Improved max vellocity
This commit is contained in:
parent
edf2df6c7e
commit
4223961fe7
@ -3,7 +3,7 @@
|
||||
#include "LinearAlgebra/FloatSingle.h"
|
||||
|
||||
ServoMotor::ServoMotor()
|
||||
: Thing(0) { // for now, id should be set properly later
|
||||
: Thing(0) { // for now, id should be set properly later
|
||||
this->type = Thing::ServoType;
|
||||
this->controlMode = ControlMode::Position;
|
||||
this->targetAngle = 0;
|
||||
@ -18,7 +18,7 @@ void ServoMotor::SetTargetAngle(float angle) {
|
||||
this->limitedTargetAngle = angle;
|
||||
} else if (angle != this->targetAngle) {
|
||||
// if the new target is the same, the limited angle is not overwritten
|
||||
this->limitedTargetAngle = this->targetAngle;
|
||||
// this->limitedTargetAngle = this->targetAngle;
|
||||
}
|
||||
|
||||
this->controlMode = ControlMode::Position;
|
||||
@ -26,7 +26,9 @@ void ServoMotor::SetTargetAngle(float angle) {
|
||||
this->hasTargetAngle = true;
|
||||
}
|
||||
|
||||
float ServoMotor::GetTargetAngle() { return this->targetAngle; }
|
||||
float ServoMotor::GetTargetAngle() {
|
||||
return this->targetAngle;
|
||||
}
|
||||
|
||||
void ServoMotor::SetMaximumVelocity(float maxVelocity) {
|
||||
this->maxVelocity = maxVelocity;
|
||||
@ -38,16 +40,18 @@ void ServoMotor::SetTargetVelocity(float targetVelocity) {
|
||||
|
||||
this->controlMode = ControlMode::Velocity;
|
||||
this->targetVelocity = targetVelocity;
|
||||
this->hasTargetAngle = false; // can't we use the controlMode for this?
|
||||
this->hasTargetAngle = false; // can't we use the controlMode for this?
|
||||
}
|
||||
|
||||
float ServoMotor::GetTargetVelocity() { return this->targetVelocity; }
|
||||
float ServoMotor::GetTargetVelocity() {
|
||||
return this->targetVelocity;
|
||||
}
|
||||
|
||||
void ServoMotor::Update(unsigned long currentTimeMs) {
|
||||
for (unsigned char childIx = 0; childIx < this->childCount; childIx++) {
|
||||
Thing *child = this->GetChild(childIx);
|
||||
Thing* child = this->GetChild(childIx);
|
||||
if (child != nullptr && child->type == Thing::ServoType) {
|
||||
ServoMotor *servo = (ServoMotor *)child;
|
||||
ServoMotor* servo = (ServoMotor*)child;
|
||||
servo->Update(currentTimeMs);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user