Configure a roboclaw motor
The roboclaw
model of the motor component supports standard brushed DC motors driven by Basicmicro’s RoboClaw motor controller.
Note
You must set up your RoboClaw before configuring it.
Make note of the baud rate that you set up during this process.
The default is 38400
.
Follow this guide to do so.
To configure a roboclaw
motor as a component of your robot:
Navigate to the Config tab of your robot’s page in the Viam app.
Click on the Components subtab and click Create component.
Select the motor
type, then select the roboclaw
model.
Enter a name for your motor and click Create.
Edit and fill in the attributes as applicable.
{
"components": [
{
"name": "<your-roboclaw-motor-name>",
"type": "motor",
"model": "roboclaw",
"attributes": {
"serial_path": "<your-serial-path>",
"motor_channel": <int>,
"serial_baud_rate": <int>
},
"depends_on": []
}
]
}
Example configuration for a roboclaw
DC brushed motor:
{
"components": [
{
"name": "your-roboclaw-motor",
"type": "motor",
"model": "roboclaw",
"attributes": {
"serial_path": "/dev/ttyUSB0",
"motor_channel": 1,
"serial_baud_rate": 38400
},
"depends_on": []
}
]
}
The following attributes are available for roboclaw
motors:
Name | Type | Inclusion | Description |
---|---|---|---|
serial_path | string | Required | The full filesystem path to the serial device, starting with sudo dmesg | grep tty to show relevant device connection log messages, and then match the returned device name, such as ttyAMA0 , to its device file, such as ls /dev/serial/by-path to list USB serial devices. If you omit this attribute, Viam will attempt to automatically detect the path.Example: "/dev/serial/by-path/usb-0:1.1:1.0" |
serial_baud_rate | int | Optional | Rate to send data over the serial line. This must match the baudrate you have set up using basicmicro’s setup program. You cannot have multiple roboclaw motors with different baud rates.Default: 38400 |
motor_channel | int | Required | Channel the motor is connected to on the controller. Must be 1 or 2 . |
address | int | Optional | Serial address of the controller. Default: 128 |
ticks_per_rotation | int | Optional | Number of full steps in a rotation. Update this if you connect encoders to your controller through its EN1 and EN2 pins. Default: 0 |
Refer to your motor and motor driver data sheets for specifics.
Test the motor
Once your motor is configured and connected, go to the Control tab and click on the motor’s drop-down panel. Use the buttons to try turning your motor forwards or backwards at different power levels and check whether it moves as expected.
If the motor does not appear on the Control tab, or if you notice unexpected behavior, check your robot’s Logs tab for errors, and review the configuration.
Have questions, or want to meet other people working on robots? Join our Community Discord.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!