-
Notifications
You must be signed in to change notification settings - Fork 11
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 docs for modular driver example consolidation #239
Merged
allisonschiang
merged 10 commits into
viamrobotics:main
from
allisonschiang:update-docs
Jun 25, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
c666128
update readme for template module
allisonschiang 7738c46
edited more links
allisonschiang 4993e9b
Merge branch 'viamrobotics:main' into update-docs
allisonschiang 18a5baa
grammar
allisonschiang bdff1ba
Update README.md
allisonschiang 18edf25
Update README.md
allisonschiang de662df
Update README.md
allisonschiang e5b7244
Merge branch 'main' into update-docs
allisonschiang c0906e8
added commit vers
allisonschiang 110ce9c
Merge branch 'main' into update-docs
allisonschiang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
# Viam Micro-RDK ESP32 Sensor Modules Example | ||
# Viam Micro-RDK Modular Driver Examples | ||
|
||
## (In)stability Notice | ||
|
||
> **Warning** The Viam Micro-RDK is currently in beta. | ||
|
||
## Overview | ||
|
||
This project in this repository was generated from the [Micro-RDK | ||
Module | ||
Template](https://github.com/viamrobotics/micro-rdk/tree/main/templates/module), | ||
This project in this repository was generated from the | ||
[Micro-RDK Module Template](/templates/module), | ||
and demonstrates how to produce modular resources for the Micro-RDK. | ||
|
||
## Usage | ||
|
@@ -36,11 +35,12 @@ index 79fbc5c..949b5ab 100644 | |
smol = "1.2" | ||
futures-lite = "1.12.0" | ||
micro-rdk = {version = "0.0.3", git = "https://github.com/viamrobotics/micro-rdk.git", features = ["esp32"]} | ||
+micro-rdk-esp32-sensor-examples = { git = "https://github.com/viam-labs/micro-rdk-esp32-sensor-examples" } | ||
+micro-rdk-modular-driver-example = { git = "https://github.com/viamrobotics/micro-rdk/tree/main/examples/modular-drivers" } | ||
``` | ||
|
||
Rebuild the project per the above Micro-RDK Development Setup | ||
instructions and reflash the board. | ||
instructions and reflash the board. We will be using the Wifi | ||
RSSI Sensor and free heap sensor for this example. | ||
|
||
### Instantiating the Sensors | ||
|
||
|
@@ -94,7 +94,7 @@ can find this code on the `Code Sample` page for your robot): | |
## Implementation Walkthrough | ||
|
||
This project was created by using the [Micro-RDK Module | ||
Template](https://github.com/viamrobotics/micro-rdk/tree/main/templates/module) | ||
Template](/templates/module) | ||
and `cargo generate`: | ||
|
||
``` shell | ||
|
@@ -103,33 +103,39 @@ $ cargo generate --git https://github.com/viamrobotics/micro-rdk templates/modul | |
``` | ||
|
||
When prompted by the template, the project was named | ||
`micro-rdk-esp32-sensor-examples` and `esp32` selected for the target | ||
`micro-rdk-modular-driver-example` and `esp32` selected for the target | ||
platform. The generated project has the form of a library crate, where | ||
`src/lib.rs` defines an initially empty implementation of the | ||
well-known Micro-RDK module entry point `register_models`: | ||
|
||
https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/02d7c8e487a48ac7c8d527a5c7b750d6c2357a27/src/lib.rs#L3-L5 | ||
``` rust | ||
use micro_rdk::common::registry::{ComponentRegistry, RegistryError}; | ||
|
||
pub fn register_models(_registry: &mut ComponentRegistry) -> Result<(), RegistryError> { | ||
Ok(()) | ||
} | ||
``` | ||
|
||
The generated project also includes a `package.metadata` section in | ||
its `Cargo.toml` which identifies the library crate as being a | ||
Micro-RDK module: | ||
|
||
https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/02d7c8e487a48ac7c8d527a5c7b750d6c2357a27/Cargo.toml#L12-L13 | ||
https://github.com/viamrobotics/micro-rdk/blob/fbc1783258bfefc027fd25a8cc9a1b37f6ea0524/examples/modular-drivers/Cargo.toml#L18-L19 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be relative? |
||
A subsequent commit adds definitions of the | ||
[FreeHeapSensor](https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/9cc59d56cc35ab7cf0c471b613c5f3c2ab2ed95b/src/wifi_rssi_sensor.rs) | ||
[FreeHeapSensor](src/free_heap_sensor.rs) | ||
and | ||
[WifiRSSISensor](https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/9cc59d56cc35ab7cf0c471b613c5f3c2ab2ed95b/src/free_heap_sensor.rs) | ||
[WifiRSSISensor](src/wifi_rssi_sensor.rs) | ||
|
||
That commit also introduces a crate-local `register_model` function | ||
That commit also introduces a crate-local `register_models` function | ||
for each sensor: | ||
|
||
- `FreeHeapSensor`: https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/9cc59d56cc35ab7cf0c471b613c5f3c2ab2ed95b/src/free_heap_sensor.rs#L21-L25 | ||
- `WifiRSSISensor`: https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/9cc59d56cc35ab7cf0c471b613c5f3c2ab2ed95b/src/wifi_rssi_sensor.rs#L19-L23 | ||
- `FreeHeapSensor`: https://github.com/viamrobotics/micro-rdk/blob/fbc1783258bfefc027fd25a8cc9a1b37f6ea0524/examples/modular-drivers/src/free_heap_sensor.rs#L23-27 | ||
- `WifiRSSISensor`: https://github.com/viamrobotics/micro-rdk/blob/fbc1783258bfefc027fd25a8cc9a1b37f6ea0524/examples/modular-drivers/src/wifi_rssi_sensor.rs#L23C1-L27C2 | ||
|
||
Finally, the top level `register_models` entry point is updated to delegate to the `register_model` function for both sensors: | ||
Finally, the top level `register_models` entry point is updated to delegate to the `register_models` function for both sensors: | ||
|
||
https://github.com/viam-labs/micro-rdk-esp32-sensor-examples/blob/9cc59d56cc35ab7cf0c471b613c5f3c2ab2ed95b/src/lib.rs#L6-L10 | ||
https://github.com/viamrobotics/micro-rdk/blob/fbc1783258bfefc027fd25a8cc9a1b37f6ea0524/examples/modular-drivers/src/lib.rs#L10C1-L18C2 | ||
|
||
The Micro-RDK module is now ready to be used in a Micro-RDK project, | ||
just by adding it as an ordinary dependency in the `dependencies` | ||
|
@@ -138,6 +144,5 @@ section of the project's `Cargo.toml` file, as noted in the | |
|
||
## Related Reading | ||
|
||
Please see | ||
https://github.com/viam-labs/micro-rdk-modular-driver-examples for | ||
another example of modular Micro-RDK sensors. | ||
Please see the [moisture sensor](src/moisture_sensor.rs) and [water pump](src/water_pump.rs) for | ||
more examples of modular Micro-RDK drivers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⬆️ - This still says
micro-rdk-esp32-sensor-examples
.