Rosserial Script: Difference between revisions

From Control Systems Technology Group
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 10: Line 10:
The lines '''33-36''' are used to create a new ROS topic <code>arm_angles</code> to publish the ROS message <code>floats_msg</code> 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.
The lines '''33-36''' are used to create a new ROS topic <code>arm_angles</code> to publish the ROS message <code>floats_msg</code> 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.
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 [http://cstwiki.wtb.tue.nl/index.php?title=Sending_data_between_Windows_Applications&action=edit&redlink=1 here].


== Sending the data to ROS ==
== Sending the data to ROS ==
[[File:Send data.png|x280px]]
[[File:Send data.png|x280px]]
The lines '''75-77''' are used to print the content of the <code>data</code> array onto the console. This can be used to check whether the correct values are read from the text file using this piece of [http://cstwiki.wtb.tue.nl/index.php?title=Sending_data_between_Windows_Applications&action=edit&redlink=1 code].
The lines '''80-82'''  take the <code>data</code> array and its contents and put it into the <code>floats_msg</code> message. Then the message is published onto the ROS topic.
After the message has been send, the application is delayed 4000 milliseconds before sending another message. This time interval is quite long and causes the AMIGO's movements to be delayed by a big amount. A smaller delay can be tried, but it might overload the AMIGO simulator and cause it to crash.

Latest revision as of 17:30, 20 June 2016

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

The lines 75-77 are used to print the content of the data array onto the console. This can be used to check whether the correct values are read from the text file using this piece of code.

The lines 80-82 take the data array and its contents and put it into the floats_msg message. Then the message is published onto the ROS topic.

After the message has been send, the application is delayed 4000 milliseconds before sending another message. This time interval is quite long and causes the AMIGO's movements to be delayed by a big amount. A smaller delay can be tried, but it might overload the AMIGO simulator and cause it to crash.