-
Notifications
You must be signed in to change notification settings - Fork 48
DOCS-4087: autonomous decision-making #4473
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
Conversation
✅ Deploy Preview for viam-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…your module from scratch
It looks like the following files may have been renamed. Please ensure you set all needed aliases: |
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.
So high-level, I am curious about the objective of this PR. It seems like it creates a rather lengthy page that duplicates other tutorial and how-to content. Each section in here is covering configuring a (specific) machine, generating module stub code, modifying the code to follow a different pattern from what the generator generates, and also writing logic that makes decisions autonomously.
Would it perhaps be better to have targeted code snippets in a how-to, and then have full things like this in tutorials? Then this page can just focus on the making autonomous decisions and be much shorter?
I'm also curious what the plan is for maintaining these code examples as the platform including the module generator change; the hot reloading flow for example should improve soon.
@@ -219,46 +219,46 @@ Next, navigate to the **CONFIGURE** tab of your machine's page. | |||
|
|||
1. **Add a vision service.** | |||
|
|||
Next, add a vision service [detector](/dev/reference/apis/services/vision/#detections): | |||
Next, add a vision service [detector](/dev/reference/apis/services/vision/#detections): |
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.
bah why must GH be so bad at recognizing whitespace-only diffs ;(
Connect your SCUTTLE base to your SBC. | ||
Add the following `components` configuration to create board, base, and motor components in Viam so you can control your SCUTTLE base: |
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.
I would make this way less scuttle-specific. You could link to the tutorial as an example but this feels like too much detail and too specific for an AI section guide.
I'd ditch the config below too since it takes up so much length on the page but won't apply to all bases; just tell them to configure their base with a link to https://docs.viam.com/operate/reference/components/base/
- **module name**: "autonomous_example_module" | ||
- **language**: Python | ||
- **visibility**: private | ||
- **organization ID**: your organization ID, found on the Viam organization settings page | ||
- **resource to be added to the module**: Generic Service | ||
- **model name**: "line_follower" | ||
- **Enable cloud build**: yes | ||
- **Register module**: yes |
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.
- **module name**: "autonomous_example_module" | |
- **language**: Python | |
- **visibility**: private | |
- **organization ID**: your organization ID, found on the Viam organization settings page | |
- **resource to be added to the module**: Generic Service | |
- **model name**: "line_follower" | |
- **Enable cloud build**: yes | |
- **Register module**: yes | |
- **Module name**: `autonomous_example_module` | |
- **Language**: Python | |
- **Visibility**: Private | |
- **Organization ID**: Your organization ID, found on the Viam organization settings page | |
- **Resource to be added to the module**: Generic Service | |
- **Model name**: `line_follower` | |
- **Enable cloud build**: Yes | |
- **Register module**: Yes |
[nits] Some of these are capitalized in the CLI prompts anyway, plus regardless it looks odd in the list for them to be inconsistent
Find the [Part ID](/dev/reference/apis/fleet/#find-part-id) for your machine. | ||
To deploy your module on your machine, run the following command, replacing `<your-part-id>` with your Part ID: |
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.
Find the [Part ID](/dev/reference/apis/fleet/#find-part-id) for your machine. | |
To deploy your module on your machine, run the following command, replacing `<your-part-id>` with your Part ID: | |
Find the [part ID](/dev/reference/apis/fleet/#find-part-id) for your machine. | |
To deploy your module on your machine, run the following command, replacing `<your-part-id>` with your part ID: |
[nit]
# Register your module | ||
Registry.register_resource_creator( | ||
LineFollower.MODEL, | ||
ResourceCreatorRegistration(LineFollower.new_resource, LineFollower.validate) | ||
) | ||
|
||
async def main(): | ||
""" | ||
Main entry point for the Viam module. | ||
""" | ||
await Module.serve() | ||
|
||
if __name__ == "__main__": | ||
asyncio.run(main()) | ||
LineFollower.LOGGER.info("Done.") |
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.
Sorry if this is a silly question but, the module generator doesn't include this--why is it here? You're not using easyresource?
I worry this will contribute to the chatbot mixing and matching example module structures
async def start(self): | ||
LineFollower.LOGGER.info("Starting color following...") | ||
await self._start_color_following_internal() | ||
|
||
async def close(self): |
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.
When do these get called? I noticed they're not generated by the generator for generic service. I see we have close here https://python.viam.dev/autoapi/viam/services/generic/client/index.html#viam.services.generic.client.GenericClient.close but not start
|
||
## Follow a line | ||
|
||
This module uses a vision service and a motor to program a machine to follow a line of a configurable color. |
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 module uses a vision service and a motor to program a machine to follow a line of a configurable color. | |
This module uses a vision service to make a mobile robot follow a colored line. | |
You can configure the color. |
It doesn't just use a motor
Also nit: make sure your PR title is in imperative mood |
if location == "left": | ||
# Crop logic for left side | ||
pass | ||
elif location == "right": | ||
# Crop logic for right side | ||
pass | ||
# Implement detection logic here |
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.
Did not review all the code in this PR because was first curious about overall intent of PR, but if this does go forward this code will need to be fixed
Uh oh!
There was an error while loading. Please reload this page.