Official Lynxmotion Smart Servo (LSS) libraries for Python
Read more about the LSS on our wiki.
If you want more details about the LSS protocol, go here.
To configure your LSS easily, we recommend you try out the LSS Config. More details about it on the wiki.
Purchase any LSS model on and accessories at RobotShop!
Check out blogs, tutorials and post questions on the RobotShop community site.
This project uses uv for dependency management. If you don't have uv installed:
# Install uv (Linux/macOS)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or using pip
pip install uv# Clone the repository
git clone https://github.com/motius/pyLSS
cd PyLSS
# Install dependencies
uv sync
# Or install in development mode with all dependencies
uv sync --all-groupsimport serial
from pylss import LSS
# Create and open a serial connection
bus = serial.Serial('/dev/ttyUSB0', 115200, timeout=0.1)
# Create an LSS servo controller for servo ID 5
servo = LSS(5, bus)
# Move to 45 degrees
servo.move_deg(45.0)
# Get current position
position = servo.get_position_deg()
print(f"Current position: {position}°")
# Get servo information
model = servo.get_model()
voltage = servo.get_voltage()
temperature = servo.get_temperature()
print(f"Model: {model}")
print(f"Voltage: {voltage}mV")
print(f"Temperature: {temperature/10}°C")
# Clean up
bus.close()The repository includes several example scripts in the examples directory:
The library includes a comprehensive test suite using pytest with mocked serial communication, so no hardware is required to run tests.
# Run all tests
uv run pytest tests/
# Run with verbose output
uv run pytest tests/ -v
# Run with coverage report
uv run pytest tests/ --cov=pylss
# Run specific test class
uv run pytest tests/test.py::TestLSSActionMethods -vAll tests use mocked serial objects, making them fast and reliable without requiring physical hardware.