How to run image_view from launch file? [closed]

asked 2020-03-09 21:35:28 -0500

Cerin gravatar image

How to I write a launch file to run the image_view window?

I have a launch file setting up a simple webcam and publishing its output to /camera/image/compressed, like:

<launch>

    <node name="camera" pkg="usb_cam" type="usb_cam_node" output="screen" >
        <param name="video_device" value="/dev/video0" />
        <param name="image_width" value="640" />
        <param name="image_height" value="480" />
        <param name="pixel_format" value="yuyv" />
        <param name="camera_frame_id" value="camera" />
        <param name="io_method" value="mmap"/>
    </node>

    <node name="camera_raw_to_plain" pkg="topic_tools" type="relay" output="screen" args="/camera/image_raw/compressed /camera/image/compressed" />

</launch>

And if I run:

rosrun image_view image_view image:=/camera/image _image_transport:=compressed _autosize:=true

then I get an image_view window showing my webcam video. However, if I try to run iamge_view from the launch file like:

<launch>

    <node name="camera" pkg="usb_cam" type="usb_cam_node" output="screen" >
        <param name="video_device" value="/dev/video0" />
        <param name="image_width" value="640" />
        <param name="image_height" value="480" />
        <param name="pixel_format" value="yuyv" />
        <param name="camera_frame_id" value="camera" />
        <param name="io_method" value="mmap"/>
    </node>

    <node name="camera_raw_to_plain" pkg="topic_tools" type="relay" output="screen" args="/camera/image_raw/compressed /camera/image/compressed" />

<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
    <param name="image" value="/camera/image" />
    <param name="autosize" value="true" />
    <param name="image_transport" value="compressed" />
</node>

</launch>

then the image_view window never appears.

What am I doing wrong?

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by gvdhoorn
close date 2020-03-10 09:22:05.838824

Comments

<param name="image" value="/camera/image" />

image is not a parameter, but a topic name. On the command line, a:=b remaps, _a:=b sets parameter a to value b.

So changing the param name="image" to remap from="image" to="/camera/image" should work.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-10 03:34:23 -0500 )edit

Related questions: #q209035, #q266318, #q200460 and #q41756.

Q&As #q200460 and #q41756 are essentially duplicates I believe.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-10 03:36:35 -0500 )edit

Thank you. That fixed it.

Cerin gravatar image Cerin  ( 2020-03-10 09:16:16 -0500 )edit

Good to hear.

Seeing as the other Q&As are essentially duplicates, I'm closing this.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-10 09:21:59 -0500 )edit