Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update services descriptions/API #308

Merged
merged 9 commits into from
May 9, 2024
26 changes: 21 additions & 5 deletions website/docs/concepts/canbus_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,34 @@ or microcontrollers and devices.
- **Dependencies**: Standalone service, but pivotal for many autonomous operations.
Notably, the Track Follower service is heavily reliant on the Canbus service.

# Data Streams
## Data Streams

- `/twist`: The commanded linear velocity of the vehicle in the x direction in meters per second.
Check the protobuf definition for more details:
[canbus_pb2.Twist2d](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/canbus.proto#L58-L61)
- `/motor_states`: Streams state messages from the motors of your Amiga, such as voltage and RPM.
Check the protobuf definition for more details:
[canbus_pb2.MotorStates](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/canbus.proto)

- `/pendant`: Streams state messages from the pedant of your Amiga, such as buttons pressed.
Check the protobuf definition for more details:
[amiga_v6_pb2.PendantState](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/amiga_v6.proto)

- `/raw_messages`:A representation of raw CAN bus messages with timestamps, node IDs, error
flags, remote transmission indicators, and encoded payloads.
Check the protobuf definition for more details:
[canbus_pb2.RawCanbusMessages](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/canbus.proto#L95-L107)
[canbus_pb2.RawCanbusMessages](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/canbus.proto)

- `/state`: State of the Amiga CAN bus.
Encapsulates key information required to evaluate the state of the Amiga robot.
Check the protobuf definition for more details:
[amiga_v6_pb2.AmigaV6CanbusState](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/amiga_v6.proto)

- `/tool_statuses`: State of the tools (if any) connected to your Amiga.
Check the protobuf definition for more details:
[tool_control_pb2.ToolStatuses](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/tool_control.proto)

- `/twist`: The commanded linear velocity of the vehicle in the x direction in meters per second.
Check the protobuf definition for more details:
[canbus_pb2.Twist2d](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/canbus/canbus.proto)

## API

1. `/twist`: Receives twist commands (linear and angular velocities) and instructs the
Expand All @@ -40,6 +52,10 @@ motors accordingly.
3. `/get_battery_state`: Returns the battery state.
A float value indicating the battery's state of charge, ranging [0.0, 1.0].
If no motors are connected, it returns -1.0.
4. `/control_tools`: Control the tools / actuators based on the ActuatorCommands message.
5. `/stop_all_tools`: Stop all tools and prevent control for a predetermined duration.
6. `/yield_all_tools`: Prevent control for a predetermined duration.
7. `/config_request`: Use the farm-ng SDO protocol to send a config request to the dashboard.

## Safety and Operation

Expand Down
8 changes: 6 additions & 2 deletions website/docs/concepts/filter_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ For the Filter service to function correctly, these services must be operational
relevant sensor data.
Since the Filter relies on GPS data, the Amiga must have a GPS connected to an RTK base station.

# Data Streams
## Data Streams

- `/state`: A filter's state detailing pose, convergence, calibration, uncertainty, innovation, and heading.
Check the protobuf definition for more details:
Expand All @@ -49,6 +49,10 @@ heading (in radians), convergence status, and pose uncertainty.
- `/get_track`: Returns the current track of the robot, essentially the path that the robot has traveled.
- `/clear_track`: Clears the current track, useful when initiating a new tracking sequence or
recalibrating the system.
- `/pause_track`: Pause adding waypoints to a track.
- `/resume_track`: Resume adding waypoints to a track.
- `/pop_track_end`: Removes the last waypoint added to the track.
Track must be paused first (`/pause_track`).

## Convergence Requirements

Expand All @@ -58,7 +62,7 @@ need to be met, including:
- The robot is connected to Wi-Fi, ensuring communication continuity.
- The GPS service is receiving messages, with `accuracyNorth` and `accuracyEast` values smaller
than 0.01, indicating high precision.
- The oak0 service is active and transmitting IMU data.
- The oak/0 sub-service is active and transmitting IMU data.

Upon startup or recalibration, the robot needs to be moved slightly to allow the filter to converge
(indicated by `has_converged` = true).
Expand Down
16 changes: 13 additions & 3 deletions website/docs/concepts/gps_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: GPS

# GPS Service Overview

The GPS service is an integral component of the Amiga's navigation system, utilizing a
The GPS sub-service is an integral component of the Amiga's navigation system, utilizing a
high-precision Ublox module to determine the robot's exact position on Earth.
This service is indispensable for tasks that require geo-location, from simple
navigation to complex tasks like field mapping or precision agriculture.
Expand All @@ -31,7 +31,7 @@ These messages contain rich data sets that include the robot's current geospatia
velocity, time, and other relevant GPS data.

:::info INFO
There are two types of GPS messages: **PVT** and **RELPOSNED**.
There are three types of GPS messages: **PVT**, **RELPOSNED**, and **ECEF**.

**PVT** (Position, Velocity, and Time) messages provide the all-in-one solution: position, velocity,
and time.
Expand All @@ -41,9 +41,15 @@ It contains details like longitude, latitude, altitude, speed, and UTC time.
North, East, Down (N-E-D) frame. It's mainly used for applications requiring relative positioning
between two receivers, often as a part of Real Time Kinematics (RTK) solutions.
It shows the difference in position between a "moving" receiver and a "fixed" reference receiver.

**ECEF** (Earth-Centered, Earth-Fixed) messages provide coordinates that represent positions
relative to the earth's center, but fixed to the earth as it rotates.
ECEF coordinates are expressed in meters in a 3D Cartesian coordinate system.
These messages are particularly useful for applications
that require a global reference frame, such as satellite operations and global mapping projects.
:::

# Data Streams
## Data Streams

- `/pvt`: PVT message.
Check the protobuf definition for more details:
Expand All @@ -53,6 +59,10 @@ It shows the difference in position between a "moving" receiver and a "fixed" re
Check the protobuf definition for more details:
[gps_pb2.RelativePositionFrame](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/gps/gps.proto#L73-L97)

- `/ecef`:ECEF message.
Check the protobuf definition for more details:
[gps_pb2.EcefCoordinates](https://github.com/farm-ng/farm-ng-amiga/blob/main/protos/farm_ng/gps/gps.proto#L109-L117)
guilhermedemouraa marked this conversation as resolved.
Show resolved Hide resolved

## Requirements

For the GPS service to function optimally, certain conditions must be met:
Expand Down
4 changes: 2 additions & 2 deletions website/docs/concepts/oak_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ However, its data, especially the IMU information, plays a significant role in t
navigation capabilities, as it's fused with GPS and wheel odometry data in the Filter service
(using an Unscented Kalman Filter).

# Multiple Instances
## Multiple Instances

Depending on the number of OAK devices connected to the Amiga, there might be multiple instances
of the OAK service running concurrently.
Expand All @@ -38,7 +38,7 @@ These messages can include various data types such as:
- Accelerometer data
- Gyroscope data

# Data Streams
## Data Streams

- `/calibration`: Intrinsic parameters of the cameras.
Check the protobuf definition for more details:
Expand Down
159 changes: 76 additions & 83 deletions website/docs/concepts/recorder_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ analysis, debugging, and model training.

## Purpose

The primary objective of the Recorder Service is to provide a robust mechanism for recording
The primary objective of the Recorder sub-service is to provide a robust mechanism for recording
data streams from different services. This is invaluable for tasks such as training computer
vision/AI models, where capturing field imagery is essential.
For instance, when developing a precision sprayer application for weeds, one would
Expand All @@ -22,10 +22,12 @@ first traverse the field, recording data to train a model to detect weeds.
The Recorder Service is a subscriber to the following services:

- Canbus
- Filter
- GPS
- Oak (Multiple Oak topics may be available, depending on the number of Oak cameras connected,
e.g., oak0, oak1, ...)
- GPS Service
- Filter Service
e.g., oak/0, oak/1, ...)
- System Monitor
- Track Follower

## Available Topics for Recording

Expand All @@ -41,44 +43,27 @@ Some of which may inherit from the protobuf messages found at:<br/>
[**`farm-ng-core/protos/`**](https://github.com/farm-ng/farm-ng-core/tree/main/protos/farm_ng/core)
:::

### Canbus Topics

- `canbus/health`: Provides health metrics for the Canbus service, such as publishing frequency.
- `canbus/raw_messages`: Streams all messages received from the CAN bus by the canbus service.
You can parse and unpack these messages to see details of the motors (e.g., rpm, temperature),
of your Amiga (e.g., battery voltage, velocity, whether auto-mode is engaged),
and other pertinent information.
- `canbus/twist`: Outputs the linear and angular velocities of the robot, offering insights
into its movement dynamics.

### Oak Topics

- `oak/health`: Delivers health metrics for the Oak service, including publishing frequency.
- `oak/calibration`: Streams the current calibration settings of the Oak device,
ensuring the camera's accuracy.
- `oak/disparity`: Outputs the disparity image calculated from the left/right stereo images,
used for depth perception and 3D mapping.
- `oak/imu`: Streams 3-D accelerometer & gyroscope values from the Oak camera's internal IMU,
giving insights into the robot's orientation and movement.
- `oak/left`: Outputs the feed from the stereo left camera of the Oak device.
- `oak/right`: Outputs the feed from the stereo right camera of the Oak device.
- `oak/rgb`: Streams the stereo RGB image from the Oak device, providing full-color
visuals of the robot's environment.

### GPS Topics

- `gps/health`: Offers health metrics for the GPS service, such as publishing frequency.
- `gps/pvt`: Streams GPS Position, Velocity, and Time (PVT) messages, giving a comprehensive
view of the robot's location and movement.
- `gps/relposned`: Provides GPS relative position in North, East, Down (N-E-D) coordinates,
offering a detailed spatial orientation of the robot.

### Filter Topics

- `filter/health`: Delivers health metrics for the Filter service, including publishing frequency.
- `filter/state`: Streams the filter state, which combines the robot's pose, orientation,
filter state uncertainties, and filter convergence status.
This topic is essential for understanding the robot's current state and its accuracy.
- [Canbus Topics](/docs/concepts/canbus_service/#data-streams)

- [Filter Topics](/docs/concepts/filter_service/#data-streams)

- [GPS Topics](/docs/concepts/gps_service/#data-streams)

- [Oak Topics](/docs/concepts/oak_service/#data-streams)

- System Monitor Topics

- `system_monitor/health`: Delivers health metrics for the system_monitor service,
including publishing frequency.
- `system_monitor/auto_mode`: Streams auto mode state (either true or false).
- `system_monitor/batteries_state`: Streams the percent of battery left.
- `system_monitor/cpu_usage`: Streams the percent of CPU currently being consumed on the brain.
- `system_monitor/filter_state`: Streams the filter service state.
- `system_monitor/wifi_state`: Streams auto mode state (either true or false).
- `system_monitor/virtual_memory_usage`: Streams athe percent of virtual memory being consumed
by the brain.

- [Track Follower Topics](/docs/concepts/track_follower_service/#data-streams)

---

Expand All @@ -88,58 +73,62 @@ depending on their specific needs and analysis requirements.
## Recording Profile

To initiate recording, a "Recording profile" must be provided as an argument.
This profile is a JSON file detailing the subscriptions or topics to be recorded. Here's an example:
This profile is a
[**EventServiceConfig**](https://github.com/farm-ng/farm-ng-core/blob/main/protos/farm_ng/core/event_service.proto#L80-L107)
protobuf, detailing the subscriptions or topics to be recorded.

```json
{
"config": {
"name": "record_default",
"subscriptions": [
{
"uri": {
"path": "*",
"query": "service_name=canbus"
},
"every_n": 1
},
{
"uri": {
"path": "*",
"query": "service_name=gps"
},
"every_n": 1
},
{
"uri": {
"path": "/imu",
"query": "service_name=oak0"
},
"every_n": 1
},
{
"uri": {
"path": "*",
"query": "service_name=filter"
},
"every_n": 1
}
]
}
"name": "my_profile",
"subscriptions": [
{
"uri": {
"path": "*",
"query": "service_name=canbus"
},
"every_n": 1
},
{
"uri": {
"path": "*",
"query": "service_name=gps"
},
"every_n": 1
},
{
"uri": {
"path": "/imu",
"query": "service_name=oak/0"
},
"every_n": 1
},
{
"uri": {
"path": "*",
"query": "service_name=filter"
},
"every_n": 1
}
]
}
```

:::info INFO
The **`*`** symbol in the `path` field indicates that all available topics of that specific
subscription (service) should be recorded.

The `every_n` field indicates the ratio of recording frequency.
For example, if the publishing rate of `oak/0/imu` is 50 ms, an every_n of "2" will yield
in data being recording every 100 ms (2 * 50 ms).
:::

## API

Users can interact with the Recorder Service using the following commands:

- `/start`: Initiates data recording.
- `recorder/start`: Initiates data recording.
A valid "Recording profile" must be provided as an argument.
- `/stop`: Halts the data recording process.
- `recorder/stop`: Halts the data recording process.

## Data Storage

Expand All @@ -154,15 +143,19 @@ at the recording's start, the robot's name, and the file number in the sequence:
For example:

```php
2023_01_12_16_17_52_134845_element-vegetable.0000.bin
2024_06_01_12_00_00_134845_element-vegetable.0000.bin
```

## How to Use

Data can be recorded through the Recorder App, or using the `EventsClient` class.
Data can be recorded through the AppBar, the Camera App, or using the `EventsClient` class
as in the **Events Recorder example**.

- To record data through the UI on the Brain display, see the
[Launcher Guide - Status Bar](/docs/apps/launcher/#status-bar).

To record data through the UI on the Brain display, see the
[Recorder App Guide](/docs/apps/recorder_app/).
- To record data through the Camera App on the Brain display, see the
[Camera App Guider](/docs/apps/camera_app/).

guilhermedemouraa marked this conversation as resolved.
Show resolved Hide resolved
To record data using the Recorder Service API from your own application, see the
- To record data using the Recorder Service API from your own application, see the
[Events Recorder example](/docs/examples/events_recorder/).
Loading