Quickstart Tutorial: Python API for a Real Actuator via USB
This page walks you through the fastest way to run a real actuator connected via USB and control it with Python. It installs the Python API globally so you can test quickly from a terminal.
For best-practice project setup, dependency management, and reusable examples, start with Install Python API, then follow the Python API Examples repository README, beginning with the quickstart examples.
👣 Step-by-Step Guide
- Make sure your actuator is set up and connected via USB, as described in the Quickstart Tutorial: Set Up a Real Actuator and Connect via USB.
Tip
This quickstart is optimized for speed, not long-term project hygiene. For normal development, use the installation workflow in Install Python API and run the maintained quickstarts and tutorials from Python API Examples.
-
Install the PULSAR HRI Python API:
-
Check USB communication using the CLI tool:
You should see your actuator's ID and connection information. -
Copy and paste the following command into your terminal. The actuator should rotate at a constant speed for 5 seconds:
python - <<'PY' from time import sleep from pcp_api import PcpOverUsb, PulsarActuatorReal # Auto-detect the USB port and create the adapter port = PcpOverUsb.get_port() adapter = PcpOverUsb(port) # Connect to actuator at address 0 (USB) actuator = PulsarActuatorReal(adapter, 0) actuator.connect() # Set control mode and target speed actuator.change_mode(PulsarActuatorReal.Mode.SPEED) actuator.change_setpoint(1.0) # rad/s # Start and run for 5 seconds actuator.start() sleep(5) actuator.disconnect() adapter.close() PY
Success
You’ve just sent your first command using the PULSAR Python API! You can now do much more with it:
-
Following the public Python examples repository, starting with the quickstart examples and then moving to the in-depth tutorials.
-
Trying communication methods beyond direct USB that enable control of multiple actuators, such as PULSAR CAN Communication.
-
Becoming familiar with the Python API code reference, starting with
PulsarActuatorReal. -
If you're interested in simulating PULSAR actuators without hardware, explore how to create virtual actuators with the AUGUR Digital Twin. The first public DTwin beta asset release is available for Linux x86_64 and Windows x86_64.
Question
Need help or something doesn’t work? Head over to the Support page: we’ve got your back.