mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-16 17:20:05 +00:00
9cfb5ce546
* fix(motors): cleanup imports + fix signatures * feat(motors): add damiao canbus + multiple fixes * fix(motors): address comments -> last_state + different gains + sleep * refactor(motors): reduce duplicated code + adressed some comments in the PR * chore(motors): better timeouts * tests(motors): damiao test and imports * chore(deps): fix space * Apply suggestions from code review Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com> Signed-off-by: Steven Palma <imstevenpmwork@ieee.org> * chore(motors): remove normalization tables damiao * fix(motors): imports and signatures * feat(motors): add motor_type_str + recv_id to motor class and _get_motor_recv_id raises if no motor_obj.recv_id * chore(motors): remove normalize from base motor class and damaio * tests(motors): remove bad tests (to be replaced) * chore(motors): updated import check * use constant for kp and kd range and check responses in mit_control_batch() * Add docs on setting up canbus and use damiao otor bus, also add lerobot_setup_can.py and log if there is not response from a write command * precommit format * supress bandit as these are intentional cli commands * fix setup-can * add test * skip test in ci * nit precommit * update doc example * dont import can for tests --------- Signed-off-by: Steven Palma <imstevenpmwork@ieee.org> Co-authored-by: Pepijn <138571049+pkooij@users.noreply.github.com> Co-authored-by: Pepijn <pepijn@huggingface.co>
67 lines
1.7 KiB
Python
67 lines
1.7 KiB
Python
"""Minimal test script for Damiao motor with ID 3."""
|
|
|
|
import pytest
|
|
|
|
from lerobot.utils.import_utils import _can_available
|
|
|
|
if not _can_available:
|
|
pytest.skip("python-can not available", allow_module_level=True)
|
|
|
|
from lerobot.motors import Motor
|
|
from lerobot.motors.damiao import DamiaoMotorsBus
|
|
|
|
|
|
@pytest.mark.skip(reason="Requires physical Damiao motor and CAN interface")
|
|
def test_damiao_motor():
|
|
motors = {
|
|
"joint_3": Motor(
|
|
id=0x03,
|
|
model="damiao",
|
|
norm_mode="degrees",
|
|
motor_type_str="dm4310",
|
|
recv_id=0x13,
|
|
),
|
|
}
|
|
|
|
bus = DamiaoMotorsBus(port="can0", motors=motors)
|
|
|
|
try:
|
|
print("Connecting...")
|
|
bus.connect()
|
|
print("✓ Connected")
|
|
|
|
print("Enabling torque...")
|
|
bus.enable_torque()
|
|
print("✓ Torque enabled")
|
|
|
|
print("Reading all states...")
|
|
states = bus.sync_read_all_states()
|
|
print(f"✓ States: {states}")
|
|
|
|
print("Reading position...")
|
|
positions = bus.sync_read("Present_Position")
|
|
print(f"✓ Position: {positions}")
|
|
|
|
print("Testing MIT control batch...")
|
|
current_pos = states["joint_3"]["position"]
|
|
commands = {"joint_3": (10.0, 0.5, current_pos, 0.0, 0.0)}
|
|
bus._mit_control_batch(commands)
|
|
print("✓ MIT control batch sent")
|
|
|
|
print("Disabling torque...")
|
|
bus.disable_torque()
|
|
print("✓ Torque disabled")
|
|
|
|
print("Setting zero position...")
|
|
bus.set_zero_position()
|
|
print("✓ Zero position set")
|
|
|
|
finally:
|
|
print("Disconnecting...")
|
|
bus.disconnect(disable_torque=True)
|
|
print("✓ Disconnected")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_damiao_motor()
|