Skip to content

Commit

Permalink
CLOiSim-2.3.1
Browse files Browse the repository at this point in the history
[Major Changes]

* Upgrade Unity editor version
  -> 2020.3.7f1 (LTS)

* Sensor Device related
  * parsing output type for laser scan in LaserPlugin
  * Memory handling for native array in Camera Sensor device
  * Modify Lidar Sensor Device code
    - using callback function for AsyncGPUReadackRequest
    - native array memory handling for LaserCamData and DepthCamBuffer structure
  * handling Memory leackage for nativearray in Lidar Sensor devcie
  
* SDF related  
  * Change wheel properties in MicomPlugin
  : wheel/base -> wheel/tread


[Minor Changes]

* Versions
  * Update app version info in Project settings
    : 2.3.0 -> 2.3.1

* Sensor Device
  * Add protection code in depth camera
    - null check for compute shader	
  * Change class name
    - DevicePlugin -> CLOiSimPlugin
    - DevicesPlugin -> CLOiSimMultiPlugin
  * Handling CLOiSimPlugin when destory the objects before close the application -> Stop thread
  * Change to reusable command buffer in Camera Sensor device
  * Trying to save memory in Motor Module and it does not call SetTargetVelocityAndForce() method when direction is switched
  * missing call base method from OnDestroy() method in inherited class
  * Change global spherical coordniates for GPS sensor device in DeviceHelper

* General
  * Disable BakeMesh option in ProjectSeetings

* Services
  * remove websocket when destory the object

* GUI
  * add yield for coroutine in MarkerVisualizer
  * Moved Drawing contact line on Editor mode into OnDrawGizmos() method for SDF.Helper.Link() class


[Bug fix]

* Sensor device
  * Bug Fix: missed calling ProcessDevice() method in DeviceThread()
  • Loading branch information
hyunseok-yang authored May 11, 2021
1 parent 09f2285 commit 396872c
Show file tree
Hide file tree
Showing 56 changed files with 312 additions and 246 deletions.
8 changes: 8 additions & 0 deletions Assets/Scripts/CLOiSimPlugins.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Assets/Scripts/CLOiSimPlugins/CLOiSimMultiPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2020 LG Electronics Inc.
*
* SPDX-License-Identifier: MIT
*/

using System.Collections.Generic;
using System.Xml;
using UnityEngine;

public abstract class CLOiSimMultiPlugin : CLOiSimPlugin
{
private Dictionary<string, CLOiSimPlugin> CLOiSimPlugins = new Dictionary<string, CLOiSimPlugin>();

public void AddCLOiSimPlugin(in string deviceName, in CLOiSimPlugin CLOiSimPlugin)
{
CLOiSimPlugins.Add(deviceName, CLOiSimPlugin);
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using messages = cloisim.msgs;
using Any = cloisim.msgs.Any;

public abstract partial class DevicePlugin : DeviceTransporter, IDevicePlugin
public abstract partial class CLOiSimPlugin : DeviceTransporter, ICLOiSimPlugin
{
protected static messages.Param ParsingInfoRequest(in byte[] srcReceivedBuffer, ref MemoryStream dstCameraInfoMemStream)
{
Expand Down
15 changes: 15 additions & 0 deletions Assets/Scripts/CLOiSimPlugins/CLOiSimPlugin.InfoService.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
using UnityEngine;
using System.Xml;

public interface IDevicePlugin
public interface ICLOiSimPlugin
{
void SetPluginName(in string name);
void SetPluginParameters(in XmlNode node);
void Reset();
}

public abstract partial class DevicePlugin : DeviceTransporter, IDevicePlugin
public abstract partial class CLOiSimPlugin : DeviceTransporter, ICLOiSimPlugin
{
public enum Type {WORLD, ELEVATOR, MICOM, GPS, LASER, CAMERA, DEPTHCAMERA, MULTICAMERA, REALSENSE};

public Type type { get; protected set; }

private BridgeManager bridgeManager = null;
private static BridgeManager bridgeManager = null;

public string modelName { get; protected set; } = string.Empty;
public string partName { get; protected set; } = string.Empty;

private Pose devicePluginPose = Pose.identity;
private Pose pluginPose = Pose.identity;

public string pluginName { get; protected set; } = string.Empty;
protected SDF.Helper.PluginParameters parameters = new SDF.Helper.PluginParameters();
Expand All @@ -41,10 +41,19 @@ public enum Type {WORLD, ELEVATOR, MICOM, GPS, LASER, CAMERA, DEPTHCAMERA, MULTI

protected bool IsRunningThread => runningThread;

public void Stop() { runningThread = false; }

private Device device = null;

protected abstract void OnAwake();
protected abstract void OnStart();
protected virtual void OnReset() {}

public void SetDevice(in Device device)
{
this.device = device;
}

protected bool AddThread(in ThreadStart function)
{
if (function != null)
Expand All @@ -68,7 +77,7 @@ private void StartThreads()
}
}

public void ChangePluginType(in DevicePlugin.Type targetType)
public void ChangePluginType(in CLOiSimPlugin.Type targetType)
{
type = targetType;
}
Expand All @@ -92,7 +101,7 @@ public void SetPluginParameters(in XmlNode node)

public Pose GetPose()
{
return devicePluginPose;
return pluginPose;
}

private bool PrepareDevice(in string subPartName, out ushort port, out ulong hash)
Expand Down Expand Up @@ -182,10 +191,13 @@ void Awake()
}
else
{
bridgeManager = coreObject.GetComponent<BridgeManager>();
if (bridgeManager == null)
{
Debug.LogError("Failed to get 'bridgeManager'!!!!");
bridgeManager = coreObject.GetComponent<BridgeManager>();
if (bridgeManager == null)
{
Debug.LogError("Failed to get 'bridgeManager'!!!!");
}
}
}

Expand Down Expand Up @@ -221,7 +233,6 @@ public void Reset()

void OnDestroy()
{
// Debug.Log("DevicePlugin destroied");
runningThread = false;
foreach (var thread in threadList)
{
Expand All @@ -230,6 +241,7 @@ void OnDestroy()
if (thread.IsAlive)
{
thread.Join();
thread.Abort();
}
}
}
Expand All @@ -240,6 +252,8 @@ void OnDestroy()
{
DeregisterDevice(hashKey);
}

// Debug.Log(name + ", CLOiSimPlugin destroyed !!!!!!!!!!!");
}

protected void ThreadWait()
Expand All @@ -250,8 +264,8 @@ protected void ThreadWait()
private void StorePose()
{
// Debug.Log(deviceName + ":" + transform.name);
devicePluginPose.position = transform.localPosition;
devicePluginPose.rotation = transform.localRotation;
pluginPose.position = transform.localPosition;
pluginPose.rotation = transform.localRotation;
}

protected static void ClearMemoryStream(ref MemoryStream ms)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using Stopwatch = System.Diagnostics.Stopwatch;

public class CameraPlugin : DevicePlugin
public class CameraPlugin : CLOiSimPlugin
{
private SensorDevices.Camera cam = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using UnityEngine;

public partial class ElevatorSystem : DevicePlugin
public partial class ElevatorSystem : CLOiSimPlugin
{
private enum ElevatorState {STOP = 0, UPWARD, DOWNWARD};
private struct ElevatorEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
using Param = cloisim.msgs.Param;
using Any = cloisim.msgs.Any;

public partial class ElevatorSystem : DevicePlugin
public partial class ElevatorSystem : CLOiSimPlugin
{
private enum ElevatorTaskState {DOOR_OPEN, DOOR_CLOSE, STANDBY, PROCESSING, DONE}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using Stopwatch = System.Diagnostics.Stopwatch;

public class GpsPlugin : DevicePlugin
public class GpsPlugin : CLOiSimPlugin
{
private SensorDevices.GPS gps = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
* SPDX-License-Identifier: MIT
*/

using System.IO;
using ProtoBuf;
using Stopwatch = System.Diagnostics.Stopwatch;
using messages = cloisim.msgs;
using Any = cloisim.msgs.Any;

public class LaserPlugin : DevicePlugin
public class LaserPlugin : CLOiSimPlugin
{
private SensorDevices.Lidar lidar = null;

Expand Down Expand Up @@ -67,6 +71,10 @@ private void Response()
SetROS2CommonInfoResponse(ref msForInfoResponse, topic_name, frame_id);
break;

case "request_output_type":
SetOutputTypeResponse(ref msForInfoResponse);
break;

case "request_transform":
var devicePose = device.GetPose();

Expand All @@ -83,4 +91,15 @@ private void Response()
ThreadWait();
}
}

private void SetOutputTypeResponse(ref MemoryStream msInfo)
{
var output_type = parameters.GetValue<string>("output_type", "LaserScan");
var outputTypeInfo = new messages.Param();
outputTypeInfo.Name = "output_type";
outputTypeInfo.Value = new Any { Type = Any.ValueType.String, StringValue = output_type };

ClearMemoryStream(ref msInfo);
Serializer.Serialize<messages.Param>(msInfo, outputTypeInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using messages = cloisim.msgs;
using Any = cloisim.msgs.Any;

public class MicomPlugin : DevicePlugin
public class MicomPlugin : CLOiSimPlugin
{
private MicomInput micomInput = null;
private MicomSensor micomSensor = null;
Expand Down Expand Up @@ -173,7 +173,7 @@ private void SetWheelInfoResponse(ref MemoryStream msWheelInfo)
wheelInfo.Value = new Any { Type = Any.ValueType.None };

var baseInfo = new messages.Param();
baseInfo.Name = "base";
baseInfo.Name = "tread";
baseInfo.Value = new Any { Type = Any.ValueType.Double, DoubleValue = micomSensor.WheelBase };
wheelInfo.Childrens.Add(baseInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using messages = cloisim.msgs;
using Any = cloisim.msgs.Any;

public class MultiCameraPlugin : DevicePlugin
public class MultiCameraPlugin : CLOiSimPlugin
{
private SensorDevices.MultiCamera multicam = null;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DevicePlugins
# CLOiSimPlugin

These plugin scripts are for sensor connection.

Expand All @@ -17,7 +17,7 @@ For example, if it describes a name with 'RobotControl' in `<plugin>` attributes
<kd>0.0</kd>
</PID>
<wheel>
<base>449</base>
<tread>449</tread>
<radius>95.5</radius>
<location type="left">LeftWheel</location>
<location type="right">RightWheel</location>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using messages = cloisim.msgs;
using Any = cloisim.msgs.Any;

public class RealSensePlugin : DevicesPlugin
public class RealSensePlugin : CLOiSimMultiPlugin
{
private Camera[] cameras = null;
private List<string> activatedModules = new List<string>();
Expand Down Expand Up @@ -71,10 +71,10 @@ private CameraPlugin FindAndAddCameraPlugin(in string name)
if (camera.gameObject.name.Equals(name))
{
var plugin = camera.gameObject.AddComponent<CameraPlugin>();
plugin.ChangePluginType(DevicePlugin.Type.REALSENSE);
plugin.ChangePluginType(CLOiSimPlugin.Type.REALSENSE);
plugin.subPartName = name;

AddDevicePlugin(name, plugin);
AddCLOiSimPlugin(name, plugin);
activatedModules.Add(name);
return plugin;
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/Core/BridgeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class BridgeManager : MonoBehaviour
private Dictionary<string, ushort> haskKeyPortMapTable = new Dictionary<string, ushort>();

/*
* ModelName, DevicePluginType, Devicename, topic : portnumber
* ModelName, CLOiSimPluginType, Devicename, topic : portnumber
*
* {
* "ModelName":
* {
* "DevicePluginType":
* "CLOiSimPluginType":
* {
* "PartsName":
* {
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Core/SimulationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void OnDestroy()
if (wsServer != null)
{
Debug.Log("Stop WebSocket Server");
wsServer.RemoveWebSocketService("/control");
wsServer.RemoveWebSocketService("/markers");
wsServer.Stop();
}
}
Expand Down
5 changes: 3 additions & 2 deletions Assets/Scripts/Core/SimulationWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using UnityEngine;

public class SimulationWorld : DevicePlugin
public class SimulationWorld : CLOiSimPlugin
{
private Clock clock = null;

Expand All @@ -16,6 +16,7 @@ protected override void OnAwake()
{
type = Type.WORLD;
clock = gameObject.AddComponent<Clock>();
SetDevice(clock);

modelName = "World";
partName = "cloisim_world";
Expand All @@ -39,4 +40,4 @@ private void Sender()
}
}
}
}
}
2 changes: 1 addition & 1 deletion Assets/Scripts/Core/SimulationWorld.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 396872c

Please sign in to comment.