Robotics StackExchange | Archived questions

No data from SICK S300 in ROS

Using the cobsicks300 package and an RS422 -> USB connection to a Raspberry Pi I can't seem to get any data that will visualise in ROS/RVIZ although I am able to view the incoming data in a python program reading from the /dev/ttyUSB0 interface.

s300_launch.launch file

<launch
        <rosparam command ="load" file="$(find cob_sick_s300)s300_config.yaml"/> 
</launch>

s300_config.yaml file

port: /dev/ttyUSB0
baud: 38400
scan_duration: 0.025
scan_cycle_time: 0.040
inverted: true
scan_id: 7
frame_id: laser
scan_intervals: [[-1.3526, 1.361357]]

Asked by fzeta on 2019-08-27 03:56:33 UTC

Comments

Can you show what your rviz looks like? It is possible you don't have rviz configured correctly.

Asked by MCornelis on 2019-08-27 05:27:46 UTC

I've added the laserscan and tried to add the topic for the scanner, however before doing so I'm unable to find it using rostopic list as it only shows

/rosout
/rosout_agg

Asked by fzeta on 2019-08-27 05:41:47 UTC

Your .launch file doesn't appear to start any node(s). It just loads some parameters from a .yaml file.

No driver is started, which would explain why you're not seeing any topics other than the default ones, and no data is being published.

Asked by gvdhoorn on 2019-08-27 05:55:38 UTC

Oh, what would I need to do to start a node in this context?

Asked by fzeta on 2019-08-27 05:56:27 UTC

You'll have to figure out how to actually start the driver. I don't have any experience with that package, so I wouldn't know.

There may be other .launch files that you could use. I'd check for those first.

Have you checked the wiki page of the package? It refers to launch files in cob_bringup that you may be able to use as templates/examples.

Asked by gvdhoorn on 2019-08-27 05:59:33 UTC

Have a look here for an explanation on roslaunch using XML: http://wiki.ros.org/roslaunch/XML

Asked by MCornelis on 2019-08-27 06:01:42 UTC

https://github.com/ipa320/cob_robots/blob/kinetic_dev/cob_bringup/drivers/sick_s300.launch I was also able to find this for kinetic. Might be useful as an example.

Asked by MCornelis on 2019-08-27 06:06:36 UTC

I'm having trouble with the cob_hardware_config package as I can't seem to find it through apt-get. It doesn't seem to be a Melodic package

Asked by fzeta on 2019-08-27 06:16:41 UTC

You don't need to install all of those packages. I would suggest to look at the source, find the launch files mentioned and then create one of your own.

Asked by gvdhoorn on 2019-08-27 06:50:04 UTC

The link I gave you was how to bringup a complete robot setup. That setup happened to be using the sick s300 laser that you are using. So you could probably use the lines related to starting the laser driver. The other lines, you will need to replace with whatever you need for your setup. If your only goal is to see some laserdata in ROS and rviz then just launching the driver will probably suffice. So the relevant part of the launch file for you would be:

<node  pkg="cob_sick_s300" type="cob_sick_s300" name="driver" respawn="false" output="screen">
</node>

You can use the other link I posted about roslaunch XML to figure out how to pass your config file in there. Alternatively you can set all the params in your launch file as follows:

<launch>
  <node  pkg="cob_sick_s300" type="cob_sick_s300" name="driver" respawn="false" output="screen">
  <param name="serial_port"         type="string" value="/dev/ttyUSB0"/>  
        ...
  </node>
</launch>

Asked by MCornelis on 2019-08-27 07:16:15 UTC

Thank you so much, I've got the node running, however it can't seem to open the config file correctly, as I don't know how to format it with the new node name

Asked by fzeta on 2019-08-27 07:51:54 UTC

I believe I have the data coming through, I just need to setup Rviz correctly to the node I think or make a topic?

Asked by fzeta on 2019-08-27 08:01:13 UTC

In Rviz you can press the add button in the bottom left and then add a LaserScan. The LaserScan will then be in the Displays list. There you can open the dropdown under the laserscan and select your laserscan topic. If nothing is displayed then make sure you set the fixed frame under global options to the frame of the laser.

Asked by MCornelis on 2019-08-27 09:01:26 UTC

If you get this to work you can then in rviz go to "file>save config as" and save your rviz configuration. This configuration can then be reloaded the next time you open rviz. You could also add rviz to your launchfile and load rviz with the config. This way, when your laser node starts, rviz will also be started with the correct config. This means you don't have to add the LaserScan to the display every time.

Asked by MCornelis on 2019-08-27 09:06:27 UTC

It finds the topics /scan from the laser frame but nothing is printed out onto the map

Asked by fzeta on 2019-08-27 09:16:05 UTC

Have you tried setting Global options>fixed frame to "laser" instead of "map". If that does not work then you'll have to figure out the name of the frame the laserscan is published in (laser tends to be the default).

Asked by MCornelis on 2019-08-27 09:17:47 UTC

i believe it finds the correct topic, its the only one availible in "laser" https://imgur.com/a/eWN2LwR

Asked by fzeta on 2019-08-27 09:25:31 UTC

Rviz says the frame laser does not exist. So that is the problem right now. Your data is being published, but rviz needs to know in which tf frame this is happening. Tf is used to transform data between frames. The fixed frame stated in rviz is the "base" frame/center of your visualization. All other data is visualized relative to this fixed frame in their respective frames. You need to find the name of your laser frame and make that the fixed frame. From your config:

frame_id: laser

I expected this to be "laser", but according to rviz this is not he case. Did you manage to pass the parameters correctly yet?

Asked by MCornelis on 2019-08-27 09:31:58 UTC

Here is an example for a different type of laser, maybe you can edit this with your values/parameter names and see if that works:

<launch>
  <node name="rplidarNode"          pkg="rplidar_ros"  type="rplidarNode" output="screen">
  <param name="serial_port"         type="string" value="/dev/ttyUSB0"/>  
  <param name="serial_baudrate"     type="int"    value="256000"/><!--A3 -->
  <param name="frame_id"            type="string" value="laser"/>
  <param name="inverted"            type="bool"   value="false"/>
  <param name="angle_compensate"    type="bool"   value="true"/>
  <param name="scan_mode"           type="string" value="Sensitivity"/>
  </node>
</launch>

Asked by MCornelis on 2019-08-27 09:37:28 UTC

I let the parameters fall to default as they weren't passing with the new node name "driver". To go in the launch file?

Asked by fzeta on 2019-08-27 09:43:54 UTC

You are free to pick the name to be whatever you want. The pkg and type need to reference the correct ros package and executable.

Asked by MCornelis on 2019-08-27 09:47:27 UTC

I've got the parameters set up, its finding the /scan topic using the fixed frame: laser but reamins to say "no tf data" and I'm getting "communication timeout" in the roslaunch window however I'm also getting opening scanner, and scanner opened successfully messages

Asked by fzeta on 2019-08-27 10:00:30 UTC

You could try adding a static tf broadcaster: http://wiki.ros.org/tf2/Tutorials/Writing%20a%20tf2%20static%20broadcaster%20%28C%2B%2B%29 and broadcast a static transform that does no transformation whatsoever between map and laser (so laser is at x=0 y=0 z=0 roll=0 pitch=0 yaw=0 or the quaternion equivalent x=0 y=0 z=0 qx=0 qy=0 qz=0 qw=1). So in your case something like this:

<launch>
<node  pkg="cob_sick_s300" type="cob_sick_s300" name="driver" respawn="false" output="screen">
  <param name="serial_port"         type="string" value="/dev/ttyUSB0"/>  
  ... etc. etc.

<node pkg="tf2_ros" type="static_transform_publisher" name="laser_transform_broadcaster" args="0 0 0 0 0 0 1 map laser" />
</launch>

Normally I would expect the laser driver to provide this for you though. If you do this you should be able to use the map or laser frame as your fixed frame, since you are now providing tf with a transformation between map and laser frame.

Asked by MCornelis on 2019-08-27 10:44:19 UTC

I've tried doing so but nothing seems to be working and I'm not sure why? rostopic echo /scan doesn't show any data in the terminal, so perhaps it isn't reading correctly? or its the wrong topic?

Asked by fzeta on 2019-08-28 03:52:31 UTC

If you are not getting data using echo then there is probably something wrong with your configuration (are you sure things like the baudrate are correct?). It would also make sense that Rviz is not displaying anything then, because there is simply no data being published. When something listens to a topic expecting data, but no data arrives that is when you get a communication timeout.

Asked by MCornelis on 2019-08-28 04:01:11 UTC

I've checked all of my config, baudrate etc and it should be working by now but I'm lost on what could be the issue

Asked by fzeta on 2019-08-28 07:36:39 UTC

I've got data coming from the device into ROS however it's throwing a [driver-2] process has died and it's very inconsistent, their are communication timeouts between the messages from the S300

Asked by fzeta on 2019-08-28 08:10:25 UTC

Perhaps you could try to contact the cob_sick_s300 package maintainer or the people from SICK. Have you verified that the sensor works with the proprietary driver that SICK provides? I don't have the laser so I can't recreate the situation. I'm afraid my help ends here.

Asked by MCornelis on 2019-08-28 09:51:28 UTC

Thanks a tonne for the help. I got the data flowing through properly at a lower baudrate 115200 although I'm hitting a problem with the package I beleive as the node dies and doesn't report a log file correctly.

Asked by fzeta on 2019-08-29 02:52:30 UTC

Answers