I am would like to control 2 motors synchronized using ODrive. The first motor rotates at a fixed speed (which can be changed), and the second motor should always maintain a certain encoder offset of the other.
m0 should always follow m1, such that the m1 encoder.count_in_cpr - m0 encoder.count_in_cpr is a fixed value, e.g. 500.
I am not sure how to achieve that. I would like to do that in a Python script. So far, I have set m1 into ramped vel mode, can set the speed of m1 as desired, and want to set m0 into torque mode, and then control it such, that it follows m1, but that doesn’t work.
You can set m1.input_pos = m0.pos_estimate - 500 and m1.input_vel = m0.vel_setpoint
You can almost use the mirroring mode for this but it doesn’t have an “offset”, so you’d have to physically set up your system such that the one motor is 500 counts behind the other one (see input mode 7 here)
I my case m0 should mirror m1 movements (with fixed offset). But actually their directions are inversed (i.e. m1 moves +, and m0 -), i.e. in order to keep the fixed offset m0 has to turn negatively, if m1 turns positively.
How exactly would that work:
set both axes into: AXIS_STATE_CLOSED_LOOP_CONTROL
put both into: axis.controller.config.input_mode = INPUT_MODE_MIRROR
put both: axis.controller.config.control_mode = CONTROL_MODE_POSITION_CONTROL
for both: axis.controller.config.circular_setpoints = True
And:
a) Do I need these settings too?
config.axis_to_mirror
config.mirror_ratio
b) How could I set the speed for m1 here? Using m1.input_vel?
c) Should m1 be in Circular position control mode, or Vel Mode?
d) Can I set ramps for this mirroring (vel ramp, torque ramp)?