-
Notifications
You must be signed in to change notification settings - Fork 0
base.h
Lukáš Dršman edited this page May 10, 2022
·
2 revisions
Contains basic functions to control dual-motor robot with a gyroscopic sensor.
The struct type for dual-motor robot base is defined as
typedef struct Base
{
motor lmotor, rmotor;
sensor gyro;
}
base;
consisting of left and right motors (lmotor
and rmotor
respectively), and a gyroscopic sensor (gyro
) fields. These are all defined in src/drivers/
.
The constructor for base
is defined as
base baseNew(char lport, char rport, char gyroport);
taking three ports in a character format, each corresponding to the designated motor/sensor.
For example, if the robot has its
- left motor connected port A,
- right motor connected port D,
- gyro sensor connected port 1,
the corresponding base
would be constructed using
base foo;
foo = baseNew('A', 'D', '1');
void baseResetGyro(base b);
- resets the gyroscope, defined on
base b
- Parameters:
-
base b
- base object
-
void baseRunTank(base b, int lspeed, int rspeed);
- sets individual speeds of the motors, defined on
base b
- Parameters:
-
base b
- base object -
int lspeed
- left motor speed -
int rspeed
- right motor speed
-
void baseRunSteering(base b, double speed, double x, int direction);
- compound control of motor speeds using steering parameter
- Parameters:
-
base b
- base object -
double speed
- maximum motor speed -
double x
- steering parameter, modifies the motor speed ration -
int direction
-FWD
for forwards movement,BWD
for backwards movement (FWD and BWD are defined inmove.h
. When using onlybase.h
,1
and-1
respectively can be used instead)
-
void baseStop(base b);
- stops motors, defined on
base b
- Parameters:
-
base b
- base object
-
double timeSeconds(void);
- measures time in seconds with a nanosecond precision
- Parameters: N/A