Here is the whole code
#include "robot-config.h"
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VCS VEX V5 */
/* */
/*---------------------------------------------------------------------------*/
//Creates a competition object that allows access to Competition methods.
vex::competition Competition;
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
void pre_auton( void ) {
Dr.setVelocity(100,velocityUnits::pct);
Dl.setVelocity(100,velocityUnits::pct;)
Bl.setVelocity(100,velocityUnits::pct);
Bl.setMaxTorque(50,percentUnits::pct);
Dr.setMaxTorque(127,percentUnits::pct);
Dl.setMaxTorque(127,percentUnits::pct);
Cll.setVelocity(90,velocityUnits::pct);
Clr.setVelocity(90,velocityUnits::pct);
Cll.setMaxTorque(127,percentUnits::pct);
Clr.setMaxTorque(127,percentUnits::pct);
Fwl.setVelocity(127,velocityUnits::pct);
Fwr.setVelocity(127,velocityUnits::pct);
Lss.setVelocity(50,velocityUnits::pct);
Lss.setMaxTorque(127,percentUnits::pct);
//set speed
}
/*---------------------------------------------------------------------------*/
/* */
/* Autonomous Task */
/* */
/* This task is used to control your robot during the autonomous phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*---------------------------------------------------------------------------*/
void autonomous( void ) {
// ..........................................................................
// empty...
// ..........................................................................
}
/*----------------------------------------------------------------------------*/
/* */
/* User Control Task */
/* */
/* This task is used to control your robot during the user control phase of */
/* a VEX Competition. */
/* */
/* You must modify the code to add your own robot specific commands here. */
/*----------------------------------------------------------------------------*/
void usercontrol( void ) {
// User control code here, inside the loop
while (1){
Dr.setVelocity(0.6*(Controller1.Axis1.position(percentUnits::pct))+1.5*(Controller1.Axis2.position(percentUnits::pct)),velocityUnits::rpm);
Dl.setVelocity(0.6*(Controller1.Axis1.position(percentUnits::pct))-1.5*(Controller1.Axis2.position(percentUnits::pct)),velocityUnits::rpm);
Dr.spin(directionType::fwd);
Dl.spin(directionType::fwd);
if(Controller1.ButtonR1.pressing()){
Fwl.spin(directionType::rev);
Fwr.spin(directionType::fwd);
}else{
if(Controller1.ButtonR2.pressing()){
Fwl.spin(directionType::fwd);
Fwr.spin(directionType::rev);
}else{
Fwl.stop();
Fwr.stop();
}
}
if(Controller1.ButtonL1.pressing()){
Cll.spin(directionType::fwd);
Clr.spin(directionType::rev);
}else{
if(Controller1.ButtonL2.pressing()){
Cll.spin(directionType::rev);
Clr.spin(directionType::fwd);
}else{
Cll.stop();
Clr.stop();
}
}
if(Controller1.ButtonLeft.pressing()){
Bl.rotateFor(-840,rotationUnits::deg);
}else{
if(Controller1.ButtonRight.pressing()){
Bl.rotateFor(-420,rotationUnits::deg);
}else{
Bl.stop();
}
}
if(Controller1.ButtonUp.pressing()){
Lss.rotateTo(900,rotationUnits::deg);
}else{
if(Controller1.ButtonDown.pressing()){
Lss.rotateTo(675,rotationUnits::deg);
}else{
if(Controller1.ButtonX.pressing{
Lss.rotateTo(0,rotationUnits::deg);
}else{
Lss.stop();
}
}
}
vex::task::sleep(20); //Sleep the task for a short amount of time to prevent wasted resources.
}
//
// Main will set up the competition functions and callbacks.
//
int main() {
//Run the pre-autonomous function.
pre_auton();
//Set up callbacks for autonomous and driver control periods.
Competition.autonomous( autonomous );
Competition.drivercontrol( usercontrol );
//Prevent main from exiting with an infinite loop.
while(1) {
vex::task::sleep(100);//Sleep the task for a short amount of time to prevent wasted resources.
}
}
2018年11月29日星期四
订阅:
博文评论 (Atom)
The last Humangeo class
Ok... it is really sad to say goodbye, but the good thing is we can still meet in the School! I have a Robotic competition this Sunday and ...
-
today we saw a lot of population pyramids and learnt about how to decide this is a developing country or a developed country. And I check ...
-
Population Ratio Defined as the number of the males per 100 females in the population. Developed countries have more females than males t...
-
Total Fertility Rate(TFR) TFR: average number of children born per woman for a population to remain the same, the TFR must be 2.1 higher ...
没有评论:
发表评论