ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

use_sim_time and rosserial for Arduino

asked 2023-04-11 04:34:05 -0500

cst gravatar image

Hello,

In my project (in ROS melodic), I have to use simulation time for carla_ros_bridge and CARLA and have to control a real mobile robot that gets its movement commands from my /ackermann_cmd topic.

The problem is, with "use_sim_time=true", the ackermann_cmd messages are not executed by the robot and the robot also doesn't publish its state to the topic /atv_state (with "use_sim_time=false", both work just fine). I suspect that the robot's Arduino code doesn't sufficiently synchronize the time with ROS, but I haven't found any examples on how to do that for ROS simulation time.

Arduino code: https://github.com/Lapland-Robotics/m...

It could be that something like "ros::Time begin = nh.now();" is missing in the Arduino code, but I've also seen examples without, and again - none that explicitly deal with ROS simulation time in Arduino code.

For the sake of completeness, here is the launch file I used for testing my problem:

<launch>

   <!--  ************** Global Parameters ***************  -->
   <param name="use_sim_time" value="false"/>

   <node pkg="rostopic" type="rostopic" name="ackermann_cmd"
     args="pub /ackermann_cmd ackermann_msgs/AckermannDriveStamped '{header: auto, drive:{speed: 1.0}}' --rate 10 -s" />

   <!--  ****** rosserial ***** --> 
   <node pkg="rosserial_python" type="serial_node.py" name="serial_node">
   <param name="port" value="/dev/ATV_Interface_Port"/>
   <param name="baud" value="57600"/>
   </node>
</launch>

Since the robot architecture makes it quite complicated to change the Arduino code, it would be very helpful to know if the problem is indeed in the Arduino code or if it is something else. Any help is greatly appreciated!

Thanks in advance, cst

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-12 08:51:03 -0500

cst gravatar image

I found a workaround: Run two rosmasters in the system instead of one for the whole system. One rosmaster in the laptop where CARLA and carla_ros_bridge are running and one in the mobile robot. Then start the multimaster_fkie to establish communication between both rosmasters. The rosmaster on the CARLA side in the laptop will have use_sim_time=True and the rosmaster on the robot's side has use_sim_time=False and therefore is sending and receiving ros messages as usual.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2023-04-11 04:34:05 -0500

Seen: 98 times

Last updated: Jul 12 '23