SOLVED: Switching from velocity to position mode (jerking motion)

Hi all,

I have a question regarding switching from velocity mode (vel ramp input mode) to control mode for a robot arm I am working on.

Imagine my scenario:

  • a joint is at home position (pos_estimate = 0, pos_setpoint = 0)
  • I placed it in velocity mode (to jog) and moved it to pos_estimate = 9 [revs]
  • now I want to go back to position mode. But, the second I place it in position mode it races back to “zero” position (because pos_setpoint is still = 0, and pos_estimate is not)

What I want the joint to do:

  • after I used velocity mode to jog the joint, I want to place it in position mode but want to to stay where it is at, and continue on from there using position mode.

The problem:

  • pos_setpoint is not writable (anymore on the new firmware).

Is it possible to change/modify the pos_setpoint?
How can I achieve switching from velocity mode to position mode (preferably without putting the joint i idle and then closed loop again)

I found an older thread discussing this.

The solve for this as of firmware 0.5.3 is as follows:

After you are done with velocity mode (vel ramp input mode)…

1- axis.controller.input_pos = axis.encoder.pos_estimate
2- axis.controller.controller.config.input_mode = 1 (passthrough)
3- axis.controller.config.input_mode = 5 (trap traj if you want it)
4- axis.controller.confg.control_mode = 3 (position mode)

Step 2 need to happen on the next cycle of the microcontroller (125 us) so, you may want to put a 1 ms delay before and after setting the input position to passthrough (step2)