Class MotorTank. API for working with two motors together. More...
#include <ev3cxx_motor_tank.h>
Public Member Functions | |
MotorTank (MotorPort left_motor_port, MotorPort right_motor_port, MotorType type=MotorType::LARGE) | |
Constructor of class MotorTank. More... | |
void | off (bool brake=true) |
Stop motors. More... | |
void | on (int left_speed=50, int right_speed=50) |
Set speed on regulated motors. More... | |
void | unregulated (int left_power=50, int right_power=50) |
Set power on unregulated motors. More... | |
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. More... | |
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. More... | |
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. More... | |
void | resetPosition () |
Reset the angular position of the motors to zero. More... | |
Motor & | leftMotor () |
Return reference to the left motor. More... | |
const Motor & | leftMotor () const |
Return const reference to the left motor. More... | |
Motor & | rightMotor () |
Return reference to the right motor. More... | |
const Motor & | rightMotor () const |
Return const reference to the right motor. More... | |
Private Attributes | |
Motor | m_left_motor |
Motor | m_right_motor |
Additional Inherited Members | |
Static Public Attributes inherited from MotorConstants | |
static const int | POWER_MAX = 100 |
Max power on motor. | |
static const int | POWER_MIN = -100 |
Min power on motor. | |
static constexpr float | NUMBER_OF_DEGREES_PER_ROTATION = 360.0 |
Class MotorTank. API for working with two motors together.
Definition at line 17 of file ev3cxx_motor_tank.h.
|
inline |
Constructor of class MotorTank.
left_motor_port | Port number |
right_motor_port | Port number |
type | Type of motor ports: motor_type_t |
Definition at line 31 of file ev3cxx_motor_tank.h.
|
inline |
Return reference to the left motor.
Definition at line 148 of file ev3cxx_motor_tank.h.
|
inline |
Return const reference to the left motor.
Definition at line 155 of file ev3cxx_motor_tank.h.
|
inline |
Stop motors.
Set the motors power or speed to 0 and depending on param brake will brake the motors.
brake | Start braking the motors (true = braking, false = not braking). Default value is true. |
Definition at line 42 of file ev3cxx_motor_tank.h.
References Motor::off().
Referenced by MotorTank::onForSeconds().
|
inline |
Set speed on regulated motors.
Using regulated motors driver (motors should has constant speed) and param power is equivalent to speed. Motor controls real power to keep constant speed.
left_speed | Left motor speed. Range: -100 to +100. A negative value turns the wheel backwards. Default value is 50. If a out-of-range value is given, it will be clipped to the minimum (-100) or maximum (100) value. |
right_speed | Right motor speed. Range: -100 to +100. A negative value turns the wheel backwards. Default value is 50. If a out-of-range value is given, it will be clipped to the minimum (-100) or maximum (100) value. |
Definition at line 57 of file ev3cxx_motor_tank.h.
References Motor::on().
Referenced by MotorTank::onForSeconds().
|
inline |
Set number of degrees to rotate with regulated motors.
left_speed | Left motor speed. Range: -100 to +100. Default value is 50. |
right_speed | Right motor speed. Range: -100 to +100. Default value is 50. |
degrees | Number of degrees for rotation of the forward or faster motor. Default value is 360. |
brake | If true, then motor start braking after reach the position (= degrees). |
blocking | true (The function will be blocked until the move is finished), or false (The function will not be blocked). Default value is false. |
wait_after_ms | Adds wait after the function executes. Default wait is 60 ms. It is important because of some race condition when another motor rotation follows immediately |
Definition at line 88 of file ev3cxx_motor_tank.h.
References Motor::onForDegrees().
Referenced by MotorTank::onForRotations().
|
inline |
Set number of rotations to rotate with regulated motors.
left_speed | Left motor speed. Range: -100 to +100. Default value is 50. |
right_speed | Right motor speed. Range: -100 to +100. Default value is 50. |
rotations | Number of rotations for rotation of the forward or faster motor. Default value is 1. |
brake | If true, then motor start braking after reach the position (= degrees). |
blocking | true (The function will be blocked until the move is finished), or false (The function will not be blocked). Default value is false. |
wait_after_ms | Adds wait after the function executes. Default wait is 60 ms. It is important because of some race condition when another motor rotation follows immediately |
Definition at line 114 of file ev3cxx_motor_tank.h.
References MotorTank::onForDegrees().
|
inline |
Rotates the motor for a given time.
left_speed | Speed of left motor. Range: -100 to +100. Default value is 50. |
right_speed | Speed of right motor. Range: -100 to +100. Default value is 50. |
ms | Number of miliseconds for rotate with motor. Default value is 1000. |
brake | If true, then motor start braking after reach the position (= degrees). |
Definition at line 126 of file ev3cxx_motor_tank.h.
References MotorTank::off(), and MotorTank::on().
|
inline |
Reset the angular position of the motors to zero.
Setting the value of the angular position sensor of the motor does not affect the actual power and position of the motor.
Definition at line 137 of file ev3cxx_motor_tank.h.
References Motor::resetPosition().
|
inline |
Return reference to the right motor.
Definition at line 162 of file ev3cxx_motor_tank.h.
|
inline |
Return const reference to the right motor.
Definition at line 169 of file ev3cxx_motor_tank.h.
|
inline |
Set power on unregulated motors.
Motors work with constant power, NOT speed. Speed changes depend on load.
left_power | Left motor power. Range: -100 to +100. A negative value turns the wheel backwards. Default value is 50. If a out-of-range value is given, it will be clipped to the minimum (-100) or maximum (100) value. |
right_power | Right motor power. Range: -100 to +100. A negative value turns the wheel backwards. Default value is 50. If a out-of-range value is given, it will be clipped to the minimum (-100) or maximum (100) value. |
Definition at line 71 of file ev3cxx_motor_tank.h.
References Motor::unregulated().