servo support
This commit is contained in:
parent
4faf4986cf
commit
4e555f195f
3 changed files with 30 additions and 0 deletions
|
@ -95,6 +95,29 @@ void Robot::HandleKeyCode(int16_t keyCode)
|
||||||
case ENTER_SAVE:
|
case ENTER_SAVE:
|
||||||
chassis.SetTwist(0, 0);
|
chassis.SetTwist(0, 0);
|
||||||
break;
|
break;
|
||||||
|
case REWIND:
|
||||||
|
servo.setTargetPos(keyString.toInt());
|
||||||
|
Serial.println(keyString);
|
||||||
|
keyString = "";
|
||||||
|
break;
|
||||||
|
case NUM_1:
|
||||||
|
case NUM_2:
|
||||||
|
case NUM_3:
|
||||||
|
keyString += (char)(keyCode + 33);
|
||||||
|
break;
|
||||||
|
case NUM_4:
|
||||||
|
case NUM_5:
|
||||||
|
case NUM_6:
|
||||||
|
keyString += (char)(keyCode + 32);
|
||||||
|
break;
|
||||||
|
case NUM_7:
|
||||||
|
case NUM_8:
|
||||||
|
case NUM_9:
|
||||||
|
keyString += (char)(keyCode + 31);
|
||||||
|
break;
|
||||||
|
case NUM_0_10:
|
||||||
|
keyString += '0';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ void Robot::InitializeRobot(void)
|
||||||
|
|
||||||
// The line sensor elements default to INPUTs, but we'll initialize anyways, for completeness
|
// The line sensor elements default to INPUTs, but we'll initialize anyways, for completeness
|
||||||
lineSensor.Initialize();
|
lineSensor.Initialize();
|
||||||
|
|
||||||
|
servo.attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Robot::EnterIdleState(void)
|
void Robot::EnterIdleState(void)
|
||||||
|
@ -303,6 +305,8 @@ void Robot::RobotLoop(void)
|
||||||
* and asynchronous events (IR presses, distance readings, etc.).
|
* and asynchronous events (IR presses, distance readings, etc.).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
servo.update();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle any IR remote keypresses.
|
* Handle any IR remote keypresses.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <LineSensor.h>
|
#include <LineSensor.h>
|
||||||
#include <LSM6.h>
|
#include <LSM6.h>
|
||||||
#include <openmv.h>
|
#include <openmv.h>
|
||||||
|
#include <servo32u4.h>
|
||||||
|
|
||||||
static float apriltag_Kp = 0.043; // rads per second per pixel
|
static float apriltag_Kp = 0.043; // rads per second per pixel
|
||||||
static float lining_kP2 = 0.67;
|
static float lining_kP2 = 0.67;
|
||||||
|
@ -51,6 +52,8 @@ protected:
|
||||||
/* Line sensor */
|
/* Line sensor */
|
||||||
LineSensor lineSensor;
|
LineSensor lineSensor;
|
||||||
|
|
||||||
|
Servo32U4Pin5 servo;
|
||||||
|
|
||||||
/* To add later: rangefinder, camera, etc.*/
|
/* To add later: rangefinder, camera, etc.*/
|
||||||
uint16_t distanceTolerance = 65; //for width of tag
|
uint16_t distanceTolerance = 65; //for width of tag
|
||||||
#define CENTER_THRESHOLD 10
|
#define CENTER_THRESHOLD 10
|
||||||
|
|
Loading…
Reference in a new issue