Skip to content

Commit

Permalink
update readme and move rename examples (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarriba authored Mar 17, 2023
1 parent 0fe6205 commit 3537705
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 60 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
- uses: ros-tooling/setup-ros@v0.6
with:
required-ros-distributions: noetic
#- run: "source /opt/ros/noetic/setup.bash && rosnode --help"
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: sudo apt install -y protobuf-compiler
Expand Down
112 changes: 61 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# How to test the amiga-ROS bridge in simulation
# ROS bridge for the Amiga

***This is currently without Amiga HW in the loop***
[![Build Status](https://travis-ci.com/farm-ng/amiga-ros-bridge.svg?branch=master)](https://travis-ci.com/farm-ng/amiga-ros-bridge)
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/farm-ng/amiga-ros-bridge)](https://github.com/farm-ng/amiga-ros-bridge/releases/latest)
[![License](https://img.shields.io/badge/License-ADK-blue.svg)](https://github.com/farm-ng/farm-ng-amiga/blob/main/LICENSE)
[![ROS](https://img.shields.io/badge/ROS-Noetic-blue)](https://www.ros.org)
[![Rust](https://img.shields.io/badge/rust-1.66.0+-93450a.svg?logo=rust)](https://www.rust-lang.org)

This repository contains a ROS bridge for the Farm-ng Amiga platform written in [Rust](https://www.rust-lang.org/).

> **Disclaimer:** the Amiga stack does not leverage ROS for control, but rather uses a gRPC service for control. This bridge is provided as a convenience for users who wish to use ROS for control. For performance critical applications, we recommend using the gRPC service directly.
## Overview

Expand Down Expand Up @@ -29,7 +36,6 @@ Clone the repository and initialize the submodule.

** [optional] `roscd` to your ROS workspace and clone this repository there.


```bash
git clone https://github.com/farm-ng/amiga-ros-bridge.git
git submodule update --init
Expand All @@ -40,7 +46,7 @@ git submodule update --init
- [ROS Noetic install instructions](http://wiki.ros.org/noetic/Installation/Ubuntu)
- [Rust install instructions](https://www.rust-lang.org/learn/get-started).

## Run the bridge (with ROS commands)
## Run the bridge

### Terminal 1

Expand Down Expand Up @@ -81,50 +87,9 @@ and that you know the IP address of the Amiga.
rosrun amiga_ros_bridge amiga_ros_bridge -H 192.168.1.98 -p 50060
```

## Steps to follow (without ROS commands)

### Terminal 1

Start ROS core:

```bash
source /opt/ros/noetic/setup.bash
roscore
```

### Terminal 2

***In a new terminal***, start the Amiga mock server:

```bash
source /opt/ros/noetic/setup.bash
cargo run --example amiga-mock-server
```

This is a stand-in for the actual Amiga gRPC canbus service that echos back the received commands.

### Terminal 3

***In a new terminal***, start the ROS bridge:

> Warning: This will crash immediately if there is no Amiga gRPC (or mock) service to connect to.
```bash
source /opt/ros/noetic/setup.bash
cargo run
```

This will register the bridge to the Vehicle `Twist` stream, forward these as gRPC messages, and republish them as ROS `TwistStamped` messages.

### Terminal 4 (+ 5)

This is where you would launch your ROS nodes for controlling the Amiga and listening to the measured state of the Amiga.
You can also try the following stand-in tools:

- [Experimental Amiga Joystick](#experimental-amiga-joystick)
- [Stable ROS packages](#stable-ros-packages)
## Control the Amiga

#### Experimental Amiga Joystick
### Experimental Amiga Joystick

You can start the **experimental** amiga-joystick app to command velocities
to the Amiga (e.g. the mock server) and print received velocity states:
Expand All @@ -138,7 +103,7 @@ cargo run --example amiga-joystick

Use arrow keys (left, right, up, down) to command velocities to the Amiga.

#### Stable ROS packages
### Stable ROS packages

You can publish `Twist` commands to the ROS bridge on the `/amiga/cmd_vel` topic with the [`rqt_robot_steering`](http://wiki.ros.org/rqt_robot_steering) package.

Expand Down Expand Up @@ -170,13 +135,58 @@ We have provided some examples to help you get started. You will find the exampl

### Python

- [`twist_publisher.py`](examples/twist_publisher.py): Publishes a `Twist` message on the `/amiga/cmd_vel` topic.
- [`twist_subscriber.py`](examples/twist_subscriber.py): Subscribes to the `/amiga/vel` topic and prints the received `TwistStamped` messages.
- [`amiga_cmd_vel_publisher.py`](examples/amiga_cmd_vel_publisher.py): Publishes a `TwistStamped` message on the `/amiga/cmd_vel` topic.
- [`amiga_vel_subscriber.py`](examples/amiga_vel_subscriber.py): Subscribes to the `/amiga/vel` topic and prints the received `TwistStamped` messages.

### Rust

- [`amiga_cmd_vel_publisher.rs`](examples/amiga_cmd_vel_publisher.rs): Publishes a `TwistStamped` message on the `/amiga/cmd_vel` topic.
- [`amiga_vel_subscriber.rs`](examples/amiga_vel_subscriber.rs): Subscribes to the `/amiga/vel` topic and prints the received `TwistStamped` messages.
- [`amiga-joystick.rs`](examples/amiga-joystick.rs): A simple joystick to command velocities to the Amiga and print received velocity states.

## Run the mocked bridge

### Terminal 1

Start ROS core:

```bash
source /opt/ros/noetic/setup.bash
roscore
```

### Terminal 2

***In a new terminal***, start the Amiga mock server:

```bash
source /opt/ros/noetic/setup.bash
cargo run --example amiga-mock-server
```

This is a stand-in for the actual Amiga gRPC canbus service that echos back the received commands.

### Terminal 3

***In a new terminal***, start the ROS bridge:

> Warning: This will crash immediately if there is no Amiga gRPC (or mock) service to connect to.
```bash
source /opt/ros/noetic/setup.bash
cargo run
```

This will register the bridge to the Vehicle `Twist` stream, forward these as gRPC messages, and republish them as ROS `TwistStamped` messages.

### Terminal 4 (+ 5)

This is where you would launch your ROS nodes for controlling the Amiga and listening to the measured state of the Amiga.
You can also try the following stand-in tools:

- [Experimental Amiga Joystick](#experimental-amiga-joystick)
- [Stable ROS packages](#stable-ros-packages)

## Do you want to know more?

Inspect ci_test.sh.
Inspect [`ci_test.sh`](ci_test.sh) for a full example of how to run the bridge in a CI environment.
4 changes: 2 additions & 2 deletions ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cargo build
roslaunch launch/test_launch.launch &
sleep 2
cargo run --example amiga-mock-server &
cargo run --example test-amiga-cmd_vel &
cargo run --example amiga_cmd_vel_publisher &
cargo run -- --test-mode &
cargo run --example test-amiga-vel
cargo run --example amiga_vel_subscriber
echo DONE
4 changes: 2 additions & 2 deletions examples/amiga-mock-server.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use futures::Stream;
use ros_bridge::grpc::farm_ng::canbus::proto::canbus_service_server::{
use amiga_ros_bridge::grpc::farm_ng::canbus::proto::canbus_service_server::{
CanbusService, CanbusServiceServer,
};
use ros_bridge::grpc::farm_ng::canbus::proto::{
use amiga_ros_bridge::grpc::farm_ng::canbus::proto::{
SendCanbusMessageReply, SendCanbusMessageRequest, SendVehicleTwistCommandReply,
SendVehicleTwistCommandRequest, StreamCanbusReply, StreamCanbusRequest, StreamMotorStatesReply,
StreamMotorStatesRequest, StreamVehicleTwistStateReply, StreamVehicleTwistStateRequest,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
fn main() {
// Initialize node
rosrust::init("amiga_cmd_vel_test");
rosrust::init("amiga_cmd_vel_publisher");

// Create publisher
let cmd_vel_pub = rosrust::publish("/amiga/cmd_vel", 2).unwrap();
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ fn main() {
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");

// Initialize node
rosrust::init("amiga/vel listener");
rosrust::init("amiga_vel_subcriber");
let arc_count = std::sync::Arc::new(std::sync::Mutex::<u32>::new(0));
let arc_count_clone = arc_count.clone();
let _subscriber_raii = rosrust::subscribe(
Expand All @@ -20,7 +20,7 @@ fn main() {
},
)
.unwrap();
info!("/amiga/vel subscriber launched");
info!("amiga_vel_subscriber launched");
let rate = rosrust::rate(0.0);

// Block the thread until a count=10
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async fn main() {
debug!("Connecting to gRPC server at {}", address);

// the gRPC client takes the receiver rx.
let handle = runtime.spawn(async move {
let _ = runtime.spawn(async move {
AmgigRosBridgeGrpcClient::connect(address)
.await
.unwrap()
Expand Down

0 comments on commit 3537705

Please sign in to comment.