Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So this did not fit into the comments section:

The error in your question occurs when no image is published to the subscribed topic. According to the wiki of the apriltag_ros package, the subscribed topic is image_rect, which is the rectified camera image. Normally you would use the package image_proc to automatically publish the rectified image according to your camera calibration file. Rectification itself requires the camera_info topic to be published. In your case you did not record this in the bagfile, so we need to solve the problem on the apriltag side.

Here is a launchfile for apriltag I've found:

<launch>
  <arg name="launch_prefix" default="" /> <!-- set to value="gdbserver localhost:10000" for remote debugging -->
  <arg name="node_namespace" default="apriltag_ros_continuous_node" />
  <arg name="camera_name" default="/camera_rect" />
  <arg name="camera_frame" default="camera" />
  <arg name="image_topic" default="image_rect" />

  <!-- Set parameters -->
  <rosparam command="load" file="$(find apriltag_ros)/config/settings.yaml" ns="$(arg node_namespace)" />
  <rosparam command="load" file="$(find apriltag_ros)/config/tags.yaml" ns="$(arg node_namespace)" />

  <node pkg="apriltag_ros" type="apriltag_ros_continuous_node" name="$(arg node_namespace)" clear_params="true" output="screen" launch-prefix="$(arg launch_prefix)" >
    <!-- Remap topics from those used in code to those on the ROS network -->
    <remap from="image_rect" to="$(arg camera_name)/$(arg image_topic)" />
    <remap from="camera_info" to="$(arg camera_name)/camera_info" />

    <param name="camera_frame" type="str" value="$(arg camera_frame)" />
    <param name="publish_tag_detections_image" type="bool" value="true" />      <!-- default: false -->
  </node>
</launch>

In your case, you publish /usb_cam/image_raw in your bagfile, but apriltag with the above launchfile wants /camera_rect/image_rect: you can see this from line <remap from="image_rect" to="$(arg camera_name)/$(arg image_topic)" />. This line uses the remap function where you can remap a topic to a different name. So you just have to change the args camera_name to "/usb_cam" and image_topic to "image_raw"- Alternatively you could pass these arguments during launching in the command line, something like: roslaunch apriltag_ros launchfile.launch camera_name:="/usb_cam" image_topic:="image_raw"

So this did not fit into the comments section: EDIT: apriltag_ros requires the /camera_info topic to be published. You need a bagfile with that topic in it.

================

The error in your question occurs when no image is published to the subscribed topic. According to the wiki of the apriltag_ros package, the subscribed topic is image_rect, which is the rectified camera image. Normally you would use the package image_proc to automatically publish the rectified image according to your camera calibration file. Rectification itself requires the camera_info topic to be published. In your case you did not record this in the bagfile, so we need to solve the problem on the apriltag side. Since you don't have the rectified image, you can simply remap your image topic, see below:

Here is a launchfile for apriltag I've found:

<launch>
  <arg name="launch_prefix" default="" /> <!-- set to value="gdbserver localhost:10000" for remote debugging -->
  <arg name="node_namespace" default="apriltag_ros_continuous_node" />
  <arg name="camera_name" default="/camera_rect" />
  <arg name="camera_frame" default="camera" />
  <arg name="image_topic" default="image_rect" />

  <!-- Set parameters -->
  <rosparam command="load" file="$(find apriltag_ros)/config/settings.yaml" ns="$(arg node_namespace)" />
  <rosparam command="load" file="$(find apriltag_ros)/config/tags.yaml" ns="$(arg node_namespace)" />

  <node pkg="apriltag_ros" type="apriltag_ros_continuous_node" name="$(arg node_namespace)" clear_params="true" output="screen" launch-prefix="$(arg launch_prefix)" >
    <!-- Remap topics from those used in code to those on the ROS network -->
    <remap from="image_rect" to="$(arg camera_name)/$(arg image_topic)" />
    <remap from="camera_info" to="$(arg camera_name)/camera_info" />

    <param name="camera_frame" type="str" value="$(arg camera_frame)" />
    <param name="publish_tag_detections_image" type="bool" value="true" />      <!-- default: false -->
  </node>
</launch>

In your case, you publish /usb_cam/image_raw in your bagfile, but apriltag with the above launchfile wants /camera_rect/image_rect: you can see this from line <remap from="image_rect" to="$(arg camera_name)/$(arg image_topic)" />. This line uses the remap function where you can remap a topic to a different name. So you just have to change the args camera_name to "/usb_cam" and image_topic to "image_raw"- Alternatively you could pass these arguments during launching in the command line, something like: roslaunch apriltag_ros launchfile.launch camera_name:="/usb_cam" image_topic:="image_raw"