How to vari velocity when in position control mode

Hi! I’m fairly new to robotics, and I happen to have access to an odrive S1 and a 90kv bldc motor that I’m using to learn. I’m controlling the Odrive from an Arduino using CAN and have it set to position control mode.
I see that when I call odrv0.setPosition(…) the motor always runs at the maximum velocity. Still, I want to try and control the velocity at which the motor turns, just like on the web GUI where I can set the maximum velocity (Dashboard/PositionControl/TuningParameters/VelocityLimit). I’m not finding a way to do this. I’ve tried calling odrv0.setLimits(float velocity_limit, float current_soft_max) but it’s not working how I would expect. I may be doing something wrong, I’m misunderstanding something, or possibly both T.T.

Is there any way to do this? And if not, I was thinking of interpolating from the start of the movement to its end target and feed those incremental positions one by one to control the speed. I’m not sure if that’s a bad idea.
I’m in position control because for my application I need to set a desired position rather than velocity or torque, but it would also be important to control the speed at which it moves from one place to another.

Thanks a lot in advance for any help!

Hi! This sounds exactly what trajectory control is meant for. If you set your odrv0.axis0.controller.config.input_mode to InputMode.TRAP_TRAJ, then you can configure odrv0.axis0.trap_traj.config.vel_limit (as well as accel_limit and decel_limit) to specify the maximum velocity, acceleration, and deceleration used when moving between points.

You can configure all this over CAN from the Arduino but it may be quicker to just configure it in the GUI – then from the Arduino you can just use setPosition.

1 Like

Thanks a lot! I will try it out.
Also, in case anyone has the same problem, calling odrv0.setLimits(float velocity_limit, float current_soft_max) does work, but you need to add a bit of delay between commands. I added a delay(10); between setLimits and setPosition and it started working

Good to know! Yes, I believe those only take effect after one controller cycle (~125us maximum).