Momentum Wheel Torque Control

Hey there,
I am currently working on a balancing cube project (inverted pendulum) and am trying to implement the control side of the project but I have no idea what the best way is to implement this velocity independant torque control. I tried to use the torque control mode of the odrive but it just remains stationary rather than controlling the speed to produce a torque.

How would I implement a spinning momentum wheel which can be accelerated/decelerated to achieve a torque output?

Cheers!

Torque control mode should be what you need…

Check that controller.input_mode = input_mode_passthrough

Thanks for that! Took me a while to figure this out since I kept on getting an error. The input_mode function is actually located within controller.config as shown below.
odrv0.axis0.controller.config.input_mode = INPUT_MODE_PASSTHROUGH

Now I just need to figure out how to make the Arduino side work. Pre-programmed commands work like:

requested_state = ODriveArduino::AXIS_STATE_MOTOR_CALIBRATION;
if(!odrive.run_state(motornum, requested_state, true)) return;

However sadly the commands below won’t yield any result and I don’t quite know why:

odrive_serial << "w axis0.controller.config.control_mode CONTROL_MODE_TORQUE_CONTROL\n";
odrive_serial << "w axis0.controller.config.input_mode INPUT_MODE_PASSTHROUGH\n";
odrive_serial << "w axis0.requested_state AXIS_STATE_CLOSED_LOOP_CONTROL\n";
odrive_serial << "w axis0.controller.input_torque " << 0.2f << "\n";
delay(2);
odrive_serial << "w axis0.controller.input_torque " << 0.0f << "\n";

When you send commands to the control mode, input mode, or state, you shouldn’t put the text. What you want to send is the integer value that corresponds to the enumeration that you want. See how we do this in the library as an example:

Of course… you could also just use the library and call odrive_serial.run_state() like we do in the example code.

That seems to work perfectly thanks @Wetmelon!

Would the method using odrive_serial.run_state() also work with say the InputMode or the ControlMode?

I have however as per usual run into further problems. The Odrive doesn’t seem to do anything the arduino asks once I disconnect the usb between my pc and the Odrive. Likely just a setting somewhere but I am not sure where to find this.

EDIT: I would also like to reset any errors that occur on the Odrive (sometimes it randomly comes up with an encoder error) automatically from the Arduino. Is there a command accessible through the serial interface for this?

No but it’s easily copied & modified to send the correct command

Do you have a ground wire between the odrive and the Arduino?

Not as such. You have to check all of the errors individually