3

Lets say I have a robot, with a raspberry pi, or a jetson, running ROS. And I want to see the sensor readings, or something on RVIZ, on my laptop. Or maybe control the robot using a wired Xbox controller connected to my laptop... Is there anyway I can write a node on my laptop that can connect to the roscore of the robot (rpi/jetson) over the lan network, or a zigbee module or something?

Or do I have to create another instance of roscore on my laptop, and make them talk to each other through the zigbee module/lan? That would be very tedious... Please don't tell me that it's the only option.

EDIT: The part about connecting the robot and the computer using lan has been explained... I'd really appreciate it if somebody could now tell me how to connect it to the robot's roscore using RF modules

DS3a
  • 99
  • 1
  • 7

1 Answers1

5

If the robot computer (e.g. the jetson or pi) and the laptop are on the same LAN, then you only need one roscore running, say on the robot.

You need to set two environment variables, ROS_MASTER_URI and ROS_IP. ROS_MASTER_URI should be set to http://ROBOT_IP:11311 on both computers, while ROS_IP should be set to the IP address of the computer it is on. In other words, on the robot computer, ROS_IP is equal to the IP address in ROS_MASTER_URI, but on the laptop, it is equal to that laptop's IP address.

Once those environment variables are set, you can "talk" to the robot using ROS topics, just as if those ROS topics were on the same machine. There should be no change needed to your code.

See the official wiki Running ROS across Multiple Machines for more information.

Alex
  • 947
  • 6
  • 16
  • Ohh, and what about if I don't have lan, and can only communicate with the robot using an XBEE module or something? – DS3a Jan 31 '21 at 11:29
  • 1
    In that case, it's more complicated, but I imagine you can use PPP or SLIP. Something like this: https://stackoverflow.com/questions/19941357/tcp-ip-over-serial-port. This would make communication as seamless as if the machines were on the same LAN (barring any bandwidth and latency issues). If you want to do something simpler and more ad-hoc, you can e.g. use pyserial to communicate over the serial ports and use a custom protocol (using the struct module) to shuttle data. Easy for a one-way data stream, but not very robust. You can also look at established serial protocols such as mavlink. – Alex Feb 01 '21 at 04:52