Skip to content

ucmercedrobotics/amiga-ros2-bridge

Repository files navigation

FarmNG Amiga ROS2 Bridge

github website python pre-commits Code style: black

Overview

The Amiga-ROS2 bridge, currently supported for ROS2 Humble, interfaces with the Amiga gRPC services to:

  • Stream data from the Amiga brain services
  • Control the Amiga using the available vehicle control APIs.

Using this bridge with the amiga requires an Amiga OS v2.3.x.

Note

To setup the environment, you'll be working in Docker on your local machine. It will communicate to the Amiga via Tailscale using gRPC, just like any of our ADK Brain examples.

Even though this repo is a collaboration between farm-ng and Robotics@UC Merced, this is NOT an official release from farm-ng and, therefore, we can't guarantee support or long term compatibility. That said, we will do everything possible to help you use it. For suggestions, questions, or concerns, raise an issue here.

Collaboration and PRs are welcome and will be evaluated by UC Merced and Farm-ng teams on regular basis.

How to set up the node (needed only one time):

Installation

  1. Clone this repo and open the directory:
git clone https://github.com/ucmercedrobotics/amiga-ros2-bridge.git
cd amiga-ros2-bridge

[Optional, but highly recommended] Create a new virtual environment

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
  1. Clone submodules and other repos
git submodule update
cd amiga-ros2-nav
vcs import < nav.repos
cd ..

Note, this bridge works even if you're not using Nav2! We've added support for Nav2 assuming you are using a UBlox module. We use a UBlox RTK Zed-F9P module to get RTK corrections from a base station instead of using NTRIP over IP as is provided from FarmNG on the Amiga.

  1. After, build your ROS2 container. Note you can run either on your own machine becausce of gRPC or directly on the Amiga:

To build on your own machine,

make build-dev

To build on the Amiga,

make build-prod
  1. [Optional, for application requiring GUIs] Next, standup the noVNC container to forward X11 to your web browser.

To run the container,

make vnc

Be sure to run this on the same machine you're running your ROS2 bridge on.

You can view the noVNC page at http://localhost:8080/vnc.html if ran locally, or http://{IP}:8080/vnc.html if the image is remote.

Execution (every time you start the node):

  1. Configure and spin up your Docker container:

This step assumes you have installed Tailscale and properly configured your access to the Brain with farm-ng's support team.

Check which services/streams you want to see and/or control at amiga-ros2-bridge/include/service_config.json. Make sure you update your Brains addresses on each host:

{
    "configs": [
        {
            "name": "canbus",
            "port": 6001,
            "host": "000.000.000.000"
        },
        ...
  1. Finally, standup the container and connect to it:
make bash

You should now be inside the container, and the terminal will show something like:

root@docker-desktop:/amiga_ros2_bridge#

Once inside, build ROS2 packages,

colcon build
source install/setup.bash

Note

Feel free to modify Makefile to change your container's startup command based on what you need adding port forwarding, displays, different volumes, etc.

  1. Expose your Amiga gRPC servers as ROS2 topics:
make amiga-streams

You should see confirmation of the topics exposed:

...
[amiga_streams-1] [INFO] [1743180979.278455758] [amiga_streams]: Subscribing to farm-ng topic: /oak0/left and publishing on ROS topic: /oak0/left
...

Examples

You should now be able to interact with the services from your ROS2 container. An example is to allow twist commands to drive the Amiga:

  1. Open a new terminal, connect to the container with a shell:
make shell

Note, please use make shell after you've used make bash to create the container instance. This command will attach you to the current environment instead of creating a completely new one. See Makefile for more details.

  1. Now run the twist converter:
make twist

This will listen on topic /cmd_vel from standard ROS2 velocity commands and convert them to Amiga specific CANbus velocity commands.

Prior to running anything using ROS2, make sure you activate auto control as seen in the image below.

dashboard in auto page

⚠️ Make sure it is safe to move the robot without physically controlling it! ⚠️

  1. Control remotely:
make joy

This defaults to a controller mapped to /dev/input/js0. This default file descriptor is usually a PS4 controller. You can connect your own contoller via bluetoothctl.

Current Support

Luxonis Oak-D

Using the onboard Oak-D cameras or your own, you can configure them to stream using ROS2 drivers. The below command will execute the DepthAI provided ROS2 drivers (including 9-axis IMU support).

make oakd

To edit the config to match your cameras, edit amiga_ros2_oakd/config/amiga_cameras.yaml prior to running the ROS2 drivers.

BT.CPP

This repo supports mission command and control via BT.CPP XML. We have an example behavior tree in amiga_ros2_behavior_tree, which can be adapted to fit your own robot configuration.

See amiga_ros_behavior_tree for examples.

Foxglove

  1. Inside the docker container, run the foxglove node (Farm-ng uses port 8765 for their foxglove bridge, so we use 8766 by default),
make foxglove
  1. Follow instructions here to open foxglove

Nav2

While we use our own UBlox RTK module in order to support Nav2 related ROS2 nodes, this can be adapted to model any configuration. See our Nav2 repo for more details.

LLM Planning

From any computer (except the Amiga since it's behind Tailscale) on the same network as the Amiga, run the proxy that will connect our webapp to the Amiga. git clone https://github.com/vtomnet/mp-proxy, make a venv, install requirements.txt, python proxy.py --to-tcp <amiga_ip>:<bt_runner_port>. From https://mp.vtom.net/ plan out your mission.

Note, you can configure what port the Amiga talks from through bt_runner parameter mission_port, which is defaulted to 12346.

Stopping Services

Many services, such as the Oak-D cameras, require the exclusive use of the hardware. You may also see it fit to use this To disable default Amiga drivers, use the following command:

bash ./scripts/stop_amiga_services.sh

Nav2 Autonomous Pipeline

We provide two ways of bringing up the autonomy stack:

  1. shell script that spawns all nodes inside tmux for debugging:
bash ./scripts/bringup_amiga_tmux.sh
  1. Master launch file for deployment:

Start the container,

make bash

Once inside, bring up the nodes,

make bringup

This will spawn the Amiga-ROS2 bridge, Oakd cameras, URDF descriptions, localization stack, and nav2 stack.