1

FTC 向けの遠隔操作プログラムをプログラミングしています。私たちのロボットはオムニホイールです:

/\ /

上部で、4 つのモーターを motor_LF、motor_LB、motor_RF、および motor_RB として定義します。

残念ながら、モーターを実際に動かす最後の数行で、モーター変数が定義されていないというエラーが表示されます。

どんな助けでも大歓迎です。

初めてrobotcを試しています。それを構成し、次のコードを用意します。

#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTMotor,  none)
#pragma config(Hubs,  S2, HTServo,  none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Sensor, S2,     ,               sensorI2CMuxController)
#pragma config(Motor,  motorA,          motorC,        tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  motorC,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  mtr_S1_C1_1,     motor_LF,       tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motor_LB,       tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     motor_RF,       tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_2,     motor_RB,       tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C3_1,     motor_L,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C3_2,     motorI,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S2_C1_1,    servo1,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_2,    servo2,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S2_C1_6,    servo6,               tServoNone)

#include "JoystickDriver.c"                                     //includes code for tele-op

void initializeRobot()                                              //starts the Robot for autonomous
{                                                                                       //starts autonomous

    return;                                                                         //returns the robot to tele-op after autonomous
}                                                                                       //ends autonomous


task main()

{
    //starts tele-op
    initializeRobot();                                                  //starts the robot for teleop



    waitForStart();                                                         //waits for start of tele-op period

    int mThreshold = 15; // To avoid unnecessary movement

    //joystick initialization 
    int xValL, yValL, xValR;

    float scaleFactor = 40.0 / 127; // Sets max. average motor power and maps range
    // of analog stick to this power range

    int motor_LFVal = 0;                                                //sets the initial value of motor_LF to 0
    int motor_LBVal = 0;                                                //sets the initial value of motor_LB to 0
    int motor_RFVal = 0;                                                //sets the initial value of motor_RF to 0
    int motor_RBVal = 0;                                                //sets the initial value of motor_RB to 0

    //repeat forever

    while (true)
    {
        getJoystickSettings(joystick);                      //gets the joystick input throughout match

        xValL = joystick.joy1_x1;
        yValL = joystick.joy1_y1;

        //create threshold for x1 axis
        if(abs(xValL) > mThreshold)         //if the absolute value of joystick 1, left stick, x-axis is greater than the threshold
        {
            xValL = joystick.joy1_x1;                               //robot will move
        }
        else                                                                            //if the absolute value of joystick 1, left stick, x-axis is less than the threshold
        {
            xValL = 0;                                                                  //robot will NOT move
        }

        //create threshold for y1 axis
        if(abs(yValL) > mThreshold)         //if the absolute value of joystick 1, left stick, y-axis is greater than the threshold
        {
            yValL = joystick.joy1_y1;                                   //robot will move
        }
        else                                                                            //if the absolute value of joystick 1, left stick, y-axis is less than the threshold
        {
            yValL = 0;                                                                  //robot will NOT move
        }

        //create threshold for x2 axis
        if(abs(xValR) > mThreshold)         //if the absolute value of joystick 1, right stick, x-axis is greater than the threshold
        {
            xValR = joystick.joy1_x2;                                   //robot will move
        }
        else                                                                            //if the absolute value of joystick 1, right stick, x-axis is less than the threshold
        {
            xValR = 0;                                                                  //robot will NOT move
        }

        //final math and running statements

        //allows each motor to turn independently
        motor[motor_LF] = (-yValL - xValL - xValR) * scaleFactor;  //ERROR HERE                             //-(joy1_y1) - (joy1_x1) - (joy1_x2) = the final value of motor_LF
        motor[motor_LB] = (-yValL + xValL - xValR) * scaleFactor;    //ERROR HERE                           //-(joy1_y1) + (joy1_x1) - (joy1_x2) = the final value of motor_LB
        motor[motor_RF] = (yValL - xValL - xValR) * scaleFactor;     //ERROR HERE                               //(joy1_y1) - (joy1_x1) - (joy1_x2) = the final value of motor_RF
        motor[motor_RB] = (yValL + xValL - xValR) * scaleFactor;     //ERROR HERE                               //(joy1_y1) + (joy1_x1) - (joy1_x2) = the final value of motor_RB


    }

}
4

0 に答える 0