Encoder data from Odrive

Hello everyone,

I am using AS5047D encoder with Odrive Pro, but I wanted to send the encoder data from Odrive to Teensy3.5 via UART. I’m using the command odrive.getEncoderPosition(ODRV_0), but the .getEncoderPosition isn’t working. Any idea on where am I going wrong?

Thank you!

Assuming the ODriveUART instance is named ODRV_0:

ODriveFeedback feedback = ODRV_0.getFeedback();
Serial.println(feedback.pos) # This will be the encoder position

May I ask where you saw the “getEncoderPosition” function? I want to make sure that we don’t have any out-of-date documentation anywhere.

Hi, Thank you for the prompt reply!
I didn’t see it in the official documentation. I read it somewhere in the posts or online platforms. I honestly don’t remember!

I do have another question, I am using two Odrives and I want to get the position and velocity feedback of two AS5047d encoders, each attached to one of the odrive. How can I get the feedback.pos or feedback.vel in that case.

Thank you so much for your help!

Assuming you have e.g. ODrive 0 on serial 2, and ODrive 1 on serial 3, and your baudrate is 115200:

// 
HardwareSerial& odrive0_serial = Serial2;
HardwareSerial& odrive1_serial = Serial3;

ODriveUART odrive0(odrive0_serial);
ODriveUART odrive1(odrive1_serial);

void setup() {
    odrive0_serial.begin(115200);
    odrive1_serial.begin(115200);

    ODriveFeedback odrive0_feedback = odrive0.getFeedback();
    ODriveFeedback odrive1_feedback = odrive1.getFeedback();
    // Then you'd just use e.g. odrv0_feedback.pos or .vel or odrv1_feedback.pos or .vel

Thank you so much. I’ll try this out.

Truly appreciate it! Thanks!

No worries, best of luck!

1 Like

Hi Solomondg,

I have a quick question, for sending current/torque values from teensy to odrive, what command should I use? can I use setTorque in that case?

Thank you!

Yep, setTorque’s the one!

Thank you so much. You’re awesome!

Glad I could help :slight_smile:

Hi Solomondg,
I was wondering if there’s a way to serial print how much toruqe Odrive is providing the motors in position control mode using Arudino IDE?

Thank you for you help!

Hi! you can just run e.g. odrive.getParameterAsFloat("axis0.motor.torque_estimate");

I’ll try that. Thank you so much!

1 Like

Let me know how it goes!

Yeah, it works perfectly. Thanks!

1 Like