deer89900
Rookie
Joined: Tue Apr 09, 2013 7:53 am Posts: 3
|
 new teleop:compile correctly,but fail to do any movement
The robot is also right.Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, ir1, sensorHiTechnicIRSeeker1200) #pragma config(Sensor, S3, ir2, sensorHiTechnicIRSeeker1200) #pragma config(Sensor, S4, safe, sensorTouch) #pragma config(Motor, motorA, , tmotorNXT, openLoop) #pragma config(Motor, motorB, , tmotorNXT, openLoop) #pragma config(Motor, motorC, , tmotorNXT, openLoop) #pragma config(Motor, mtr_S1_C1_1, wheel_left, tmotorTetrix, openLoop, reversed) #pragma config(Motor, mtr_S1_C1_2, wheel_right, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C2_1, motor3, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C2_2, motor4, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C3_1, lift, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C3_2, light, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C4_1, g_switch, tServoStandard) #pragma config(Servo, srvo_S1_C4_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C4_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C4_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C4_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C4_6, servo6, tServoNone)
#include "JoystickDriver.c"
task main() { int mThreshold = 10;
int xVal, yVal, zVal;
float scaleFactor = 100 / 127;
while(true) { getJoystickSettings(joystick);
xVal = joystick.joy1_x1; yVal = joystick.joy1_y1; zVal = joystick.joy1_y2;
if (abs(xVal) < mThreshold) { xVal = 0; } if (abs(yVal) < mThreshold) { yVal = 0; }
if(joy1Btn(4) == 1) { motor[wheel_left] = ((yVal) + (xVal)) * scaleFactor * 15/100; motor[wheel_right] = ((yVal) - (xVal)) * scaleFactor * 15/100; if (zVal < 0 && SensorValue(safe) == 1) { motor[lift] = 0; } else { motor[lift] = zVal * scaleFactor * 15/100; } } else if(joy1Btn(4) == 0) { motor[wheel_left] = ((yVal) + (xVal)) * scaleFactor; motor[wheel_right] = ((yVal) - (xVal)) * scaleFactor; if (zVal < 0 && SensorValue(safe) == 1) { motor[lift] = 0; } else { motor[lift] = zVal * scaleFactor; } } } }
|