Initial Configuration
Before we can start using CyberRunner, we need to first calibrate the camera and configure the motors. These steps have to be taken only once.
Camera Calibration
In order for the position of the ball within the labyrinth to be tracked, we need to first calibrate the camera. For this purpose, we use the COCamCalib MATLAB toolbox.
-
Follow the steps here to obtain the calibration results for your camera.
Disclaimer
The Find Center step is computationally intensive and may get stuck. In this case, update
PPin both instances of the functionlsqlin()tosparse(PP). This should speed up the process. For more details, the bug fix is idenitified in this thread.Make sure to take the calibration pictures at a 1920x1200 resolution.
-
Save the calibration results by clicking on Export Data in the OCamCalib GUI. This will create the file
calib_results.txtin your MATLAB workspace. -
Copy the
calib_results.txtfile ascalib_results_cyberrunner.txtto your ROS workspace withcp <path_to_matlab_workspace>/calib_results.txt <path_to_cyberrunner_ws>/src/cyberrunner/cyberrunner_state_estimation/calib/calib_results_cyberrunner.txtReplace
<path_to_matlab_workspace>and<path_to_cyberrunner_ws>with the path to your MATLAB workspace and your CyberRunner ROS workspace, respectively. -
Install the calibration file by navigating to your workspace and running
colcon build --symlink-install source install/setup.bash
Marker positions
The state estimator relies on approximately knowing the location of the blue markers within the image. To obtain these positions follow these steps.
-
Open two terminal windows, navigate to the CyberRunner workspace and source the workspace.
-
In the first terminal, run the camera script
ros2 run cyberrunner_camera cam_publisher.py -
In the second terminal, run the select markers script and follow the instructions in the terminal
ros2 run cyberrunner_state_estimation select_markers
Motor Configuration
- Install Dynamixel Wizard 2.0.
- Temporarily disconnect the front motor (the motor on the longer side of the labyrinth). Connect the U2D2 to your host PC and ensure that the motors are turned on by pressing the power switch on the U2D2 Power Hub Board.
- In the Dynamixel Wizard, press Scan until the motor is found.
- Assign ID 2 to the connected motor, set the baud rate to 1M, and set the operating mode to 0 (Current Control Mode). Make sure to click Save after each change.
- Reconnect the front motor.
- Press Scan again.
- For the newly connected motor, assign ID 1, and apply the same changes as for the other motor.