DcMotor
Last updated
Last updated
DcMotor is a fundamental component in FTC (FIRST Tech Challenge) robots, providing the essential power for various movements and actions. It's a direct current electric motor that converts electrical energy into mechanical energy.
CurrentPosition
Provides the current rotational position of a motor.
Key points:
Return Value: A floating point value in ticks.
Usage: Crucial for precise motor control, closed-loop control, and position-based actions.
Mode
Gets the mode of a motor.
Key points:
Return Value: RunMode. The four possible modes are RUN_WITHOUT_ENCODER, RUN_USING_ENCODER, RUN_TO_POSITION, and STOP_AND_RESET_ENCODER.
Usage: Crucial for precise motor control, closed-loop control, and position-based actions.
Power
Gets the power of a motor.
Key points:
Return value: A floating point value from -1.0 to 1.0
Usage: Used to check the power of a motor. Crucial for precise motor control.
PowerFloat
Determines if the power of a motor is a float number.
Key points:
Return value: True if motor power is not an integer, false otherwise.
Usage: Used to check if the power of a motor is a whole number. Crucial for precise motor control.
TargetPosition
Provides the target position of a motor.
Key points:
Return value: A floating point value in ticks
Usage: Used to check the target position of a motor. Crucial for precise motor control and autonomous driving.
TargetPositionTolerance
Provides the margin of error for the position of a motor. Not all motors have this feature.
Key points:
Return value: A floating point value in ticks
Usage: Used to check the tolerance of a motor. Crucial for precise motor control
Can’t find it? You will need to choose CurrentPosition or TargetPosition, then choose from the dropdown list.
Velocity
Provides the current velocity of a motor.
Key points:
Return value: The returned value is in ticks per second
Usage: Used to check the current velocity of a motor. Crucial for precise motor control and autonomous driving.
Can’t find it? You will need to choose CurrentPosition or TargetPosition, then choose from the dropdown list.
Direction
Provides the current direction of a motor.
Key points:
Return value: A string value of “FORWARD” or “REVERSE”.
FORWARD: The power the motor receives is unaltered.
REVERSE: The power the motor receives is multiplied by -1, reversing its sign.
Usage: Used to check the current direction of a motor.
ZeroPowerBehavior
Determines the behavior of a motor when its power is set to zero. The two possible values are BRAKE or FLOAT.
Key points:
Brake: When the motor's power is set to zero, the motor is braked, bringing it to a quick stop. Ideal for situations where you want the motor to stop quickly and hold its position. This is commonly used for mechanisms like arms or lifts.
Float: When the motor's power is set to zero, the motor coasts freely, allowing the motor's axle to rotate without generating torque. Suitable when you want the motor to coast freely after setting power to zero, allowing momentum to carry the mechanism. This can be useful for wheels or mechanisms where controlled deceleration is not required.
set DcMotor.Direction to
Controls the direction of the motor. The only directions are “FORWARD” or “REVERSE”
Key points:
FORWARD: The power the motor receives is unaltered.
REVERSE: The power the motor receives is multiplied by -1, reversing its sign.
Usage: To make setting and controlling the power to motors easier while programming and driving. This can be useful for wheels on a drivetrain where opposing motors need to spin opposite to each other to move in one direction.
set DcMotor.Power to
controls the power the motor receives, determining its speed and direction.
Key points:
Value range: Accepts a floating-point value between -1.0 and 1.0.
Direction: Positive values move the motor forward, negative values move it backward.
Magnitude: The absolute value of the power determines the motor's speed.
set DcMotor.TargetPosition to
Sets the target position of the motor.
Key points:
Value: A floating-point value in ticks.
Usage: A more precise method to control the position of the motor.
set DcMotor.TargetPositionTolerance to
Sets the target position tolerance of the motor.
Key points:
Value: A floating-point value in ticks.
Usage: Controls the margin of error of the motor.
Can’t find it? You will need to choose set TargetPosition, then choose from the dropdown list.
set DcMotor.Velocity to
sets the velocity of the motor. Not all motors support this feature.
Key points:
Value: A floating-point value in ticks per second.
Usage: Controls the speed of the motor more precisely.
Can’t find it? You will need to choose set TargetPosition, then choose from the dropdown list.
set DcMotor.Mode to
sets the mode of the motor. The four modes are RUN_WITHOUT_ENCODER, RUN_USING_ENCODER, RUN_TO_POSITION, and STOP_AND_RESET_ENCODER.
Key points:
DcMotor.RunMode.RUN_WITHOUT_ENCODER: This is the default mode. The motor runs at the specified power level without using encoder feedback. Suitable for basic open-loop control.
DcMotor.RunMode.RUN_USING_ENCODER: Uses encoder feedback to control motor speed. Allows for more precise speed control. Often used in conjunction with PID control.
DcMotor.RunMode.RUN_TO_POSITION: Runs the motor to a specified target position using encoder feedback. Ideal for precise positioning tasks.
DcMotor.RunMode.STOP_AND_RESET_ENCODER: Stops the motor and resets the encoder count to zero. Used to initialize the motor's position before starting a new movement.
set DcMotor.ZeroPowerBehavior to
Sets the state of a motor when its power is set to zero. The two possible values are BRAKE or FLOAT.
Key points:
Brake: When the motor's power is set to zero, the motor is actively braked, bringing it to a quick stop. Ideal for situations where you want the motor to stop quickly and hold its position. This is commonly used for mechanisms like arms or lifts.
Float: When the motor's power is set to zero, the motor coasts freely, allowing the motor's axle to rotate without generating torque. Suitable when you want the motor to coast freely after setting power to zero, allowing momentum to carry the mechanism. This can be useful for wheels or mechanisms where controlled deceleration is not required.
isBusy
Determines whether a motor has reached its target position.
Key points:
Returns: true if the motor is still moving towards its target position; false If the motor has reached its target position.
Usage: Commonly used in while loops to wait for a motor to complete its movement.
Purpose: Essential for synchronous motor control. Helps prevent unintended actions before the motor reaches its desired position.
Dual
This set of commands are commonly used to move a two motor drivetrain.
Power
Controls the power of two motors, determining its speed and direction.
Key points:
Value range: Accepts a floating-point value between -1.0 and 1.0.
Direction: Positive values move the motor forward, negative values move it backward.
Magnitude: The absolute value of the power determines the motor’s speed.
TargetPosition
Sets the target position of two motors.
Key points:
Value: A floating-point value in ticks.
Usage: A precise method to control the position of the motors.
TargetPositionTolerance
Sets the target position tolerance of two motors.
Key points:
Value: A floating-point value in ticks.
Usage: Controls the margin of error of the motors.
Can’t find it? You will need to choose the set TargetPosition block, then choose from the dropdown list.
Velocity
sets the velocity of two motors. Not all motors support this feature.
Key points:
Value: A floating-point value in ticks.per second
Usage: Controls the speed of the motors more precisely.
Can’t find it? You will need to choose the set TargetPosition block, then choose from the dropdown list.
Mode
Sets the mode of two motors. The four modes are RUN_WITHOUT_ENCODER, RUN_USING_ENCODER, RUN_TO_POSITION, and STOP_AND_RESET_ENCODER.
Key points:
DcMotor.RunMode.RUN_WITHOUT_ENCODER: This is the default mode. The motor runs at the specified power level without using encoder feedback. Suitable for basic open-loop control.
DcMotor.RunMode.RUN_USING_ENCODER: Uses encoder feedback to control motor speed. Allows for more precise speed control. Often used in conjunction with PID control.
DcMotor.RunMode.RUN_TO_POSITION: Runs the motor to a specified target position using encoder feedback. Ideal for precise positioning tasks.
DcMotor.RunMode.STOP_AND_RESET_ENCODER: Stops the motor and resets the encoder count to zero. Used to initialize the motor's position before starting a new movement.
ZeroPowerBehavior
Sets the state of two motors when their power is set to zero. The two possible values of Brake or Float.
Key points:
Brake: When the motor's power is set to zero, the motor is actively braked, bringing it to a quick stop. Ideal for situations where you want the motor to stop quickly and hold its position. This is commonly used for mechanisms like arms or lifts.
Float: When the motor's power is set to zero, the motor coasts freely, allowing the motor's axle to rotate without generating torque. Suitable when you want the motor to coast freely after setting power to zero, allowing momentum to carry the mechanism. This can be useful for wheels or mechanisms where controlled deceleration is not required.
Quad
This set of commands are commonly used to move a four motor drivetrain.
Power
Controls the power four motors receive, determining its speed and direction.
Key points:
Value range: Accepts a floating-point value between -1.0 and 1.0.
Direction: Positive values move the motor forward, negative values move it backward.
Magnitude: The absolute value of the power determines the motors’ speed.
TargetPosition
Sets the target position of four motors.
Key points:
Value: A floating-point value in ticks.
Usage: A more precise method to control the position of the motors.
TargetPositionTolerance
Sets the target position tolerance of four motors.
Key points:
Value: A floating-point value in ticks.
Usage: Controls the margin of error of the motors
Can’t find it? You will need to choose the set TargetPosition block, then choose from the dropdown list.
Velocity
Sets the velocity of four motors. Not all motors support this feature.
Key points:
Value: A floating-point value in ticks per second
Usage: Controls the speed of the motors more precisely.
Can’t find it? You will need to choose the set TargetPosition block, then choose from the dropdown list.
Mode
Sets the mode of four motors. The four modes are RUN_WITHOUT_ENCODER, RUN_USING_ENCODER, RUN_TO_POSITION, and STOP_AND_RESET_ENCODER.
Key points:
DcMotor.RunMode.RUN_WITHOUT_ENCODER: This is the default mode. The motor runs at the specified power level without using encoder feedback. Suitable for basic open-loop control.
DcMotor.RunMode.RUN_USING_ENCODER: Uses encoder feedback to control motor speed. Allows for more precise speed control. Often used in conjunction with PID control.
DcMotor.RunMode.RUN_TO_POSITION: Runs the motor to a specified target position using encoder feedback. Ideal for precise positioning tasks.
DcMotor.RunMode.STOP_AND_RESET_ENCODER: Stops the motor and resets the encoder count to zero. Used to initialize the motor's position before starting a new movement.
ZeroPowerBehavior
Sets the state of four motors when their power is set to zero. The two possible values are BRAKE or FLOAT.
Key points:
Brake: When the motor's power is set to zero, the motor is actively braked, bringing it to a quick stop. Ideal for situations where you want the motor to stop quickly and hold its position. This is commonly used for mechanisms like arms or lifts.
Float: When the motor's power is set to zero, the motor coasts freely, allowing the motor's axle to rotate without generating torque. Suitable when you want the motor to coast freely after setting power to zero, allowing momentum to carry the mechanism. This can be useful for wheels or mechanisms where controlled deceleration is not required.
Extended
More blocks for motors that are less commonly used. Nothing in this folder is implemented. DO NOT USE.