ASCII with Raspberry Pi

I am wanting to send an input velocity to the ODrive via ASCII. I was wondering what the syntax for that is in python?

For reading position, I found the below works:

ser.write(“f 0\n”.encode(‘ascii’))
pos = ser.readline()
print(pos)

Hi jonathan,

I use ASCII protocol for my project using C/C++.
I also am using hoverboard motors so my velocity starts out and .25.
There is a lot of setup to my project and I have Calibrate my encoder each power up of the Odrive.
I also have to engage the drive.

Here’s my C/C++ code to go forward:

void ddod::on_forward_pushButton_pressed()
{
if(ui->avoidance_checkBox->isChecked()==true)
avoid_flag=true;
str_velocity=QString::number(velocity_bu);

// check to see if front wheel drive is engaged
if(ui->avoidance_checkBox->isChecked() == true)
{
       qDebug() <<  front;
     //   on_forward_pushButton_released();
}

if(front_wd_flag==true)
{
    motor0 = "v 1 ";
    motor1 = "v 0 ";

}
else{
motor0 = "v 0 ";
motor1 = "v 1 ";
}
if(odrv_1->isOpen() == true)
{
    motor0.append(str_velocity);
    motor0.append("\n");
    motor1.append("-");     //negative is needed to make motor1 go same direction as motor0
    motor1.append(str_velocity);
    motor1.append("\n");
    odrv_1->write(motor0);
    odrv_1->write(motor1);
}

}

I drive two hoverboard motors the same direction.

I have allowed for either front wheel drive or rear wheel drive.
I have found front wheel drive preferable.
The str_velocity starts at 0.25 which is plenty fast in my house.

Hope you can get some use out of my code.

Hi, thanks for sending that. I was looking for something in Python but I’m sure this can help. Thanks!

Found this on github, maybe it will help??