NXP-CUP 2024: MR-B3RB robot Install instructions

Cognipilot MR-B3RB Robot 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

You must also follow the NXP-CUP 2024: Simulation Install instructions as it is explained how to update you development computer for the NXP-CUP 2024.

If you have correctly followed the previous steps, you should already be familiar with how to flash the Cognipilot software onto the MR-CANHUBK344 board. In this step, we will flash the board again, but this time with an updated version of the Cerebri software that includes support for the NXP Cup 2024. Additionally, we will need to log in via SSH to the NavQPlus and update the cranium workspace to enable support for the NXP Cup, similar to the procedure outlined on the previous page.

Build and flash the NXP-CUP Cerebri image for B3RB

In your development computer go to:

cd ~/cognipilot/ws/cerebri
git pull

Check that you are on the nxp-cup branch

cd ~/cognipilot/ws/cerebri
git status

Which should return:

On branch nxp-cup
Your branch is up to date with 'origin/nxp-cup'.

nothing to commit, working tree clean

If it doesn't show that:

git checkout nxp-cup

Remember if you PDB does not have the battery sensor you have to follow this guide: Configuring Cerebri Software for MR-CANHUBK344 Without Power Measurement Capability

If you have ensured that you are on the nxp-cup branch and that there is not any update available. Then type the following command:

cd ~/cognipilot/ws/cerebri 
west update

Build NXP-CUP Cerebri B3RB image for MR CANHUBK3 with west

cd ~/cognipilot/ws/cerebri 
west build -b mr_canhubk3 app/b3rb -p

Flash Cerebri B3RB image with west to MR CANHUBK3

Make sure Segger JLink is on your system and the MR CANHUBK3 is connected to the JLink programmer: Connect J-Link EDU Mini to MR-CANHUBK344 with DCD-LZ adapt board.

cd ~/cognipilot/ws/cerebri 
west flash

Once it has finished, you can disconnect the J-Link from your computer and from the MR-CANHUBK344.

In case the west flash command failed, put the followung commands on the terminal:

JLinkExe
connect
S32K344
S
4000
loadbin /home/$user/cognipilot/ws/cerebri/build/zephyr/zephyr.elf 0x400000
exit

Updating repositories on NavQPlus

If you have any doubt or problem in this section please first refer to this documentation: https://airy.cognipilot.org/cranium/compute/navqplus/setup/

Once you have flashed the MR-CANHUBK344, It's time to log into the NavQPlus. Do this with this command:

ssh <username>@<hostname>.local

Next, we will install the packages to develop the algorithm for the NXP CUP 2024 in the B3RB 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).

  • B3RB robot: Includes the launch file for the node that processes the race track images.

  • 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:

#!/bin/bash

declare -A repos=(
    ["cranium/src/synapse_protobuf"]="https://github.com/NXPHoverGames/synapse_protobuf"
    ["cranium/src/synapse_tinyframe"]="https://github.com/NXPHoverGames/synapse_tinyframe"
    ["cranium/src/synapse_msgs"]="https://github.com/NXPHoverGames/synapse_msgs"
    ["cranium/src/synapse_ros"]="https://github.com/NXPHoverGames/synapse_ros"
    ["cranium/src/b3rb_robot"]="https://github.com/NXPHoverGames/b3rb_robot"
    ["cranium/src/nxp_cup_vision"]="https://github.com/NXPHoverGames/nxp_cup_vision"
)

# Update existing repositories or clone if they don't exist
for repo in "${!repos[@]}"; do
    echo "Processing $repo..."
    repo_path="${repo}" # Derive the full path
    
    # Check if the repository directory exists. If it does not, clone it.
    if [ ! -d "${repo_path}" ]; then
        echo "Repository ${repo_path} does not exist. Cloning..."
        git clone --branch nxp-cup "${repos[$repo]}" "${repo_path}"
        echo "Cloned ${repo} into ${repo_path}."
    fi
    
    # Navigate to the repository directory
    cd "${repo_path}" || { echo "Failed to change directory to ${repo_path}. Does it exist?"; continue; }
    
    # Set the new remote URL
    git remote set-url origin "${repos[$repo]}"
    echo "Remote changed to ${repos[$repo]}"

    # Fetch changes from the new remote
    git fetch origin
    echo "Fetched changes from origin."

    # Checkout the specific branch
    git checkout nxp-cup
    if [ $? -eq 0 ]; then
        echo "Checked out nxp-cup branch."
        # Pull the latest changes from the branch
        git pull origin nxp-cup
        echo "Pulled latest changes from nxp-cup branch."
    else
        echo "Failed to checkout nxp-cup branch. Does it exist?"
    fi
    
    # Return to the original directory
    cd - > /dev/null
done

Save this script as update_repos_navqplus.sh in the ~/cognipilot directory, using any text editor of your choice, such as Vim or nano.

Then, open the terminal and execute the following commands:

Change directory to ~/cognipilot and make the script executable:

cd ~/cognipilot
chmod +x update_repos_navqplus.sh
./update_repos_navqplus.sh

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:

cd ~/cognipilot/cranium/
colcon build --symlink-install
cd ~/cognipilot/cranium/
source install/setup.bash

Now, you are ready to operate the platform.

On the NavQPlus, run the B3RB launch file:

ros2 launch b3rb_bringup robot.launch.py

Start Foxglove for operation and data visualization run the following command in your development computersimulation, run:

ros2 launch electrode electrode.launch.py

These commands will initiate the algorithm on the MR-B3RB robot and Foxglove viewer. You should locate your robot in the racetrack.

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 should 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.

Last updated