I’m currently using an ODrive v3.6 in position mode and am receiving extremely bizarre errors. Right now, I am communicating to my board via UART and command it position changes of 0.05 in a loop, so that the motor oscillates between two values. Ex. the loop commands the ODrive += input_pos of 0.05 until it reaches 20, after which it commands the ODdrive -= input_pos of 0.05 until it goes back to 0. When I do this, it oscillates correctly a few times, then the motor suddenly stops and I get this error:
I think you must have a mismatch between odrive firmware and odrivetool version.
In the newer firmware, ODrive itself can handle this kind of trajectory generation - if you set controller.config.input_mode = INPUT_MODE_TRAP_TRAJ for example, then the position setpoint will follow the accel/decel/velocity limits set in axis.trap_traj.config.
Then you can just set input_pos = new_position directly with the UART command, and ODrive will smoothly move to the new position.
Hi Towen, thanks for your response. We are incrementing like that because our goal is to use the ODrive on a small vehicle so that when you press the accelerator, the motor turns in small increments while you press down. Then when you let go of the pedal, the motor stops spinning. We don’t want to use velocity mode for this, which is why we are incrementing in position mode. If I am following your suggestion correctly, I don’t think this would work in the TRAP_TRAJ mode right because we don’t have a set end point? (We just want to spin the motor as long as the user is pressing the pedal down)
EDIT: I think I misread your suggestion and it might do the trick. I will implement it and let you know if it fixes it. Thanks a lot!
If you are using ODrive for a manually-driven vehicle, I would recommend torque mode. This should feel a lot smoother and more natural than position mode.
In the newer firmware versions, you can also set a velocity limit in torque mode.
EDIT: But of course, you need to be in position mode to take it back to zero after it reaches 20 revs.
Position mode with TRAP_TRAJ should be a good bet, as it will smooth out that last move rather than taking a violent step input to the position controller.
You can also switch between torque and position modes on the fly if you want, i.e. when you get to 20, switch to position and move to 0, then back to torque. But you wouldn’t be able to hold position between steps which maybe you need to do.
Yeah, I think trap_traj is the move because we need to hold steps throughout the movement. Also, when I used trap_traj and moved the motor to a change of 1 position higher, it did the rotation but very slowly. Is there a way to increase the speed for 1 turn only? (I tried increasing vel and accel limits)
Also, for the appropriate ASCII command, would that be t or p for controlling position in this mode?
Ah ok you’re on a bit older version (0.5.1). If your version of odrivetool (the python program) and your version of the firmware (0.5.1) don’t match, then you end up with “UNKNOWN ERROR”