billmania / roboquest_core

The backend functionality for the RoboQuest project
1 stars 0 forks source link

Move I2C bus IDs to persistent ROS config file #85

Open billmania opened 5 days ago

billmania commented 5 days ago

rq_addons Issue 5 depends on this Issue.

Currently, the I2C bus ID for both servoes and motors is hard-coded as a constant in rq_motors.py and rq_servos.py. Provide a mechanism to override both of those constants using definitions in the ROS parameter file /opt/persist/i2c/i2c.yaml.

billmania commented 4 days ago

Testing with:

/**:
  ros__parameters:
    servos_i2c_bus_id: 1
    motors_i2c_bus_id: 1

resulted in:

_setup_i2c: devices {1: {'bus': <smbus2.smbus2.SMBus object at 0x7f80b75240>, 'devices': [83, 64]}}

With

/**:
  ros__parameters:
    servos_i2c_bus_id: 6
    motors_i2c_bus_id: 1

results were:

setup_i2c: devices {1: {'bus': <smbus2.smbus2.SMBus object at 0x7fb6889240>, 'devices': [83]}, 6: {'bus': <smbus2.smbus2.SMBus object at 0x7fb6889360>, 'devices': [64]}}

Tested with both the motor controller wired to I2C1 connector and confirmed servos and motors still worked correctly.

Also verified the only device normally on I2C bus 6 is 0x53. I2C bus 1 normally has 0x00 and 0x40.