Skip to content

Commit e5c6ec1

Browse files
committed
isPositionReached() is now exposed in AlvikCarrier class
1 parent d51412b commit e5c6ec1

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/Arduino_AlvikCarrier.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ float Arduino_AlvikCarrier::getPositionLeft(){
362362
return motor_control_left->getPosition();
363363
}
364364

365+
bool Arduino_AlvikCarrier::isPositionLeftReached(){
366+
return motor_control_left->isPositionReached();
367+
}
368+
365369
void Arduino_AlvikCarrier::setPositionRight(const float degrees){
366370
motor_control_right->setPosition(degrees);
367371
}
@@ -370,6 +374,10 @@ float Arduino_AlvikCarrier::getPositionRight(){
370374
return motor_control_right->getPosition();
371375
}
372376

377+
bool Arduino_AlvikCarrier::isPositionRightReached(){
378+
return motor_control_right->isPositionReached();
379+
}
380+
373381
void Arduino_AlvikCarrier::setPosition(const float left_deg, const float right_deg){
374382
setPositionLeft(left_deg);
375383
setPositionRight(right_deg);
@@ -380,6 +388,10 @@ void Arduino_AlvikCarrier::getPosition(float & left_deg, float & right_deg){
380388
right_deg = getPositionRight();
381389
}
382390

391+
bool Arduino_AlvikCarrier::isPositionReached(){
392+
return isPositionLeftReached() && isPositionRightReached();
393+
}
394+
383395
void Arduino_AlvikCarrier::resetPositionLeft(const float initial_position){
384396
motor_control_left->resetPosition(initial_position);
385397
}

src/Arduino_AlvikCarrier.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,13 @@ class Arduino_AlvikCarrier{
172172
void setKPidRight(const float kp, const float ki, const float kd); // set PID parameters for right wheel
173173
void setPositionLeft(const float degrees); // set position in degrees on left wheel
174174
float getPositionLeft(); // get left wheel position in degrees
175+
bool isPositionLeftReached(); // return true if left wheel position is reached
175176
void setPositionRight(const float degrees); // set position in degrees on right wheel
176177
float getPositionRight(); // get right wheel position in degrees
178+
bool isPositionRightReached(); // return true if right wheel position is reached
177179
void setPosition(const float left_deg, const float right_deg); // set positions on both wheels
178180
void getPosition(float & left_deg, float & right_deg); // get both wheels position
181+
bool isPositionReached(); // return true if both wheels position are reached
179182
void resetPositionLeft(const float initial_position=0.0); // reset/set value of position for left wheel
180183
void resetPositionRight(const float initial_position=0.0); // reset/set value of position for right wheel
181184
void disablePositionControlLeft(); // disable the position control on left wheel

src/definitions/robot_definitions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ const float MOTOR_RATIO = MOTOR_CPR*MOTOR_GEAR_RATIO;
5959
#define MOVEMENT_DISABLED 0
6060
#define MOVEMENT_ROTATE 1
6161
#define MOVEMENT_MOVE 2
62+
#define MOVEMENT_LEFT 3
63+
#define MOVEMENT_RIGHT 4
64+
#define MOVEMENT_POSITION 5
6265

6366

6467
#define LIFT_THRESHOLD 80

0 commit comments

Comments
 (0)