Course project for Software for Robotics
The project is built on Raspberry Pi 4 (w/ Bullseye OS).
ROS2 (installed on Docker) is used to control the rotating platform on which the mussel is kept, and also for invoking the camera script to capture images of the mussel.
The camera (ArduCam IMX519) python script runs outside the Docker (due to hardware compatibility and limitations).
For communication between the camera script and ROS2 on Docker, we are using a RabbitMQ messaging queue which runs on another Docker container, sharing a docker network with the ROS2 Docker container.
The ros2
directory contains the ROS2 workspace along with it's Dockerfile
.
cd ros2
sudo docker build . -t project
Make sure that a docker network is created before starting the docker container, we are using a docker network named 'csc591' for our project.
Command to check docker networks
sudo docker network ls
Ifcsc591
docker network is not present in the above list, execute the following command
Command to create the docker network
sudo docker network create csc591
Within the ros2
directory,
sudo docker run -it -v $(pwd):/root -p 5000:5000 --rm --network csc591 --device /dev/i2c-1 project
If ros2 commands are not getting recognized in the docker container's terminal, run the following command at the root directory:
source /opt/ros/iron/setup.bash
Inside the docker, following steps need to be followed:
- Go inside the workspace folder and build the project
cd workspace
colcon build
- Execute the overlay command
source install/local_setup.bash
- Execute the launch file
cd ..
ros2 launch project.launch.py
In summary, build the project workspace, generate overlays and launch the ROS2 nodes.
There are 3 ROS2 nodes which we have created - PlatformController
, WebServer
, CameraController
And 2 ROS2 actions - MovePlatform.action
and Camera.action
The overview of the ROS2 project is as follows:
sudo docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 --hostname rabbitmq --network csc591 rabbitmq:3.13-management
Ensure that the ports 5672 and 15672 are not pre-occupied, if in case RabbitMQ is installed on the system and the above command is giving an error regarding port conflicts, run the
sudo rabbitmqctl stop
command to stop the service and re-run the docker command.
In a separate terminal, run the following commands to start the camera script.
cd camera
python3 camera.py
Waiting for requests...
message on the temrinal would indicate that the script is running and listening for incoming RabbitMQ message to invoke the cameras.
In a separate terminal, run the following commands to host the dashboard application
cd dashboard/
python3 -m http.server
The URL for the dashbaord is given below,
http://localhost:8000/
The dashboard has the following features:
-
Invoke the imager to rotate and capture images of mussel
The user can select the degree of rotation (upto 360°), the direction of rotation (Left or Right), the cameras (Camera1 and/or Camera2) and the operating mode. -
View the results of the imager
Load the captured images and preview each image on the dashboard.
Regarding the operating modes, there are mainly 3 different modes we offer:
- Capture Images at specific degree
Use-case: If user wants to rotate the platform upto a specific degree and then click images at that position. - Capture Images till specific degree
Use-case: If user wants to rotate the platform upto a specific degree and click images at each degree of rotation. - Capture Images for complete circle
Use-case: If user wants to rotate the platform and capture images at each degree of rotation for a whole circle.
We provide an additional mode, Release Motor, which is a fallback mode in case the stepper motor gets stuck and needs to be released immediately. No degree, direction or camera selection is required for this mode.