Viam Robotics Code Snippets
If you are using this extension or downloading it now, consider helping me out by filling out this quick 🏃🏽♂️ form.
Table of Contents
Overview
This is a VS Code (and Cursor) extension that offers a collection of code snippets for Viam Robotics. It lets you build your robot and smart machine applications faster by providing predefined code snippets for common coding tasks related to Viam.
Includes Python, Golang and Typescript snippets
😄 If you find this extension helpful please share with your friends and consider giving it a positive review
🐞 Notice an issue? Reach out on Twitter
👨💻 This is an unofficial extension and managed by me, Waseem
I'm currently exploring/building in AI, AR/VR and Robotics and sharing my journey on Twitter
My hope is that this extension can accelerate your development process when working with Viam Robotics. Happy Building!
Installation
To install this extension, follow the standard procedure for installing Visual Studio Code extensions:
- Open Visual Studio Code or Cursor
- Open the Extensions pane
- Search for "Viam Robotics Code Snippets"
- Click Install
- Start coding using the conventions below
- Smile and have fun
Usage
To use a snippet, open a supported programming (.py or .go) file and start typing the prefix of the snippet you want to use. The snippet should appear in the IntelliSense suggestions. You can then insert it by clicking on it or pressing the Tab or Enter key.
Snippets
These snippets follow a convention to make it easier to use. As you are typing, the intellisense dropdown will show you related snippets.
Convention
- All snippets start with
_v
.
- Adding a template start with
_vt
then the name of the template. Ex: _vtmain
.
- Adding a component start with
_vc
then the name of the component. Ex: _vcsensor
.
- Importing components have the same command as adding a component, but with _import at the end. Ex:
_vcsensor_import
.
Templates
Command |
Description |
_vtconnect |
Establish a connection to a robot with an address or channel. |
_vtmain |
Template that establishes a connection to a robot with a main async event loop. |
Components
Command |
Description |
_vcarm |
Initializes an Arm object. |
_vcbase |
Initializes a Base object. |
_vcboard |
Initializes a Board object. |
_vccamera |
Initializes a Camera object. |
_vccontroller |
Initializes a Controller object and handles its controls and events. |
_vcencoder |
Initializes an Encoder object. |
_vcgantry |
Initializes a Gantry object. |
_vcgripper |
Initializes a Gripper object. |
_vcmotor |
Initializes a Motor object. |
_vcmovementsensor |
Initializes a Movement Sensor object. |
_vcsensor |
Initializes a Sensor object. |
_vcservo |
Initializes a Servo object. |
Component Imports
Command |
Description |
_vcarm_import |
Import Arm component. |
_vcbase_import |
Import Base component. |
_vcboard_import |
Import Board component. |
_vccamera_import |
Import Camera component. |
_vccontroller_import |
Import Controller components. |
_vcencoder_import |
Import Encoder component. |
_vcgantry_import |
Import Gantry component. |
_vcgripper_import |
Import Gripper component. |
_vcmotor_import |
Import Motor component. |
_vcmovementsensor_import |
Import Movement Sensor component. |
_vcsensor_import |
Import Sensor component. |
_vcservo_import |
Import Servo component. |
Contributing
Feel free to submit pull requests if you want to add more snippets or improve the existing ones.
- You could either add a
.py
, .go
or .ts
file in a folder and into its respective directory. You must include a details.json
and snippet.__
file
- Or you can create a
.code-snippets
file with a dictionary of the new snippets.
If you have any questions or issues, please open an issue on the GitHub repository. Or reach out to Waseem via Twitter or Email.
License
The project is licensed under the MIT License. See the LICENSE file for details.