Serial bridge under namespace

Hello,

is it possible to publish the topics form the serial_bridge under a namespace?

Hello MrHusarion,

There are two steps to publish topics from serial_bridge in namespace.

  1. 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.

  1. 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

Thanks for the answer.
Where can I find the ROSbot firmware for offline with VSC?

You can find it in ROSbot_examples repository on GitHub. Choose from ROSbot_2.0_PRO_default_firmware and ROSbot_2.0_default_firmware depending on your ROSbot model.

Regards,
Łukasz

It works now for most of the topics, but tf and diagnostics are still not send over the namespace. How can I also send those over the namespace?

They should not be published under namespace, both /tf and /diagnostics are system wide topics.

  • /tf messages are to be distinguished by frame names inside each message, this way it is possible to find transform between any two frames in robotic system.
  • /diagnostics topic needs to contain all hardware data as described in documentation.

Regards,
Łukasz

Hi I would like to know how does this process change with the firmware update.

Hi,

I didn’t run the serialnode in the namespace, but used remappings instead.
Then I ran the rosbot_ekf node and the msgs_conversion node in the namespace. No need to change the firmware then. The only change is in the file “$(find rosbot_ekf)/params/ekf_params.yaml”. Here, the topics imu0 and odom0 are defined as absolute topics.
Change the lines

imu0: /imu
odom0: /odom

to

imu0: imu
odom0: odom

The node accepts a tf_prefix argument
This launchfile might help you:

<group if="$(arg new_firmware)">

    <arg name="serial_port" default="/dev/ttyS1"/>
    <arg name="serial_baudrate" default="500000"/>
    <node pkg="rosserial_python" type="serial_node.py" name="$(arg robot_name)_serial_node" output="screen" machine="ROSbot-$(arg robot_name)">
        <param name="port" value="$(arg serial_port)"/>
        <param name="baud" value="$(arg serial_baudrate)"/>
        <remap from="cmd_vel" to="/$(arg robot_name)/cmd_vel"/>
            <remap from="range/fl" to="/$(arg robot_name)/range/fl"/>
            <remap from="range/fr" to="/$(arg robot_name)/range/fr"/>
            <remap from="range/rl" to="/$(arg robot_name)/range/rl"/>
            <remap from="range/rr" to="/$(arg robot_name)/range/rr"/>
            <remap from="pose" to="/$(arg robot_name)/pose"/>
            <remap from="velocity" to="/$(arg robot_name)/velocity"/>
            <remap from="mpu9250" to="/$(arg robot_name)/mpu9250"/>
            

            
    </node>


    <node machine="ROSbot-$(arg robot_name)" ns="$(arg robot_name)" pkg="rosbot_ekf" type="msgs_conversion" name="msgs_conversion" respawn="true">
    </node>
    
    <node ns="$(arg robot_name)" pkg="robot_localization" type="ekf_localization_node" name="rosbot_ekf" clear_params="true" machine="ROSbot-$(arg robot_name)"> 
        <rosparam command="load" file="$(find rosbot_ekf)/params/ekf_params.yaml" />
     
       <param name="tf_prefix" value="$(arg robot_name)"/>

        <remap from="odometry/filtered" to="odom"/>

   
    </node>
  </group>

Hope this helps.

Hi,

I forgot to mention I also removed the / for the absolute topics from the msgs_conversion node.

Everything seems to be working but the odometry is way worse then when running without namespace, so there still is something wrong.
I’ll keep you update