Home | Tutorials | Wiki | Issues
Ask Your Question
0

Tutorial: Intermediate: Connect to ROS - Laser is not spinning

asked 2017-02-01 10:03:38 -0600

Hatze gravatar image

updated 2017-02-02 08:16:01 -0600

Hi,

i have recently started with Gazebo and ROS hence I thought it is a good start doing the tutorial http://gazebosim.org/tutorials?cat=gu...

I have followed all the previous steps in the tutorial - everything worked well and I could also spin the laser by sending a message over the API I created.

The problem I now face is that Gazebo seems not to subscribe to the topic I start with ROS. Following the tutorial step by step (sourcing every step and maintaining the default directory structure )has not lead to success.

When running rostopic info /my_velodyne/vel_cmd I get the following:

Type: std_msgs/Float32

Publishers: 
 * /rostopic_13126_1485965572986 (http://ThinkPad-T460p:45658/)

Subscribers: None

So it seems that I publish a value which I can also read using rostopic echo /my_velodyne/vel_cmd but nothing (gazebo) is not listening to that value.

Since I usually work with catkin and ros I have no idea how to let gazebo subsribe to the given topic.

I am running ubuntu 16.04 and gazebo 7.0.0 and ros kinetic.

Thank you so much for your help! Any advice is appreciated!

Thanks for the fast fast response! Unfortunately I have both your suggestions did not help. I can run other ros code in my console and I also sourced the setup.bash in every new terminal I opended. Also the velodyne.world file is calling the model name="my_velodyne".

Hence I will share the code with you now!

edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
0

answered 2017-08-15 00:05:27 -0600

alienmon gravatar image

I faced the same problem with you. It was because I needed to export the path first before running gazebo. As a result, the gazebo PLUGIN did not properly load.

If you run

gazebo --verbose velodyne.world

you can see an error message saying that the program couldn't find the lib for velodyne_plugin

What you should do:

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:~/velodyne_plugin/build

gazebo velodyne.world

Then It should work fine.

edit flag offensive delete link more

Comments

I followed the tutorial to the T, and was having issues publishing from ROS. This fixed my issue, thanks!

flcwedge gravatar imageflcwedge ( 2018-01-20 16:30:41 -0600 )edit
0

answered 2017-02-01 17:23:30 -0600

hugomatic gravatar image

updated 2017-02-03 18:25:51 -0600

Well,

So I used the files you posted, and I compiled them on my machine. Without any changes, I was able to get the laser spinning. So my guess is that there's a problem in your model file (which you forgot to post). Here's a world file (that embeds a velodyne model) that worked for me. Try it out and let us know if it works (or not).

C:\fakepath\velodyne.world

edit flag offensive delete link more

Comments

Can you also send the model sdf file?

hugomatic gravatar imagehugomatic ( 2017-02-02 18:05:12 -0600 )edit
0

answered 2017-02-02 09:02:22 -0600

nkoenig gravatar image

Step 3 in the tutorial has you create a ROS subscriber. The output of your rostopic info /my_velodyne/vel_cmd seems to say that there is a publisher, but not subscriber.

Here are things to try:

  1. Are you creating the subscriber, and is your code being exited correctly (use GDB or print statements)?
  2. Is the name of the topic correct? Try rostopic list to see all the topics, and check if one looks suspicious.
edit flag offensive delete link more
0

answered 2017-02-02 06:43:56 -0600

Hatze gravatar image

Thanks for the fast fast response! Unfortunately I have both your suggestions did not help. I can run other ros code in my console and I also sourced the setup.bash in every new terminal I opended. Also the velodyne.world file is calling the model name="my_velodyne".

Hence I will share the code with you now!

velodyne.world:

<?xml version="1.0" ?>
<sdf version="1.5">
  <world name="default">
    <!-- A global light source -->
    <include>
      <uri>model://sun</uri>
    </include>
    <!-- A ground plane -->
    <include>
      <uri>model://ground_plane</uri>
    </include>

    <!-- A testing model that includes the Velodyne sensor model -->
    <model name="my_velodyne">
      <include>
        <uri>model://velodyne_hdl32</uri>
      </include>

      <!-- Attach the plugin to this model -->
      <plugin name="velodyne_control" filename="libvelodyne_plugin.so">
    <velocity>2</velocity>
      </plugin>
    </model>

  </world>
</sdf>

velodyne_plugin.cc C:\fakepath\velodyne_plugin.cc

vel.cc C:\fakepath\vel.cc

Thanks again for your help!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-02-01 10:03:38 -0600

Seen: 1,236 times

Last updated: Aug 15 '17