Skip to content

Conversation

@nfynt
Copy link

@nfynt nfynt commented Nov 2, 2025

[2.2.1] - 02.11.2025

  • ROS2 Quaternion parsing fix: Properly parse Quaternion data stream on Unity side when using ROS2 client. The older method was using member variable instead of member function for respective components, which broke the json parsing pipeline. Using getter/setter method seems to fix this behaviour.

…on Unity side when using ROS2 client. The older method was using member variable instead of member function for respective components, which broke the json parsing pipeline. Using getter/setter method seems to fix this behaviour.
Copy link
Collaborator

@memrecakal memrecakal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nfynt, Thanks for reaching out. This is a known issue that will be fixed in an upcoming patch. It seems you have already resolved the issue, but also you should be able to use Newtonsoft.JSON without making any modifications.

System.Text.Json doesn't serialize fields by default, but adding an auto-property will fix the problem. However, you modified an auto-generated message, which explicitly states not to modify it. You can modify MessageGeneration, but an easier solution would be to add IncludeFields = true to the MicrosoftSerializer class. Due to the design of ROS messages, exposing internal representations will not cause encapsulation problems and performance loss will be negligible.

public double y = 0;
public double z = 0;
public double w = 1;
public double x { get; set; }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring an auto-property will fix the serialization problem due to the hidden backing field, but this is an auto-generated message so it should not be modified; rather, the Message Generator should be modified. Also, geometry_msgs/msg/Quaternion includes default values by message definition.

Suggested change
public double x { get; set; }
public double x { get; set; } = 0;

@memrecakal memrecakal closed this Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants