Skip to content

Commit 96be937

Browse files
committed
typo with dt isset
1 parent d597493 commit 96be937

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

src/common/base_classes/FOCMotor.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -485,30 +485,30 @@ void FOCMotor::updateTorqueControlType(TorqueControlType new_torque_controller)
485485
// - if changing to torque control set target to zero
486486
void FOCMotor::updateMotionControlType(MotionControlType new_motion_controller) {
487487
if (controller == new_motion_controller) return; // no change
488-
switch(new_motion_controller)
489-
{
490-
case MotionControlType::angle:
491-
if(controller != MotionControlType::angle_openloop) break;
492-
case MotionControlType::angle_openloop:
493-
if(controller != MotionControlType::angle) break;
494-
// if the previous controller was not angle control
495-
// set target to current angle
496-
target = shaft_angle;
497-
break;
498-
case MotionControlType::velocity:
499-
if(controller != MotionControlType::velocity_openloop) break;
500-
case MotionControlType::velocity_openloop:
501-
if(controller != MotionControlType::velocity) break;
502-
// if the previous controller was not velocity control
503-
// stop the motor
504-
target = 0;
505-
break;
506-
case MotionControlType::torque:
507-
// if torque control set target to zero
508-
target = 0;
509-
break;
510-
default:
511-
break;
488+
489+
switch(new_motion_controller){
490+
case MotionControlType::angle:
491+
if(controller == MotionControlType::angle_openloop) break;
492+
case MotionControlType::angle_openloop:
493+
if(controller == MotionControlType::angle) break;
494+
// if the previous controller was not angle control
495+
// set target to current angle
496+
target = shaft_angle;
497+
break;
498+
case MotionControlType::velocity:
499+
if(controller == MotionControlType::velocity_openloop) break;
500+
case MotionControlType::velocity_openloop:
501+
if(controller == MotionControlType::velocity) break;
502+
// if the previous controller was not velocity control
503+
// stop the motor
504+
target = 0;
505+
break;
506+
case MotionControlType::torque:
507+
// if torque control set target to zero
508+
target = 0;
509+
break;
510+
default:
511+
break;
512512
}
513513

514514
// finally set the new controller

src/common/lowpass_filter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ float LowPassFilter::operator() (float x)
1515
float dt = Ts;
1616
// if Ts is not set, use adaptive sampling time
1717
// calculate the ellapsed time dt
18-
if(_isset(dt)){
18+
if(!_isset(dt)){
1919
unsigned long timestamp = _micros();
2020
float dt = (timestamp - timestamp_prev)*1e-6f;
2121

src/common/pid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ float PIDController::operator() (float error){
2020
float dt = Ts;
2121
// if Ts is not set, use adaptive sampling time
2222
// calculate the ellapsed time dt
23-
if(_isset(dt)){
23+
if(!_isset(dt)){
2424
unsigned long timestamp_now = _micros();
2525
dt = (timestamp_now - timestamp_prev) * 1e-6f;
2626
// quick fix for strange cases (micros overflow)

0 commit comments

Comments
 (0)