Message Semantics - Unity to ROS over ROSBridge
Hello,
I am trying to exchange my message between windows 10 Unity 20.17.2 and ROS1. I can subscribe to my ros topic and I am able to listen to messages in my unity environment sent from ros1.
for subscribing I am sending:
`{"op": "subscribe", "topic": "/talker", "type": "std_msgs/String"}`
from windows to ros1 using ros_bridge websockets.
However, when I publish I cannot see my message on my ros terminal. I advertise first:
{"op": "advertise", "topic": "/talker", "type": "std_msgs/String"}
which reflects over ros bridge as 1 client is connected.
Then I publish my message:
{"op": "publish", "topic": "/talker", "msg": {"data" : _my_message }}
My subscriber node: (just using straight away from the tutorial)
#include "ros/ros.h"
#include "std_msgs/String.h"
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "sub_node");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("talker", 0, chatterCallback);
ros::spin();
return 0;
}
But I never receive any message. I have converted my message into JSON as per rosbridge protocol:
{ "op": "publish",(optional) "id": <string>,"topic": <string>, "msg": <json>}
I am using the websocketsharp library to create my WebSocket connection, which should not really be an issue as I can listen to messages from ros and establish the connection. It should be something wrong with my publisher node or data model I am sending.
Any pointers, please?