mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-02-08 16:31:52 +08:00
Added position getter function for arduino
Added GetPosition function in ODriveArduino file to accompany the existing GetVelocity function. Changed arduino example file to demonstrate usage over previous verbose implementation.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "ODriveArduino.h"
|
||||
|
||||
@@ -42,7 +41,7 @@ void ODriveArduino::SetCurrent(int motor_number, float current) {
|
||||
serial_ << "c " << motor_number << " " << current << "\n";
|
||||
}
|
||||
|
||||
void ODriveArduino::TrapezoidalMove(int motor_number, float position){
|
||||
void ODriveArduino::TrapezoidalMove(int motor_number, float position) {
|
||||
serial_ << "t " << motor_number << " " << position << "\n";
|
||||
}
|
||||
|
||||
@@ -50,11 +49,16 @@ float ODriveArduino::readFloat() {
|
||||
return readString().toFloat();
|
||||
}
|
||||
|
||||
float ODriveArduino::GetVelocity(int motor_number){
|
||||
float ODriveArduino::GetVelocity(int motor_number) {
|
||||
serial_<< "r axis" << motor_number << ".encoder.vel_estimate\n";
|
||||
return ODriveArduino::readFloat();
|
||||
}
|
||||
|
||||
float ODriveArduino::GetPosition(int motor_number) {
|
||||
serial_ << "r axis" << motor_number << ".encoder.pos_estimate\n";
|
||||
return ODriveArduino::readFloat();
|
||||
}
|
||||
|
||||
int32_t ODriveArduino::readInt() {
|
||||
return readString().toInt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user