Skip to content

Commit 1bc35a6

Browse files
committed
stop move and loopFOC on calibration only
1 parent c80c0df commit 1bc35a6

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/common/base_classes/FOCMotor.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -581,13 +581,15 @@ void FOCMotor::loopFOC() {
581581
// update loop time measurement
582582
updateLoopFOCTime();
583583

584+
// if initFOC is being executed at the moment, do nothing
585+
if(motor_status == FOCMotorStatus::motor_calibrating) return;
586+
584587
// update sensor - do this even in open-loop mode, as user may be switching between modes and we could lose track
585588
// of full rotations otherwise.
586589
if (sensor) sensor->update();
587590

588591
// if disabled do nothing
589-
// or if the motor is not ready (e.g. failed to calibrate or not calibrated yet) do nothing
590-
if(!enabled || motor_status != FOCMotorStatus::motor_ready) return;
592+
if(!enabled) return;
591593

592594
// if open-loop do nothing
593595
if( controller==MotionControlType::angle_openloop || controller==MotionControlType::velocity_openloop )
@@ -677,6 +679,9 @@ void FOCMotor::move(float new_target) {
677679
if(motion_cnt++ < motion_downsample) return;
678680
motion_cnt = 0;
679681

682+
// if initFOC is being executed at the moment, do nothing
683+
if(motor_status == FOCMotorStatus::motor_calibrating) return;
684+
680685
// calculate the elapsed time between the calls
681686
// TODO replace downsample by runnind the code at
682687
// a specific frequency (or almost)
@@ -700,7 +705,7 @@ void FOCMotor::move(float new_target) {
700705

701706
// if disabled do nothing
702707
// and if
703-
if(!enabled || motor_status != FOCMotorStatus::motor_ready) return;
708+
if(!enabled) return;
704709

705710

706711
// upgrade the current based voltage limit

0 commit comments

Comments
 (0)