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

How to use LSD Slam with a USB Webcam

asked 2015-05-03 14:01:01 -0600

Cerin gravatar image

updated 2015-05-03 14:49:55 -0600

How do you use LSD Slam with a generic USB webcam accessible to /dev/video1?

The README's quickstart guide works flawlessly for me with Indigo. However, their instructions for using live_slam with a video source is:

rosrun lsd_slam_core live_slam /image:=<yourstreamtopic> /camera_info:=<yourcamera_infotopic>

but they don't explain what the values for <yourstreamtopic> and <yourcamera_infotopic> should be. How do I fill these in appropriately? I'm assuming one involves referencing the camera device, but there's no further documentation.

Also, how would I launch the lsd_slam_* nodes with roslaunch? I tried creating mypackage/launch/webcam_lsd_slam.launch

<launch>
    <node name="webcam" pkg="usb_cam" type="usb_cam_node" output="screen" >
        <param name="video_device" value="/dev/video1" />
        <param name="image_width" value="640" />
        <param name="image_height" value="480" />
        <param name="pixel_format" value="mjpeg" />
        <param name="camera_frame_id" value="usb_cam" />
        <param name="io_method" value="mmap"/>
    </node>
    <node name="mapper" pkg="lsd_slam_core" type="live_slam" respawn="false" output="screen">
        <remap from="image" to="/usb_cam/image_raw" />
    </node>
    <node name="viewer" pkg="lsd_slam_viewer" type="viewer" respawn="false" output="screen" />
</launch>

but I get the error:

ERROR: cannot launch node of type [usb_cam/usb_cam_node]: usb_cam
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/user/rosbuild_ws/mypackage
ROS path [2]=/opt/ros/indigo/share
ROS path [3]=/opt/ros/indigo/stacks
ERROR: cannot launch node of type [lsd_slam_core/live_slam]: lsd_slam_core
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/user/rosbuild_ws/mypackage
ROS path [2]=/opt/ros/indigo/share
ROS path [3]=/opt/ros/indigo/stacks
ERROR: cannot launch node of type [lsd_slam_viewer/viewer]: lsd_slam_viewer
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/user/rosbuild_ws/mypackage
ROS path [2]=/opt/ros/indigo/share
ROS path [3]=/opt/ros/indigo/stacks

Presumably because the build didn't create true ROS packages for lsd_slam_core or lsd_slam_viewer. Predictably, rospack find lsd_slam_core finds nothing. How do I fix that?

Per the build instructions, the lsd_slam_core and lsd_slam_viewer folders were located in /home/user/rosbuild_ws/mypackage/lsd_slam, so I tried relocating them to /home/user/rosbuild_ws/mypackage, but that did nothing.

edit retag flag offensive close merge delete

Comments

inflo gravatar image inflo  ( 2015-05-03 14:03:31 -0600 )edit

Hi Cerin, I want to do the same things with you.I add a launch file which is the same with you.But when I ran it, there have some error. And I put it in the answers 4, plz give me some advise. Thank you in advance!

zzzZuo gravatar image zzzZuo  ( 2016-08-09 04:32:13 -0600 )edit

4 Answers

Sort by ยป oldest newest most voted
0

answered 2015-05-14 21:59:57 -0600

Cerin gravatar image

I had the lsd_slam project in the wrong location. I created a workspace like:

~/workspace
    src
        lsd_slam_test
            lsd_slam

when it should have been like:

~/workspace
    src
        lsd_slam
        lsd_slam_test

After that, the next problem I ran into was that lsd_slam can't handle color video, so I had to convert it to mono using an image_proc node:

<!-- This will read a camera and show a streaming feed in a display window. -->
<launch>
    <!-- Activate the color webcam. -->
    <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
        <param name="video_device" value="/dev/video1" />
        <param name="image_width" value="640" />
        <param name="image_height" value="480" />
        <param name="pixel_format" value="mjpeg" />
        <param name="camera_frame_id" value="usb_cam" />
        <param name="io_method" value="mmap" />
    </node>
    <!-- Convert the color webcam's output to mono. -->
    <node name="to_mono_node1" pkg="image_proc" type="image_proc" ns="usb_cam" />
    <!-- Display the mono stream. -->
    <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
        <remap from="image" to="/usb_cam/image_mono" />
        <param name="autosize" value="true" />
    </node>
</launch>

After that, lsd_slam ran correctly. Unfortunately, the performance and accuracy of the resulting depth map was unusably poor.

edit flag offensive delete link more

Comments

Hello Cerin, I want to run lsd_slam using my webcam. I am newbie ROS and don't understand how you do. I use ubuntu 12.04 and fuerte. my launch file is under fuerte_workspace.roslaunch lsd_slam_core test.launch cannot locate [test.launch] in package [lsd_slam_core]

jossy gravatar image jossy  ( 2015-07-02 03:37:15 -0600 )edit
0

answered 2015-05-14 16:23:59 -0600

Tanmay gravatar image

updated 2015-05-14 16:25:49 -0600

Hello,

First of all, lsd_slam itself is a package. It doesn't need to be inside another package (I assume that my_package is a package). You probably want to rectify that.

It seems your package path doesn't have the required workspace / folders updated in it. Try executing echo $ROS_PACKAGE_PATH to check if the appropriate directory is indeed in your package path. If not, read up how to add a directory to your package path ( export ROS_PACKAGE_PATH .....)

Also, the values of <yourstreamtopic> and <yourcamerainfo_topic> typically are the following for usb_cam. (You've even mentioned this in your launch file)

So, < yourstreamtopic > is /usb_cam/image_raw

I.e., you should be running /image:=/usb_cam/image_raw

and < yourcamerainfo_topic > is /usb_cam/camera_info

edit flag offensive delete link more

Comments

Yes, "mypackage" is a package where I'm storing launch and config files for testing it specifically with my setup.

Cerin gravatar image Cerin  ( 2015-05-14 16:54:58 -0600 )edit

So you don't need the mypackage separately. Instead, add a launch directory to the lsd_slam package, and put your launch files in there. Your config files can go straight into the lsd package.

Tanmay gravatar image Tanmay  ( 2015-05-14 18:07:33 -0600 )edit

Yes, but then I'd be duplicating their package, and that's not good practice. Package dependency seems fairly commonplace in the ROS ecosystem.

Cerin gravatar image Cerin  ( 2015-05-14 21:53:06 -0600 )edit

(I'm not sure if you mean cloning the source), glad to see you solved your problem. Was TRACKING LOST for frame ... good Points, which is .... % of available points, an issue for you? I seem to be running into issues with it.

Tanmay gravatar image Tanmay  ( 2015-05-14 22:39:44 -0600 )edit

It lost tracking a lot before I calibrated it. Then I calibrated it using camera_calibration and the ptam calibration, and that helped. After that, it only lost tracking if I moved the camera quickly. I also only used 320x240 resolution to help speed it up. The algorithm seems quite slow otherwise.

Cerin gravatar image Cerin  ( 2015-05-14 23:45:13 -0600 )edit
0

answered 2015-05-15 01:19:52 -0600

KDROS gravatar image

updated 2015-05-15 01:21:00 -0600

For using this You have to have High fps camera, otherwise move camera veryslow, then You wont get track lost. IN my case also it is not working directly If i am publishing images on the fly, that is why I am using offline construction using datasheet. Calibration is very much imp. for this because that will only help to set XY position of feature point. More accurate calibration you will get more accurate 3D point cloud.

But I have one question.. Is there any scope to convert grey pointcloud into clour point cloud.??

edit flag offensive delete link more
0

answered 2016-08-09 04:43:21 -0600

zzzZuo gravatar image

Hi,I have the same problem with Cerin,but when I ran the launch file like Cerin's /webcam_lsd_slam.launch, it have some errors:

core service [/rosout] found
ERROR: cannot launch node of type [usb_cam/usb_cam_node]: usb_cam
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/zuo/ros_ws/lsd_slam/src
ROS path [2]=/home/zuo/ros_ws/ws_uav/src
ROS path [3]=/home/zuo/ros_ws/ws_ethzasl_ptam/src
ROS path [4]=/opt/ros/indigo/share
ROS path [5]=/opt/ros/indigo/stacks
process[usb_cam/to_mono_node1-2]: started with pid [21536]
ERROR: cannot launch node of type [image_view/image_view]: image_view
ROS path [0]=/opt/ros/indigo/share/ros
ROS path [1]=/home/zuo/ros_ws/lsd_slam/src
ROS path [2]=/home/zuo/ros_ws/ws_uav/src
ROS path [3]=/home/zuo/ros_ws/ws_ethzasl_ptam/src
ROS path [4]=/opt/ros/indigo/share
ROS path [5]=/opt/ros/indigo/stacks
[ERROR] [1470734987.261875629]: Skipping XML Document "/opt/ros/indigo/share/hector_pose_estimation  hector_pose_estimation_nodelets.xml" which had no Root Element.  This likely means the XML is malformed or missing.

and my workspace is like:

~/lsd_slam
    src/
        /lsd_slam
            /lsd_slam
            /lsd_slam_core
            /lsd_slam_viewer
        /lsd_slam_test
           /launch
                /webcam_lsd_slam.launch

Thank in advance!

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-05-03 14:01:01 -0600

Seen: 8,318 times

Last updated: Aug 09 '16