I am using the Arduino odrive library to command my motor and read data (position and velocity) from 2 different motors. And then data is printed on serial. However, when I print the data, the serial data gets mixed up. Sometimes position shows up in velocity, sometimes left motor position in the right and vice versa. Sometimes there is no problem with the same code.
motor_pos_left = odrive.GetPosition(motor_left);
delay(20)
motor_pos_right = odrive.GetPosition(motor_right);
delay(20);
motor_vel_left = odrive.GetVelocity(motor_left);
delay(20);
motor_vel_right = odrive.GetVelocity(motor_right);
delay(20);
Can anyone help with this issue?