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

Do I need tf to do a simple publisher/subscriber?

asked 2011-11-22 19:15:31 -0600

jlo gravatar image

updated 2011-11-23 21:08:20 -0600

Hi,

After some time trying to find a way to simplify this code in the tutorials of simple publisher, that uses a string and turn it into a twist message but I couldn't. Here's my last effort on it.

That's why I ended up creating a modification of some of the codes that I found. Here is the subscriber and here is the publisher. I got it working, and now I ask myself: Is using tf necessary if the only thing I need is to send and receive data? (cmd_vel for the moment, although later laser_scan info, too). How can it be done? I'm at a loss here, don't know where to go from here (read a lot of documentation and finished the tutorials a couple of times)

Thanks,

Update: Awesome! I got the publisher running, but the subscriber (code here) is giving me some weird compilation problems: here.

@Lorenzo Riano: My basic concern was getting to work a code that sends some sort of speed information. Once that works, my next step is writing something similar with laser_scan. Ultimately, when I get speed control and laser_scan working, I plan to play with it and make a robot move around randomly in a .world map in Stage. So, basically, it all is for simulating it with stage, no real robot involved for now.

@Everybody: What's the best way to showcase that a publisher+subscriber works? Just by printing the message on screen once it gets to the subscriber? What if they don't fully work? Some sort of debugging available?

edit retag flag offensive close merge delete

Comments

rxconsole is your friend here :-)
Lorenzo Riano gravatar image Lorenzo Riano  ( 2011-11-24 03:52:36 -0600 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2011-11-22 19:37:17 -0600

No, TF is not necessary to do what you want. I tried your "last publisher" example (the first pastebin link), and here's what's necessary to get it running:

  • comment the include of "geometry_msgs/Twist.h" back in (it's commented out)
  • make sure that your manifest.xml contains the line <depend package="geometry_msgs"/>
  • make sure that your CMakeLists.txt contains something like this: rosbuild_add_executable(twist_publisher src/twist_publisher.cpp)
edit flag offensive delete link more
1

answered 2011-11-22 19:40:57 -0600

My understanding is that you are calculating the robot's movements when a constant speed is applied, using a unicycle model. The short answer is therefore "yes, you need to publish a tf::TransformBroadcaster in order to keep track of the robot's position".

The long answer depends on what your goal is. If you are writing a driver for a robot that reads the odometry and the velocity commands and outputs the current position, then you probably need to read this data from the hardware (wheel encorders?). If you are writing a simple simulator then this is the right path to go.

If you are familiar with Player/Stage, then https://github.com/cburbridge/uuisrc-ros-pkg/blob/master/uu-robots/player_interface/src/ros_player.cpp">here is an example of player-ros bridge that deals with transformations and publishes odometry.

Could you please describe the problems you are having, if any?

edit flag offensive delete link more

Comments

I don't why adding a link on the wiki doesn't work. The preview in the editor is fine! Any suggestion?
Lorenzo Riano gravatar image Lorenzo Riano  ( 2011-11-24 03:54:07 -0600 )edit
jlo gravatar image jlo  ( 2011-11-24 22:37:07 -0600 )edit

Question Tools

Stats

Asked: 2011-11-22 19:15:31 -0600

Seen: 517 times

Last updated: Nov 23 '11