User Tools

Site Tools


ros:ros-ddboat-log

Back to ROS main page

Here we will see how to publish a topic on a robot and to subscribe to it on a control laptop.

Considering that the IP address of the robot is 172.20.25.204 (DDBoat n°4) and that the IP address of the control laptop is 172.20.26.81, and that the roscore runs on the laptop. The laptop will be the ROS_MASTER_URI.

On the robot terminal, we set the following environment variables:

export ROS_IP=172.20.25.203
export ROS_HOSTNAME=172.20.25.203
export ROS_MASTER_URI=http://172.20.26.81:11311

On the laptop, we set the same variables :

export ROS_IP=172.20.26.81
export ROS_HOSTNAME=172.20.26.81
export ROS_MASTER_URI=http://172.20.26.81:11311

We can now make a test by publishing a float every seconds of the robot :

rostopic pub -r 1  my_topic std_msgs/Float64 1.0

We can now echo the topic on the LapTop :

rostopic echo /my_topic

and we should get :

data: 1.0
---
data: 1.0
---
ros/ros-ddboat-log.txt · Last modified: 2023/03/31 12:12 by 127.0.0.1