See our cheat sheet on how to use GitHub.
valInRange(float val, float threshold = 1.0)
- Tests if the the absolute value of the val parameter is less than the threshold and returns a boolean
- Threshold parameter default is 1.0
getEncoderAverage(int leftMotor, int rightMotor)
- Averages out the two paramters entered and returns a integer
- Failsafe if either left-side motor encoder or right-side motor encoder dies
setMotors(int left, int right)
- Sets the left-side drive motors to the first parameter entered and the right-side drive motors to the second parameter
stopMotors()
- Stops all of the drive motors
moveTo(int power, int deg, float threshold = 2.0, long time = 5000, float cor = 4.0)
- Moves the robot forward or backward the amount of degrees entered in the deg parameter at the power of the power parameter
- In order for the robot to move backward make the power and deg parameters negative
- The robot will correct its direction by changing motor speeds if the robot's drift in degrees gets out of the threshold parameter
- If the method runs for more than the time paratemeter the method will stop as a failsafe in case the encoders fail
turn(int power, int deg, int time = 5000)
- The robot will turn for the degrees given in the deg parameter on a point at the power of the power parameter
- The turn method only turns 45° and 90° currently
- If the method runs for more than the time parameter the method will stop for a failsafe if the gyro fails
arcTurn(int power, int deg, int time = 2000)
- Turns on one stopped motor for the degrees given in the deg parameter at the power of the power parameter
- The turn method only turns 45° and 90° currently
- If the method runs for more than the time parameter the method will stop for a failsafe in the gyro fails
getIR()
- Returns IR value
moveIrUp(int speed, int IR)
- Moves the robot until the IR value becomes greater then the IR parameter
moveIrDown(int speed, int IR)
- Moves the robot until the IR value becomes less then the IR parameter
sendArduinoCommand(unsigned char command)
- Send a command to the Arduino Pro Mini atMega via the hitechnic SuperPro
- Addition of the "HTSPBWriteStrobe" to the hitechnic-superpro.h file is necessary for this to work
- Commands available to send to the Arduino:
- Command = 1: Tell the arduino to blink its LED (mostly for debug)
- Command = 2: Tell Arduino to send current heading from the MPU6050 gyro
- Command = 3: Tell the Arduino to send raw acceleration on the x-axis
getMPUHeading()
- Reads and returns the current heading from the MPU6050
getMPUAccelX()
- Reads and returns the current x acceleration from the MPU6050