DcMotor.getDirection() returns curr logical direction in which this motor is set as operating
DcMotor.setDirection(DcMotorSimple.Direction direction) sets the logical direction in which this motor operates
DcMotor.setPower(double power) sets the pwr level of the motor, expressed as a fraction of the max possible pwr/speed supported according to the run mode in which the motor is operating
DcMotor.setMode(DcMotor.RunMode mode) sets the curr run mode for this motor
The run mode of a motor DcMotor.RunMode controls how the motor interprets the it's parameter settings passed through power- and encoder-related methods. Some of these modes internally use PID control to achieve their function, while others do not. Those that do are referred to as "PID modes".
--------------------------------------------------------------------------------------------------------------------
Deprecated.
Use STOP_AND_RESET_ENCODER instead
The motor is to set the current encoder position to zero.
From video: STOP_AND_RESET_ENCODER just resets the encoder value to zero
--------------------------------------------------------------------------------------------------------------------
The motor is to attempt to rotate in whatever direction is necessary to cause the encoder reading to advance or retreat from its current setting to the setting which has been provided through the setTargetPosition() method.
From video: RUN_TO_POSITION allows you to set a target position that the motor will automatically go to and hold its position there
void setTargetPosition(int position)
Sets the desired encoder target position to which the motor should advance or retreat and then actively hold thereat. This behavior is similar to the operation of a servo. The maximum speed at which this advance or retreat occurs is governed by the power level currently set on the motor. While the motor is advancing or retreating to the desired target position, isBusy() will return true.
Note that adjustment to a target position is only effective when the motor is in RUN_TO_POSITION RunMode. Note further that, clearly, the motor must be equipped with an encoder in order for this mode to function properly.
Parameters:
position - the desired encoder target position
See Also:
getCurrentPosition(), setMode(RunMode), DcMotor.RunMode.RUN_TO_POSITION, getTargetPosition(), isBusy()
----------------------------------------------
int getTargetPosition()
Returns the current target encoder position for this motor.
Returns:
the current target encoder position for this motor.
See Also:
----------------------------------------------
int getCurrentPosition()
Returns the current reading of the encoder for this motor. The units for this reading, that is, the number of ticks per revolution, are specific to the motor/encoder in question, and thus are not specified here.
Returns:
the current reading of the encoder for this motor
See Also:
getTargetPosition(), DcMotor.RunMode.STOP_AND_RESET_ENCODER
--------------------------------------------------------------------------------------------------------------------
Deprecated.
Use RUN_USING_ENCODER instead
The motor is to do its best to run at targeted velocity.
From video: RUN_USING_ENCODER lets you set the speed of the motors. It will look at the encoder values and use a pid loop to make sure that it is traveling at the right speed
--------------------------------------------------------------------------------------------------------------------
Deprecated.
Use RUN_WITHOUT_ENCODER instead
The motor is simply to run at whatever velocity is achieved by apply a particular power level to the motor.
From video: RUN_WITHOUT_ENCODER lets you directory set the motor power without looking at the encoder, however, it still keeps track of the encoder value
--------------------------------------------------------------------------------------------------------------------
void setZeroPowerBehavior(DcMotor.ZeroPowerBehavior zeroPowerBehavior)
Sets the behavior of the motor when a power level of zero is applied.
Parameters:
zeroPowerBehavior - the new behavior of the motor when a power level of zero is applied.
See Also:
DcMotor.ZeroPowerBehavior, DcMotorSimple.setPower(double)
Following are the ZeroPowerBehavior choices:
The motor stops and then brakes, actively resisting any external force which attempts to turn the motor.
The motor stops and then floats: an external force attempting to turn the motor is not met with active resistence.
The behavior of the motor when zero power is applied is not currently known.
-----------------------------------------------
Working with the Encoders:
Read the following!!! https://ftc-tricks.com/dc-motors/
If we want to reset the encoder back to zero, we can do that:
arm_motor.setMode(DcMotor.RunMode.STOP_AND_RESET_ENCODER);
arm_motor.setMode(DcMotor.RunMode.RUN_WITHOUT_ENCODER);
Note that we’re setting the RunMode back to RUN_WITHOUT_ENCODER after the reset. Unless you’re doing something special (see Run to Position below), this is probably the mode you want to be in during normal operation. It’s also the default mode.
(From video: It recommends that you use the encoders)
The reason it recommends you use encoders is if you tested with a fully charged battery and use full power, it will go a certain speed for the specified time period. However, if later you have battery that is undercharged, the motors won't be getting as much power, so the motors won't be going as fast, so the robot won't travel as far for the same time period that you specified that the motors run previously, so it will be INCONSISTENT and you will not consistently hit your target.
With encoders, the motors don't care about the battery charge since we're directly measuring the distance we've travelled
---------------------------------------------------------
Example:
// First reset the encoders. IMPORTANT, in this STOP_AND_RESET_ENCODER
// RunMode, you cannot set power to the motors!!! So you must set it to
// another RunMode prior to setting power to the motors.
motor.setMode(DcMotorController.RunMode.STOP_AND_RESET_ENCODER);
// Then set the target position for the motors to run to (NOTE: it will not actually
// move to that distance until you set the RunMode to RUN_TO_POSITION and
// then apply power to the motors.
motor.setTargetPosition( distance );
// if you want to drive forward a certain distance, use the RUN_TO_POSITION mode
motor.setMode(DcMotorController.RunMode.RUN_TO_POSITION);
// Then apply power to the motors
motor.setPower(1);
--------------------------------------------------------------------------------------------------------------------
ANDYMARK NEVERRESET motors have 1120 ticks per revolution
--------------------------------------------------------------------------------------------------------------------
TankMechanumControlScheme
An Andymark 40 native spin direction is counterclockwise