AnswerBun.com

How can I allow for this code to switch from remote control to autonomous?

Robotics Asked by Stackcode12 on December 15, 2020

//ERROR: Task ‘autonomous’ is not defined at global scope level

#pragma config(StandardModel, "RVW CLAWBOT")
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#pragma DebuggerWindows("joystickSimple")
task autonomous();
task main()

{
while (true)

{


    // update buttons and joysticks
    getJoystickSettings(joystick);

    //Assign the left and right joystick values
    //to the left and right motors
    motor[leftMotor] = joystick.joy1_y1;
    motor[rightMotor] = joystick.joy1_y1;

task autonomous()
  {
    motor[leftMotor] = 80;
    motor[rightMotor] = 80;
    wait1Msec(2500);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    
    wait1Msec(1000);
    
    motor[leftMotor] = 80;
    motor[rightMotor] = -80;
    wait1Msec(2500);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    
  }
    if(motor[rightMotor] == 1) {
    startTask(autonomous);
    stopTask(main);
  
}
}
}

One Answer

The code for “task autonomous()” should be outside of the main() function.

Answered by SteveO on December 15, 2020

Add your own answers!

Related Questions

Moment of Inertia of a Dumbbell

2  Asked on October 3, 2021 by kucar

 

Are there any tutorials for OMPL in Python?

1  Asked on October 3, 2021 by batini

   

Arduino and stepper motor

2  Asked on February 19, 2021

   

Pictures coordinates to robot coordinates

1  Asked on January 14, 2021 by dairon

     

Not able to communicate with Roomba with serial port

1  Asked on January 9, 2021 by aalian-khan

     

Directly tapping Create2 battery through vacuum brush

2  Asked on January 6, 2021 by xabigarde

 

A Delivery Drone

1  Asked on December 6, 2020 by will

         

How to convert vertical motion to horizontal?

5  Asked on December 4, 2020 by boardbite

         

Monobrick Communication Library-reading nxt sensors

2  Asked on October 31, 2020 by jpcreeper13

   

Res-Scaling method beats PID controller. How?

1  Asked on October 26, 2020 by pe-dro

       

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP