-
Notifications
You must be signed in to change notification settings - Fork 373
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.6.2 / .NET Standard 2.0 / .NET Core 6.0 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, 2017-2024
-
- 1.3.1 R2D2 Setup
- 1.3.2 Gazebo Setup on VM
- 1.3.3 TurtleBot Setup (Optional for ROS2)
-
- 2.1 Quick Start
- 2.2 Transfer a URDF from ROS to Unity
- 2.3 Transfer a URDF from Unity to ROS
- 2.4 Unity Simulation Scene Example
- 2.5 Gazebo Simulation Scene Example
- 2.6 Fibonacci Action Client
- 2.7 Fibonacci Action Server
- 3.1 Import a URDF on Windows
- 3.2 Create, Modify and Export a URDF Model
- 3.3 Animate a Robot Model in Unity
- Message Handling: Readers & Writers
- Thread Safety for Message Reception
- File Server Package
- ROS-Unity Coordinate System Conversions
- Post Build Events
- Preprocessor Directives in ROS#
- Adding New Message Types
- RosBridgeClient Protocols
- RosBridgeClient Serializers
- Action Server State Machine Model
© Siemens AG, 2017-2024