Rosserial Script

From Control Systems Technology Group
Jump to navigation Jump to search

This is a brief explanation of the code used to set up a connection to a Ubuntu machine running ROS and the ROS socket node and to publish ROS messages to a specific ROS topic from a Windows machine.

This code is part of a project to create a robot technique that allows users to hug someone when separated by a disctance like a phone call.

Setting up the connection to ROS

Setup.png

The lines 27-30 are responsible for setting up the connection to the Ubuntu machine. The characterstring *ros_master should be the IP address of the Ubuntu machine. Make sure a connection can be established from the Windows machine to this computer by pinging this IP address.

The lines 33-36 are used to create a new ROS topic arm_angles to publish the ROS message floats_msg onto. This message is a standard Float64MultiArray message. Only the data property of this message type is used to send all the latest calculated arm angles in a bundle.

In the final lines 39-42 an empty array of 14 doubles is created. The calculated arm angles are put into this array. This is part of the code is however not covered on this page, but here.

Sending the data to ROS

Send data.png