Hello MrHusarion,
There are two steps to publish topics from serial_bridge
in namespace.
- Edit CORE2 controller node to enable publishing/subscribing under namespace.
Open default ROSbot firmware (with cloud IDE or VSC plugin), in main.cpp
:
For subscriber, find line 73:
ros::Subscriber<geometry_msgs::Twist> *cmd_sub = new ros::Subscriber<geometry_msgs::Twist>("/cmd_vel", &twistCallback);
And remove slash preceding topic name:
ros::Subscriber<geometry_msgs::Twist> *cmd_sub = new ros::Subscriber<geometry_msgs::Twist>("cmd_vel", &twistCallback);
Do the same with line 87.
For publishers, find line 145:
range_pub_fl = new ros::Publisher("/range/fl", &range_fl);
And remove slash preceding topic name:
range_pub_fl = new ros::Publisher("range/fl", &range_fl);
Do the same for lines: 146, 147, 148, 158, 166, 175, 185.
Build project and flash it to CORE2.
General rule is that when publisher/subscriber is initialized, it may get topic provided with or without preceding slash. If topic name is with slash, the name is absolute. Without slash it will be appended to namespace if it is defined, otherwise the name is absolute.
- Set namespace for serial bridge:
export ROS_NAMESPACE=/my_namespace
In the same terminal, start serial bridge as usual:
/opt/husarion/tools/rpi-linux/ros-core2-client /dev/ttyCORE2
Topics will be published under the namespace.
Regards,
Łukasz