A ROS package for marker detection, tracking, and alignment using a robot's camera. The markers are placed on a circle around the robot. This package enables the robot to gather marker information, navigate to them, and visually highlight detected markers on the camera feed. Two different codes are written. In the first python code camera_fix_controller.py
the whole chassis of the car rotates and detects the markers which are placed around it. In the second code camera_rotating_controller.py
only the link which ccarries the camera rotates and the car chassis stays still.
- Identifies markers based on their unique IDs.
- Tracks marker positions and aligns the robot's camera center with detected markers.
- Draws a circle around detected markers in the camera feed and publishes the processed image.
- Provides a mechanism for the robot to rotate and gather data on multiple markers.
- Stops rotation and alignment once all markers are processed.
Ensure the following software and libraries are installed:
- Python 3.x
- ROS Noetic
numpy
scipy
opencv-python
imutils
pip install numpy scipy imutils opencv-python
- At first clone the following Aruco Ros Repository in your workspace:
git clone https://github.com/CarmineD8/aruco_ros
- clone the robot_urdf folder into your workspace
- form the aruco_ros folder in this repository substitute the .cpp file in src folder in the src folder of the aruco_ros repository you cloned before
- build your workspace:
catkin_make
- Run the camera_fix_controller node:
roslaunch robot_urdf assignment1_2.launch
- Ensure the following topics are active and functioning:
/robot/camera1/image_raw/compressed
/robot/camera1/camera_info
/marker/id_number
/marker/center_loc
- The robot will rotate to gather marker information and align its camera with the markers one by one.
- for the case that you want only the camera link to rotate and the car stays fixed. run the following launch file:
roslaunch robot_urdf assignment1_3.launch
/output/image_raw/compressed
- Message Type:
sensor_msgs/CompressedImage
- Description: Publishes the processed image with detected markers highlighted.
/cmd_vel
- Message Type:
geometry_msgs/Twist
- Description: Publishes velocity commands to navigate the robot towards markers.
/robot/camera1/image_raw/compressed
- Message Type:
sensor_msgs/CompressedImage
- Description: Subscribes to the raw camera feed for marker detection.
/robot/camera1/camera_info
- Message Type:
sensor_msgs/CameraInfo
- Description: Subscribes to the camera's resolution and focal properties.
/marker/id_number
- Message Type:
std_msgs/Int32
- Description: Subscribes to the ID of the currently detected marker.
/marker/center_loc
- Message Type:
geometry_msgs/Point
- Description: Subscribes to the center coordinates of the detected marker.
The camera_fix_controller
class is the core of this package. Below are the key methods and their functions:
Camera_callback(self, msg)
- Extracts the camera's center coordinates from the CameraInfo message.
Id_callback(self, msg)
- Updates the detected marker's ID (Id_number).
Center_callback(self, msg)
- Tracks the detected marker's center coordinates and stores them in a dictionary.
Controller_callback(self, msg)
Implements:
- Marker detection and alignment.
- Rotational strategy to gather all marker information.
- Drawing circles on the processed image for visual feedback.
main()
- Initializes the ROS node and starts the camera_fix_controller.