View Single Post
  #6   Spotlight this post!  
Unread 12-13-2016, 05:22 PM
phurley67 phurley67 is offline
Programming Mentor
FRC #0862 (Lightning Robotics)
Team Role: Mentor
 
Join Date: Apr 2014
Rookie Year: 2013
Location: Michigan
Posts: 63
phurley67 is an unknown quantity at this point
Re: Need help understanding command-based Robots

Quote:
Originally Posted by GavinL View Post
Ok, thanks a lot! And if I want to execute a command, is it "MoveToPosition.execute();"? (without "")
You would generally associate the MoveToPosition command with operator interface (OI). Using robot builder you can assign it to when a button on a joystick (or gamepad) is pressed, held, or released.

The code ends up looking something like (but again, let robot builder do the lifting until you get the hang of it):

Code:
    // where the coPilot and cmdMove2Pos variables are generally 
    // defined in your OI.h file like
    std::shared_ptr<Joystick> coPilot;
    std::shared_ptr<JoystickButton> cmdMove2Pos;

    // in you OI.cpp file in the constructor
    coPilot.reset(new Joystick(1));
    coPilot.cmdMove2Pos.reset(new JoystickButton(coPilot.get(), 2));
    cmdMove2Pos->WhenPressed(new MoveToPosition());
You can also setup a command (or different commands based on a dashboard option) to run as your auton. The commands can run in sequence, so you can build complicated autonomous behavior from simpler command options.
Reply With Quote