0
$\begingroup$

Rosanswers logo

Is there a possiblity to send Data through UDP over a ROS Node?

To Specify my question: I have a Non-ROs Computer who provides odometry who sends through UDP the data and I want to write a ROS Node which listens to this data.

Also I want to build a ROS Node who sends data through ethernet to the non-ros computer!

thanks in advance


Originally posted by felixwatzlawik on ROS Answers with karma: 201 on 2015-04-23

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Sure. You are free to do anything you want in a ROS node. Just open a UDP socket (using basic C/C++ std runtime support, or Boost, or X ..) and use it like you would normally do.

The only 'restriction' would be that you'd have to give ROS a chance to process its events and do some bookkeeping once in a while. A typical pattern for that is something like:

while (your_own_termination_condition && ros::ok())
{
   handle_your_udp_traffic();

   // other stuff
   ..

   // let ROS do its thing
   ros::spinOnce();

   // maybe sleep a little (but that depends on your application)
   ..
}

If I understand your other question correctly, the 'other stuff' would probably include things like converting the odometry data from your motor controller into proper ROS msgs, and any incoming ROS msgs (most likely geometry_msgs/Twist) into data you can send to your motor controller over your UDP socket.


Edit: you might also be interested in using ros_control to base your own node on. Instead of implementing all of the ROS side yourself, you provide ros_control with a hardware_interface (which in your case would implement the communication with your motor controller over UDP) and 'the rest' (twist controllers, differential drive velocity calculation, and the associated ROS API) will be provided for you. If I'm not mistaken, the husky_control pkg is similarly implemented.

See davetcoleman/ros_control_boilerplate for an example of how to set this up.

I sort of assumed here that you're trying to create a differential-drive mobile robot (as you talk about odometry), but if not, ros_control can still be useful.


Originally posted by gvdhoorn with karma: 86574 on 2015-04-23

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by felixwatzlawik on 2015-04-23:
that was pretty helpful! I have no knowledge about udp sockets but I have to learn it now, thanks for your fast answer :)

Comment by felixwatzlawik on 2015-04-24:
Do I need to download boost or is it already included in ROS? I am trying now to open a UDP Socket via Boost in a Ros node!

Comment by gvdhoorn on 2015-04-24:
Boost is not 'included', but it is a dependency, so it will be installed whenever you install ROS. For your own pkg, I'd recommend adding a depend element to your manifest (see the catkin docs).

Comment by felixwatzlawik on 2015-04-27:
okay, I worked a lot and I finally get the odometry out and I am publishing the encoderdata into ros to lwheel and rwheel. I found the differential drive package which would've transformed my encoder values into odometry but I just saw it is for groovy and I am using indigo. Can I still use it or is

Comment by gvdhoorn on 2015-04-27:
I think you got the differential_drive confused with the ros_control based ros_controllers/diff_drive_controller package. The last one is a completely different pkg, and is the one I recommend you use.

Comment by felixwatzlawik on 2015-04-28:
got the Odometry running, how can I get my URDF Representation in rviz?

Comment by gvdhoorn on 2015-05-03:
There are plenty of tutorials on how to do that. In any case, it's probably better to post a new question than to keep adding to this one ('urdf representation' is rather different from 'sending data over udp').

Comment by Terry Su on 2016-01-01:
@gvdhoorn, Here is the problem which likes this problem a little but the situation is opposite. Could you click the link to see my question? Thank you so much.

Comment by Masoud on 2017-04-18:
Hi @felixwatzlawik It seems that I have the same problem as your because I want to read some encoders output through UDP. I would be grateful if you could help me solve this issue. My email address is: [email protected].

Comment by Masoud on 2017-04-18:
I also found this package. https://github.com/abhinavjain241/comm_tcp

but it is using TCP/IP protocols to communicate while I need UDP.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.