Skip to main content

PyRoboteq Downloads

Python library to ease with roboteq motor controllers programming

Installation

Install the python package using: pip install PyRoboteq

Alternatively, you can clone this repository and import from the "PyRoboteq" directory.

Requirements

Tested Controllers: SDC2130, SBL2360T

The library may work with additional roboteq controllers.

In order to work with your motor controller, you'll need the following:

  • Installed PySerial module (imported as 'serial')
  • Connection to the motor controller via serial communication (USB)
  • Python 3.6 and above is recommended.

Usage

Setup

Import the PyRoboteq package

from PyRoboteq import RoboteqHandler

The PyRoboteq library includes a set of commands which you can use, including a comment describing the use of the command. To use the commands add the following line:

from PyRoboteq import roboteq_commands as cmds

Connection

In order to communicate with the controller, you will need to create a RoboteqHandler object, and then establish a connection with it. The RoboteqHandler() class additionally supports two parameters which can ease with the development.

  • The debug_mode parameter, which prints out any information sent or received to and from the controller, including any exceptions received.
  • The exit_on_interrupt. By default, the pyroboteq will ignore any exceptions to make sure minor interruptions wont crash your robot. this can be averted by adding the exit_on_interrupt parameter to exit when any interruption is received.
controller = RoboteqHandler(debug_mode = True, exit_on_interrupt = False)  # Create the controller object

The connect() method allows the library to connect to the controller, you must specifiy the port. The library works both on linux and windows.

is_connected = controller.connect("COM9") # connect to the controller (COM9 is an example for windows)

Sending Commands

Afterwards, what you will have to do is to simply write a command to the motors, if you have the SDC2130 dual series, you'll be able to communicate with 2 motors

if __name__ == "__main__":
    while True:
        controller.dual_motor_control(100, 100) # Send command to the controller

To send a message to the controller, use the send_command()

controller.send_command(EM_STOP) # this will send 0 argument command for emergency stop
controller.send_command(REL_EM_STOP) # send this command to release it
controller.send_command(SET_SPEED, 1, 1000) # send 'set speed' command to channel 1 (first argument) with the value of up to 1000 RPM (second argument)

As you can notice, you do not have to use all the arguments, check the manual to see how many arguments you need to use. The library will construct a command depending on how many arguments you give.

Even though send_command supports using raw strings, you can more preferablly send a raw string to the controller using the send_raw_command() method.

controller.send_raw_command("!M 200 200") # send a raw string.

Reading Commands

Sending commands to the controller is cool, but it would be much cooler, if the controller could also return you its very beneficial data. For this, you can use the read_value() method. The method has 2 parameters, the read command, and optionally a parameter. some commands will give you multiple data, like controller voltage, which will give you voltage from 3 different points of the controller. It is recommended that you read the manual to see what each value means.

controller_volts = controller.read_value(cmds.READ_VOLTS) # receive voltages from the controller
>>> "V= 12:16:5" # Without a parameter, the controller returns 3 channels, (internal, battery, 5v output) respectively
controller_volts = controller.read_value(cmds.READ_VOLTS, 2)
>>> "V= 16" # This way, the controller will return only the value of channel 2 (battery voltage)

Same command can be sent using a raw string:

controller_volts = controller.read_value("?V", 2)
>>> "V=16"

Examples

The PyRoboteq library comes with little examples which you can run right away.

To access the examples head to the "examples" directory inside the "PyRoboteq" directory.

More information

For more information and manuals, please refer to the official Roboteq website.

License

MIT License

Special thanks to everyone who contributed to this little project

Metadata

Release files for PyRoboteq 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyRoboteq 0.1.2
File Size Uploaded
PyRoboteq-0.1.2.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyRoboteq 0.1.2
File Interpreter ABI Platform
PyRoboteq-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.9 kB

Release files / PyRoboteq-0.1.2.tar.gz

Download URL PyRoboteq-0.1.2.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4eb8c1b002cf0d19555e727e9e78aa6d89f46a016e4d53302cfd9857c8d85aa9
BLAKE2b-256 checksum
How to use checksums
626a96b08fae90ae39c9f589071d12267a94ac175684e9d5699557d6f72bc3ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / PyRoboteq-0.1.2-py3-none-any.whl

Download URL PyRoboteq-0.1.2-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e96f8aa8fe267d2c1bf98e6f414e8fbd015980c225983756344529ad0cacd99a
BLAKE2b-256 checksum
How to use checksums
e8183a1c3d8f23e280bb43b8107fddf272b58027fb853b093a7de7b617740ac2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page