Cognipilot simulation installation specific instructions for nxp-cup
To follow this tutorial you first need to follow and install everything explained in: CogniPilot developer guide on MR-B3RB
If your installation has been successful you must be able the launch the Gazebo simulation by running the following commands in your development computer:
Please ensure that these commands function correctly and that your setup resembles what is shown in this example video
Launching the Gazebo Harmonic simulation will enable you to control the robot via the Foxglove interface. As explained in this section: b3rb_simulation
Next, we will install all necessary packages for developing the algorithm for the NXP CUP 2024, applicable to both the MR-b3rb simulation and the actual robot.
To simplify repository updates, we've created a shell script. This script automates the process of updating all repositories to the latest versions hosted on the NXPHoverGames GitHub, specifically for the NXP Cup.
The changes on the repositories are:
Synapse Protobuf and Synapse Tinyframe: Define the Pixy Vector message in the Protobuf language and provide essential definitions and functions for the TinyFrame library to operate correctly. For more information, refer to the Synapse documentation.
Synapse msgs and Synapse ros: Extend ROS with the Pixy Vector message definition and support Synapse which the facilitates communication between NavQPlus (ROS2) and CANHUBK344 (Zephyr).
Dream world: Adds a simulated race track environment to the workspace.
B3RB simulator: Includes the launch file for the node that processes the race track images.
Electrode: Integrates support for the debug image and pixy vector in Foxglove, facilitating debugging and visualization.
Cerebri: Implements a subscribing mechanism to receive the Pixy Vector message and controls for the line follower algorithm.
NXP CUP Vision: Added ROS2 package for processing race track images, transforming perspectives, detecting track edges, and publishing both the debug image and the Pixy Vector, pivotal for visual processing.
This file ensures that all the repositories are updated. Save this script in ~/cognipilot:
Save this script as update_repos_native.sh in the ~/cognipilot
directory, using any text editor of your choice, such as Vim, Gedit, Nano, or VSCode.
Then, open the terminal and execute the following commands:
This must have updated all your repositories. Please review the output of this script. It's possible that you have made local changes to the repositories, and you may need to stash them.
To build the software, navigate to the cranium/src
directory within ~/cognipilot
:
Repeat the build process for the electrode
directory:
Update the West workspace for cerebri
.
Now, you are ready to run the simulation:
To launch the Gazebo simulation featuring the MR-B3RB robot on a simple raceway, execute:
To start the Foxglove viewer for the simulation, run:
These commands will initiate the Gazebo simulation with the MR-B3RB robot and the raceway, alongside launching the Foxglove viewer.
To initiate the robot's movement, press the AUTO button and the arm button on the joystick. This action will activate the robot's line-following mode and set it to the armed state, preparing it for operation.
Once the AUTO and arm buttons on the joystick are pressed, the robot will immediately begin to navigate around the racetrack. To understand the underlying code and setup, and to explore ways to obtain a better performance for the NXP CUP 2024, proceed to the next tutorial.