Definitions of API for controlling motors.
More...
Definitions of API for controlling motors.
ID for supported motor ports.
Enumerator |
---|
EV3_PORT_A |
Port A.
|
EV3_PORT_B |
Port B.
|
EV3_PORT_C |
Port C.
|
EV3_PORT_D |
Port D.
|
TNUM_MOTOR_PORT |
Number of motor ports.
|
Enumeration type for supported motor types.
Enumerator |
---|
NONE_MOTOR |
Not connected.
|
MEDIUM_MOTOR |
Medium servo motor.
|
LARGE_MOTOR |
Large servo motor.
|
UNREGULATED_MOTOR |
Unregulated motor.
|
TNUM_MOTOR_TYPE |
Number of motor types.
|
Configure a motor port.
Set the type of motor connected to the motor port. You can also specify a new motor type even if you have already set it.
- Parameters
-
port | Motor port to be configured |
type | Motor type for the specified motor port |
- Return values
-
E_OK | Successful completion |
E_ID | Illegal motor port number |
E_PAR | Illegal motor type |
Get the angular position of a motor port.
When an incorrect motor port number is specified, it always returns 0.
- Parameters
-
port | Motor port to be inquired |
- Returns
- Angular position in degrees. A negative value means the motor rotate has rotated backwards. [TODO: number of degrees per one revolution of motor]
Get the actual power of a motor port.
When an incorrect motor port number is specified, it always returns 0.
- Parameters
-
- Returns
- Motor power [TODO: range?]
Get the type of a motor port.
- Parameters
-
port | Motor port to be inquired |
- Return values
-
>=0 | Motor type of specified motor port |
E_ID | Illegal motor port number |
Reset the angular position of the motor to zero.
Setting the value of the angular position sensor of the motor does not affect the actual power and position of the motor.
- Parameters
-
port | Motor port to be inquired |
- Return values
-
E_OK | Successful completion |
E_ID | Illegal motor port number |
E_OBJ | Motor port has not been initialized. |
ER ev3_motor_rotate |
( |
motor_port_t |
port, |
|
|
int |
degrees, |
|
|
uint32_t |
speed_abs, |
|
|
bool_t |
blocking |
|
) |
| |
Rotate a motor port for specified degrees.
- Parameters
-
port | Motor port to be rotated |
degrees | Degrees to be rotated. A negative value makes the motor rotate backwards. |
speed_abs | Speed for rotating. The value is a percentage of full speed, ranging from 0 to +100. |
blocking | true (The function will be blocked until the rotation is finished), or false (The function will not be blocked). |
- Return values
-
E_OK | Successful completion |
E_ID | Illegal motor port number |
E_OBJ | Motor port has not been initialized. |
Set the unregulated power for a motor port.
- Parameters
-
port | Motor port to be set |
power | The percentage of full power, ranging from -100 to +100. A negative value makes the motor rotate backwards. |
- Return values
-
E_OK | Successful completion |
E_ID | Illegal motor port number |
E_OBJ | Motor port has not been initialized. |
Start the motor
Move the robot along a curved path using two motors.
- Parameters
-
left_motor | ID of the left motor port |
right_motor | ID of the right motor port |
power | Power of motors. Range: -100 to +100. A negative value moves the robot backwards. |
turn_ratio | The sharpness of the turn. Range: -100 to +100. If turn_ratio is negative, the robot will turn left. If turn_ratio is positive, the robot will turn right. More specifically, turn_ratio determines the ratio of inner wheel speed as a percent. For example, if turn_ratio is +25, the right motor will move at 75% of the power, which makes the robot turn right. |
- Return values
-
E_OK | Success |
E_ID | Invalid ID of motor port |
E_OBJ | Motor port has not been initialized. |
Stop a motor port.
- Parameters
-
port | Motor port to be stopped |
brake | Brake mode, true for braking, false for coasting. |
- Return values
-
E_OK | Successful completion |
E_ID | Illegal motor port number |
E_OBJ | Motor port has not been initialized. |