IllinoisRoboticsInSpace / IRIS

Illinois Robotics in Space 2022-2023 Season
https://iris.ae.illinois.edu/
8 stars 0 forks source link

Environment Setup Script for ROS Colcon Workspace and PlatformIO #8

Closed ttchalakov closed 1 year ago

ttchalakov commented 1 year ago

Automatic Environment Setup

Added repo setup scripts for both the Jetson Nano and Ubuntu 20 x64 Desktop. The installation process is broken into three scripts, install_pc_deps.sh handles dependencies for x64, install_jetson_deps.sh handles dependencies for the Jetson Nano, and install_env_deps.sh handles dependencies that have the same installation process for both aarch64 and x64. To setup the development environment run ONLY ONCE the desired platform's setup script from within the install_scripts/ folder as ./install-<jetson/pc>-deps.sh.

PC Deps

Jetson Nano Deps

Environment Deps

Notes

Transition to PlatformIO from Arduino 2 IDE

PlatformIO is much more versatile tool for embedded development. The main benefits are vscode integration, library manager, unit test support, debugging support using external probes, and many other utilities. The MotorDriver folder contains code for the Arduino Due and is not compiled by running the colcon build command. Instead install the PlatformIO vscode extension to initialize the project. The project however also contains a setup script that needs to be run to install extra dependencies call setup_pc.sh from within the MotorDriver/ directory. The MotorDriver code can not be compiled on the Jetson Nano.

Project Structure

├── lib
│   ├── EmbeddedProto
│   ├── IRISMotorDriver
│   ├── protobuf-21.5
│   └── Sabertooth
├── src
└── test
    ├── test_common
    ├── test_desktop
    └── test_embedded

In the above project folder structure, all dependencies that can not be managed through PlatformIO are installed in lib except for IRISMotorDriver which is the library that implements the motor driver. The src/ folder contains a typical Arduino like program entry point in main.c. This is the code that will be uploaded to the Arduino Due. The test/ folder contains a testing structure implemented using the Unity testing framework. In here there are two environments, native and due. The native environment is meant for local development (x64) without uploading to the due and the due environment is meant to upload to the physical Arduino Due. test_desktop is meant for code to be tested on the desktop environment when developing a general library. test_embedded is meant for tests that need to be run on the physical hardware. This allows for tests that interact with physical logic such as setting the voltage of a specific digital pin to high or low. test_common is meant for tests that can be run on both the desktop or embedded device. This is typically useful for checking compatibility when implementing a feature.

Extra dependencies

The setup_pc.sh script uninstalls the system's protobuf-compiler and builds from scratch the correct version of protoc that the EmbeddedProto library uses. The EmbeddedProto library is then initialized and the linux udev rules for the PlatformIO extension are added.

Embedded Protobuf Development

The project has a python script, gen_proto.py, that will run before uploading or building code which will regenerate all protobuf files and place them into a generated/ folder. Profobuf is meant to be used for the communication of the MotorDriver and the Jetson. A python implementation to interact with the MotorDriver will need to be implemented.

Notes

Problems