AprilTag Example Code Overview
Last updated
Last updated
/apriltag/detections
topicThe AprilTag detection node exposes a new topic called /apriltag/detections
. This topic contains data detailing the ID of the AprilTag, the location within the image, and more. In NXP Gazebo, you will really only need the ID data.
If you want to see the full detail of the AprilTagDetection message, see below:
The /apriltag/detections
topic publishes a message called AprilTagDetectionArray - this message is an array of the message linked above. If more than one AprilTag is detected, you can use the array index to find each detection. In NXP Gazebo milestone 3, you will always use detection 0, as there is no case in which more than one detection will be found at any given time.
To subscribe to the /apriltag/detections
topic, we need to create a new subscriber. In the updated example code, you will find the following lines:
This section of code is similar to the simulated Pixy camera subscription, just adapted to the AprilTagDetectionArray message in the /apriltag/detections
topic. You can see within this section of code we passed a new callback function called LineFollower::apriltag_callback
. This function will be run each time an AprilTagDetectionArray is published.
The new LineFollower::apriltag_callback
function will allow you to use the data from the /apriltag/detections
topic at your disposal. An example function which prints out the ID of the detected AprilTag is included in the new example code.
Note that the function looks for the first AprilTag detected. Within NXP Gazebo, only one AprilTag will be shown at any given time, so you won't need to worry about using a detection other than detection 0.
If you have questions, please don't hesitate to ask Landon in the NXP Gazebo Summer Camp Teams channel!