[Documentation] [TitleIndex] [WordIndex

Problem: Write a launch file that loads image_proc (as a collection of nodelets) in a user-selectable namespace (default "camera").

Solution with current image_pipeline:

<launch>

  <!-- For simplicity, assume top-level manager already running -->
  <arg name="manager" />

  <!-- Mimic remapping, so can launch with 'camera:=prosilica' -->
  <arg name="camera" default="camera" />
  
  <!-- Push down all topics/nodelets into "camera" namespace -->
  <group ns="$(arg camera)" />

    <!-- Debayer and publish monochrome and color topics -->
    <node pkg="nodelet" type="nodelet" name="debayer"
          args="load image_proc/debayer $(arg manager)" />

    <!-- Rectify monochrome images -->
    <node pkg="nodelet" type="nodelet" name="rectify_mono"
          args="load image_proc/rectify $(arg manager)" />

    <!-- Rectify color images - need to remap default topics -->
    <node pkg="nodelet" type="nodelet" name="rectify_color"
          args="load image_proc/rectify $(arg manager)">
      <remap from="image_mono" to="image_color" />
      <remap from="image_rect" to="image_rect_color" />
    </node>

  </group> <!-- camera ns -->

</launch>

Solution in modified image_pipeline, where each nodelet remaps "camera":

<launch>

  <!-- For simplicity, assume top-level manager already running -->
  <arg name="manager" />

  <!-- Mimic remapping, so can launch with 'camera:=prosilica' -->
  <arg name="camera" default="camera" />
  
  <!-- Debayer and publish monochrome and color topics -->
  <node pkg="nodelet" type="nodelet" name="debayer"
        args="load image_proc/debayer $(arg manager)">
    <remap from="camera" to="$(arg camera)" />
  </node>

  <!-- Rectify monochrome images -->
  <node pkg="nodelet" type="nodelet" name="rectify_mono"
        args="load image_proc/rectify $(arg manager)">
    <remap from="camera" to="$(arg camera)" />
  </node>

  <!-- Rectify color images - need to remap default topics -->
  <node pkg="nodelet" type="nodelet" name="rectify_color"
        args="load image_proc/rectify $(arg manager)">
    <remap from="$(arg camera)/image_mono" to="$(arg camera)/image_color" />
    <remap from="$(arg camera)/image_rect" to="$(arg camera)/image_rect_color" />
  </node>

</launch>

Notice in the rectify_color nodelet, we have to be very careful when remapping specific topics. That's because the ros::NodeHandle namespace scoping mechanism ends up applying namespace remappings left-to-right. So "camera" gets remapped to "prosilica", and then we have to map "prosilica/image_mono" to whatever we actually want.


2024-11-09 14:33