Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none) #pragma config(Hubs, S2, HTMotor, none, none, none) #pragma config(Motor, motorA, , tmotorNormal, openLoop) #pragma config(Motor, motorB, , tmotorNormal, openLoop) #pragma config(Motor, motorC, , tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_1, motorD, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C1_2, motorE, tmotorNormal, openLoop) #pragma config(Motor, mtr_S1_C2_1, motorF, tmotorNormal, openLoop, reversed) #pragma config(Motor, mtr_S1_C2_2, motorG, tmotorNormal, openLoop) #pragma config(Motor, mtr_S2_C1_1, motorH, tmotorNormal, openLoop) #pragma config(Motor, mtr_S2_C1_2, motorI, tmotorNormal, openLoop) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
///////////////////////////////////////////////////////////////////////////////////////////////////// // // Tele-Operation Mode Code Template // // This file contains a template for simplified creation of an tele-op program for an FTC // competition. // // You need to customize two functions with code unique to your specific robot. // /////////////////////////////////////////////////////////////////////////////////////////////////////
#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
///////////////////////////////////////////////////////////////////////////////////////////////////// // // initializeRobot // // Prior to the start of tele-op mode, you may want to perform some initialization on your robot // and the variables within your program. // // In most cases, you may not have to add any code to this function and it will remain "empty". // /////////////////////////////////////////////////////////////////////////////////////////////////////
void initializeRobot() { // Place code here to sinitialize servos to starting positions. // Sensors are automatically configured and setup by ROBOTC. They may need a brief time to stabilize.
return; }
///////////////////////////////////////////////////////////////////////////////////////////////////// // // Main Task // // The following is the main code for the tele-op robot operation. Customize as appropriate for // your specific robot. // // Game controller / joystick information is sent periodically (about every 50 milliseconds) from // the FMS (Field Management System) to the robot. Most tele-op programs will follow the following // logic: // 1. Loop forever repeating the following actions: // 2. Get the latest game controller / joystick settings that have been received from the PC. // 3. Perform appropriate actions based on the joystick + buttons settings. This is usually a // simple action: // * Joystick values are usually directly translated into power levels for a motor or // position of a servo. // * Buttons are usually used to start/stop a motor or cause a servo to move to a specific // position. // 4. Repeat the loop. // // Your program needs to continuously loop because you need to continuously respond to changes in // the game controller settings. // // At the end of the tele-op period, the FMS will autonmatically abort (stop) execution of the program. // /////////////////////////////////////////////////////////////////////////////////////////////////////
task main() {
while(1) { getJoystickSettings(joystick);
motor[motorF] = joystick.joy1_y1; motor[motorE] = joystick.joy1_y2;
getJoystickSettings(joystick);
if(joy1Btn(4)) { motor[motorG] = 50 } else { motor[motorG] = 10 }
if(joy1Btn(2)) { motor[motorG] = -50 } else
if(joy1Btn(6)) { servo[servo1] = 135; }
if(joy1Btn(5)) { servo[servo1] = 250; }
} }
|