32 : m_left_motor(left_motor_port, type),
33 m_right_motor(right_motor_port, type)
42 void off(
bool brake =
true) {
43 m_left_motor.
off(brake);
44 m_right_motor.
off(brake);
57 void on(
int left_speed = 50,
int right_speed = 50) {
58 m_left_motor.
on(left_speed);
59 m_right_motor.
on(right_speed);
88 void onForDegrees(
int left_speed = 50,
int right_speed = 50,
int degrees = 360, bool_t brake =
true, bool_t blocking =
true,
unsigned int wait_after_ms = 60) {
89 int labs = abs(left_speed);
90 int rabs = abs(right_speed);
92 const float sr = float(rabs) / float(labs);
93 m_right_motor.
onForDegrees(right_speed, degrees * sr, brake,
false, 0);
94 m_left_motor.
onForDegrees (left_speed, degrees, brake, blocking, wait_after_ms);
96 const float sr = rabs != 0 ? float(labs) / float(rabs) : 0;
97 m_left_motor.
onForDegrees (left_speed, degrees * sr, brake,
false, 0);
98 m_right_motor.
onForDegrees(right_speed, degrees, brake, blocking, wait_after_ms);
114 void onForRotations(
int left_speed = 50,
int right_speed = 50,
float rotations = 1, bool_t brake =
true, bool_t blocking =
true,
unsigned int wait_after_ms = 60) {
115 onForDegrees(left_speed, right_speed, rotations * NUMBER_OF_DEGREES_PER_ROTATION, brake, blocking, wait_after_ms);
126 void onForSeconds(
int left_speed = 50,
int right_speed = 50,
unsigned int time_ms = 1000, bool_t brake =
true) {
127 on(left_speed, right_speed);
Motor & leftMotor()
Return reference to the left motor.
void unregulated(int power=50)
Set power on unregulated motor. [TODO: fix - same behavior as on() -> problem in EV3RT].
MotorTank(MotorPort left_motor_port, MotorPort right_motor_port, MotorType type=MotorType::LARGE)
Constructor of class MotorTank.
EV3RT CPP API for motors.
const Motor & rightMotor() const
Return const reference to the right motor.
Class Motor. API for working with motor.
void resetPosition()
Reset the angular position of the motors to zero.
MotorType
Enum with index of motor type.
void on(int power=50)
Set speed on regulated motor.
void on(int left_speed=50, int right_speed=50)
Set speed on regulated motors.
void unregulated(int left_power=50, int right_power=50)
Set power on unregulated motors.
MotorPort
Enum with index of motor port (A - D)
const Motor & leftMotor() const
Return const reference to the left motor.
Motor & rightMotor()
Return reference to the right motor.
void resetPosition()
Reset the angular position of the motor to zero.
Class MotorTank. API for working with two motors together.
void onForSeconds(int left_speed=50, int right_speed=50, unsigned int time_ms=1000, bool_t brake=true)
Rotates the motor for a given time.
void off(bool brake=true)
Stop motors.
void off(bool brake=true)
Stop motor.
void onForDegrees(int left_speed=50, int right_speed=50, int degrees=360, bool_t brake=true, bool_t blocking=true, unsigned int wait_after_ms=60)
Set number of degrees to rotate with regulated motors.
void onForRotations(int left_speed=50, int right_speed=50, float rotations=1, bool_t brake=true, bool_t blocking=true, unsigned int wait_after_ms=60)
Set number of rotations to rotate with regulated motors.
void onForDegrees(int speed=50, int degrees=360, bool_t brake=true, bool_t blocking=true, unsigned int wait_after_ms=60)
Set number of degrees to rotate with regulated motor.