-
Notifications
You must be signed in to change notification settings - Fork 0
move.h
Lukáš Dršman edited this page May 10, 2022
·
6 revisions
Contains compound movement functions for a dual-motor robot with a gyro sensor. Depends on base, pid and color.
-
NS_INI
- initial non-stop movement function -
NS_FIN
- finalizing non-stop movement function -
NS_MID
- non-stop functions between NS_INI and NS_FIN -
NS_STD
- standard function, not non-stop
-
FWD
- forwards movement, gets replaced with1
on compilation -
BWD
- forwards movement, gets replaced with-1
on compilation
-
FIX_SPEED
- angle correction rotation speed after NS_FIN or NS_STD function -
MIN_SPEED
- minimum rotation speed -
STEERING_MOD
- modifies the aggressiveness of steering when following lines
-
LBRW
- black line on the left, white line on the right -
LWRB
- white line on the left, black line on the right
void moveTimed(base b, int speed, double duration, pid *ctl, int direction, int fn_type);
- moves robot for
duration
seconds with PID control - Parameters:
-
base b
- base object -
int speed
- maximum speed -
double duration
- movement duration in seconds -
pid *ctl
- a pointer to apid
object (if PID object is namedfoo
, use&foo
as parameter) -
int direction
-FWD
for forwards movement,BWD
for backwards movement -
int fn_type
- see Function types
-
void moveColor(base b, int speed, color cs, double value, double delta, pid *ctl, int direction, int fn_type);
- moves robot until a color of a
value
withindelta
is reached - Parameters:
-
base b
- base object -
int speed
- maximum speed -
color cs
- color sensor object -
double value
- a grey scale value in % (~0% - black, ~100% - white) -
double delta
- an allowed difference between sensor reading andvalue
in % -
pid *ctl
- a pointer to apid
object (if PID object is namedfoo
, use&foo
as parameter) -
int direction
-FWD
for forwards movement,BWD
for backwards movement -
int fn_type
- see Function types
-
void moveLine(base b, int speed, color cs_f, color cs_s, double value, double delta, int course, int lf_mod, int direction, int fn_type);
- moves robot until a color of a
value
withindelta
is reached, following a line - Parameters:
-
base b
- base object -
int speed
- maximum speed -
color cs_f
- color sensor object for line following -
color cs_s
- color sensor object for function interruption -
double value
- a grey scale value in % (~0% - black, ~100% - white) -
double delta
- an allowed difference between sensor reading andvalue
in % -
int course
- the final orientation of the robot -
int lf_mod
- see Line following modifiers -
int direction
-FWD
for forwards movement,BWD
for backwards movement -
int fn_type
- see Function types
-
void rotate(base b, int target, int speed);
- rotates the robot around its own axis
- Parameters:
-
base b
- base object -
int target
- target angle -
int speed
- maximum speed
-
int modSpeed(double target, double angle, double speed);
- returns speed for rotation function based on the difference of the target angle and (current) angle
- Parameters:
-
double target
- target angle -
double angle
- current angle -
double speed
- maximum speed
-