ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Sending Data over UDP through Node

asked 2015-04-23 01:58:42 -0600

felixwatzlawik gravatar image

updated 2015-04-23 02:34:23 -0600

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-04-23 03:25:10 -0600

gvdhoorn gravatar image

updated 2015-04-23 03:55:44 -0600

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.

edit flag offensive delete link more

Comments

that was pretty helpful! I have no knowledge about udp sockets but I have to learn it now, thanks for your fast answer :)

felixwatzlawik gravatar image felixwatzlawik  ( 2015-04-23 03:41:53 -0600 )edit

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!

felixwatzlawik gravatar image felixwatzlawik  ( 2015-04-24 02:43:29 -0600 )edit
1

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).

gvdhoorn gravatar image gvdhoorn  ( 2015-04-24 03:33:06 -0600 )edit

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

felixwatzlawik gravatar image felixwatzlawik  ( 2015-04-27 09:32:03 -0600 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2015-04-27 09:56:46 -0600 )edit

got the Odometry running, how can I get my URDF Representation in rviz?

felixwatzlawik gravatar image felixwatzlawik  ( 2015-04-28 09:06:31 -0600 )edit

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').

gvdhoorn gravatar image gvdhoorn  ( 2015-05-03 06:44:25 -0600 )edit

@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.

Terry Su gravatar image Terry Su  ( 2016-01-01 09:19:51 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-04-23 01:58:42 -0600

Seen: 3,870 times

Last updated: Apr 23 '15