-
Notifications
You must be signed in to change notification settings - Fork 365
Dev_Serializers
The rosbridge protocol is a specification for sending JSON based commands to ROS.
In ROS# there are some options that you can choose to make (de-)serialization between the message packages and JSON based byte chunks. .NET and Newtonsoft are available JSON (de-)serialization tools in RosBridgeClient.
RosBridgeClient is designed to keep the serialization generic. New serializers can be added by implementing the ISerializer interface:
internal interface ISerializer
{
byte[] Serialize<T>(T obj);
DeserializedObject Deserialize(byte[] rawData);
T Deserialize<T>(string JsonString);
}
internal abstract class DeserializedObject
{
internal abstract string GetProperty(string property);
}
Note that the received byte array is first deserialized to DeserializedObject via Deserialize(byte[] rawData)
, then the properties of this JSON object are extracted. Referring to rosbridge protocol, the "msg" property contains a JSON object, which is deserialized into C# classes via T Deserialize<T>(string JsonString);
.
Different JSON (de-)serialization libraries have their own type definitions for a JSON object, and fucntion definitions to extract properties from a JSON object. One should also implement the abstract class DeserializedObject accordingly.
You can see NewtonsoftJsonSerializer.cs and MicrosoftSerializer.cs as examples for implementations.
A RosSocket
is instantiated by passing in the ISerializer implementation that you want to use.
Example:
// ...
RosSocket rosSocket = new RosSocket(IProtocol protocol, ISerializer serializer);
- .NET Framework 4.7.2 and later versions, find more info on its documentation.
- See the .NET dependencies here
- An open source external library, see its documentation here
- For platform compatibilities, please see the issues.
© Siemens AG, 2020 Author: Berkay Alp Cakal ([email protected])
1. Installation and Configuration
1.1 Unity on Windows
1.2 Ubuntu on Oracle VM
1.3 ROS on Ubuntu
1.4 Gazebo Setup on VM
1.5 TurtleBot2
1.6 Shadow Hand
1.7 Gazebo Simulation Example Setup
1.8 Unity Simulation Example Setup
2. Application examples with ROS communication
2.1 Transfer a URDF from ROS to Unity
2.2 Transfer a URDF from Unity to ROS
2.3 Gazebo Simulation Example
2.4 Unity Simulation Example
2.5 Fibonacci Action Client
2.6 Fibonacci Action Server
3. Application examples without ROS communication
3.1 Import a URDF on Windows
3.2 Create, Modify and Export a URDF Model
3.3 Animate a Robot Model in Unity
ROS-Unity Coordinate System Conversions
How to add new Message Types
RosBridgeClient Protocols
RosBridgeClient Serializers
Message Handling Code Map
Action Server State Machine Model
License Headers