ftc programming with android studioftckickoff.allendalerobotics.com/.../09/studio.17.pdf · driver...
TRANSCRIPT
FTC controls and programming with AndroidStudio
David Austin
Allendale Robotics
HexaSonics, FTC Team 7023
David Austin FTC Programming with Android Studio
Point-to-point wireless communication
There is not a Field Control System.
Advantage: Running at an event is just like running in yourpractice space.
David Austin FTC Programming with Android Studio
Point-to-point wireless communication
There is not a Field Control System.
Advantage: Running at an event is just like running in yourpractice space.
David Austin FTC Programming with Android Studio
Driver Station
Set up one phone as a dedicated driver station:Install the Driver Station app following the instructions inSection 8.6 in the FTC SDK User’s Manual (reference atthe end).
You will establish a Wifi Direct connection between theDriver Station and Robot Controller. You must rename theDriver Station phone as stated in the FTC game manual:e.g. “7023-DS”If you update the development software during the season,you will need to update the Driver Station app.
David Austin FTC Programming with Android Studio
Driver Station
Set up one phone as a dedicated driver station:Install the Driver Station app following the instructions inSection 8.6 in the FTC SDK User’s Manual (reference atthe end).You will establish a Wifi Direct connection between theDriver Station and Robot Controller. You must rename theDriver Station phone as stated in the FTC game manual:e.g. “7023-DS”
If you update the development software during the season,you will need to update the Driver Station app.
David Austin FTC Programming with Android Studio
Driver Station
Set up one phone as a dedicated driver station:Install the Driver Station app following the instructions inSection 8.6 in the FTC SDK User’s Manual (reference atthe end).You will establish a Wifi Direct connection between theDriver Station and Robot Controller. You must rename theDriver Station phone as stated in the FTC game manual:e.g. “7023-DS”If you update the development software during the season,you will need to update the Driver Station app.
David Austin FTC Programming with Android Studio
Driver Station
Before each match:Connect gamepads through a USB hub
Register gamepads with the Driver Station app“Start” + “A” for Driver 1“Start” + “B” for Driver 2
David Austin FTC Programming with Android Studio
Driver Station
Before each match:Connect gamepads through a USB hubRegister gamepads with the Driver Station app
“Start” + “A” for Driver 1“Start” + “B” for Driver 2
David Austin FTC Programming with Android Studio
Driver Station
Before each match:Connect gamepads through a USB hubRegister gamepads with the Driver Station app“Start” + “A” for Driver 1
“Start” + “B” for Driver 2
David Austin FTC Programming with Android Studio
Driver Station
Before each match:Connect gamepads through a USB hubRegister gamepads with the Driver Station app“Start” + “A” for Driver 1“Start” + “B” for Driver 2
David Austin FTC Programming with Android Studio
Hardware configuration
David Austin FTC Programming with Android Studio
Robot Controller
Set up another phone as a dedicated robot controller:
You will spend most of your time building a RobotController app to install on this phone. More about thislater.
Change the WiFi Direct name: e.g. “7023-RC”When both apps are running on their respective phones,establish a Wifi Direct pairing.From the Driver Station: Settings −→ Pair with RobotController.Accept the invitation in the Robot Controller.The Driver Station and Robot Controller can nowcommunicate.
David Austin FTC Programming with Android Studio
Robot Controller
Set up another phone as a dedicated robot controller:
You will spend most of your time building a RobotController app to install on this phone. More about thislater.Change the WiFi Direct name: e.g. “7023-RC”
When both apps are running on their respective phones,establish a Wifi Direct pairing.From the Driver Station: Settings −→ Pair with RobotController.Accept the invitation in the Robot Controller.The Driver Station and Robot Controller can nowcommunicate.
David Austin FTC Programming with Android Studio
Robot Controller
Set up another phone as a dedicated robot controller:
You will spend most of your time building a RobotController app to install on this phone. More about thislater.Change the WiFi Direct name: e.g. “7023-RC”When both apps are running on their respective phones,establish a Wifi Direct pairing.From the Driver Station: Settings −→ Pair with RobotController.
Accept the invitation in the Robot Controller.The Driver Station and Robot Controller can nowcommunicate.
David Austin FTC Programming with Android Studio
Robot Controller
Set up another phone as a dedicated robot controller:
You will spend most of your time building a RobotController app to install on this phone. More about thislater.Change the WiFi Direct name: e.g. “7023-RC”When both apps are running on their respective phones,establish a Wifi Direct pairing.From the Driver Station: Settings −→ Pair with RobotController.Accept the invitation in the Robot Controller.
The Driver Station and Robot Controller can nowcommunicate.
David Austin FTC Programming with Android Studio
Robot Controller
Set up another phone as a dedicated robot controller:
You will spend most of your time building a RobotController app to install on this phone. More about thislater.Change the WiFi Direct name: e.g. “7023-RC”When both apps are running on their respective phones,establish a Wifi Direct pairing.From the Driver Station: Settings −→ Pair with RobotController.Accept the invitation in the Robot Controller.The Driver Station and Robot Controller can nowcommunicate.
David Austin FTC Programming with Android Studio
Robot Controller
The robot code is contained in an Android app. To install yourapp from Android Studio, the phone must have “USBdebugging enabled.”
(Phone) Settings→ About Phone→ Build number; Tap it 7times to become developer.
(Phone) Settings→ Developer Options→ USB Debugging.
David Austin FTC Programming with Android Studio
Robot Controller
The robot code is contained in an Android app. To install yourapp from Android Studio, the phone must have “USBdebugging enabled.”
(Phone) Settings→ About Phone→ Build number; Tap it 7times to become developer.(Phone) Settings→ Developer Options→ USB Debugging.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure Robot
Choose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).
Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.
Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.
Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.
Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a name
Select Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Robot Controller
You will need to “configure the robot,” which assigns names tothe devices you plan to reference in your code.This can be done from either app.
Settings −→ Configure RobotChoose New and then Scan. This should detect yourexpansion hub(s).Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Pro tip: read the Wiki for configuring REV devices.Kinda cool: the REV hub has a built-in IMU.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.
David Austin FTC Programming with Android Studio
Android Studio
To program in Android Studio, you will need to:
Need to install Android Studio
Import the FTC Software Development Kit (SDK) availableon github.Create a FTC Robot Controller app project in AndroidStudioWrite your OpModesInstall your app through Android Studio
David Austin FTC Programming with Android Studio
Android Studio
To program in Android Studio, you will need to:
Need to install Android StudioImport the FTC Software Development Kit (SDK) availableon github.
Create a FTC Robot Controller app project in AndroidStudioWrite your OpModesInstall your app through Android Studio
David Austin FTC Programming with Android Studio
Android Studio
To program in Android Studio, you will need to:
Need to install Android StudioImport the FTC Software Development Kit (SDK) availableon github.Create a FTC Robot Controller app project in AndroidStudio
Write your OpModesInstall your app through Android Studio
David Austin FTC Programming with Android Studio
Android Studio
To program in Android Studio, you will need to:
Need to install Android StudioImport the FTC Software Development Kit (SDK) availableon github.Create a FTC Robot Controller app project in AndroidStudioWrite your OpModes
Install your app through Android Studio
David Austin FTC Programming with Android Studio
Android Studio
To program in Android Studio, you will need to:
Need to install Android StudioImport the FTC Software Development Kit (SDK) availableon github.Create a FTC Robot Controller app project in AndroidStudioWrite your OpModesInstall your app through Android Studio
David Austin FTC Programming with Android Studio
OpModes
The main task of the programming team is to write OpModeswithin the FTC Robot Controller app.
Except for registering the gamepads and connecting thephones, everything we’ve seen so far only needs to bedone once.
Most of your programming time will be spent creatingopmodes. You will probably want to create a couple. Forinstance, one for teleop and at least one for autonomous.OpModes are created using an event-driven model, similarto how an Arduino is programmed.
David Austin FTC Programming with Android Studio
OpModes
The main task of the programming team is to write OpModeswithin the FTC Robot Controller app.
Except for registering the gamepads and connecting thephones, everything we’ve seen so far only needs to bedone once.Most of your programming time will be spent creatingopmodes. You will probably want to create a couple. Forinstance, one for teleop and at least one for autonomous.
OpModes are created using an event-driven model, similarto how an Arduino is programmed.
David Austin FTC Programming with Android Studio
OpModes
The main task of the programming team is to write OpModeswithin the FTC Robot Controller app.
Except for registering the gamepads and connecting thephones, everything we’ve seen so far only needs to bedone once.Most of your programming time will be spent creatingopmodes. You will probably want to create a couple. Forinstance, one for teleop and at least one for autonomous.OpModes are created using an event-driven model, similarto how an Arduino is programmed.
David Austin FTC Programming with Android Studio
OpModes
OpModes extend OpMode as in
public class AmazingAuto extends OpMode
You must register OpModes with the app by including anannotation:
@Autonomous(name="Amazing auto!", group="Wow")// @Disabledpublic class AmazingAuto extends OpMode
You may also extend LinearOpMode. More on that later.
David Austin FTC Programming with Android Studio
OpModes
OpModes extend OpMode as in
public class AmazingAuto extends OpMode
You must register OpModes with the app by including anannotation:
@Autonomous(name="Amazing auto!", group="Wow")// @Disabledpublic class AmazingAuto extends OpMode
You may also extend LinearOpMode. More on that later.
David Austin FTC Programming with Android Studio
OpModes
OpModes extend OpMode as in
public class AmazingAuto extends OpMode
You must register OpModes with the app by including anannotation:
@Autonomous(name="Amazing auto!", group="Wow")// @Disabledpublic class AmazingAuto extends OpMode
You may also extend LinearOpMode. More on that later.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
There are a number of methods you need to construct to definean OpMode.
init(): Called once after Init is pressed.
init loop(): Called every 25 milliseconds after Init ispressed.start(): This is executed once after you press the Startbutton on the Driver Station.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds.stop(): Instructions to perform when the Stop button ispressed; e.g. set the power of all the motors to zero.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
There are a number of methods you need to construct to definean OpMode.
init(): Called once after Init is pressed.init loop(): Called every 25 milliseconds after Init ispressed.
start(): This is executed once after you press the Startbutton on the Driver Station.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds.stop(): Instructions to perform when the Stop button ispressed; e.g. set the power of all the motors to zero.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
There are a number of methods you need to construct to definean OpMode.
init(): Called once after Init is pressed.init loop(): Called every 25 milliseconds after Init ispressed.start(): This is executed once after you press the Startbutton on the Driver Station.
loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds.stop(): Instructions to perform when the Stop button ispressed; e.g. set the power of all the motors to zero.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
There are a number of methods you need to construct to definean OpMode.
init(): Called once after Init is pressed.init loop(): Called every 25 milliseconds after Init ispressed.start(): This is executed once after you press the Startbutton on the Driver Station.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds.
stop(): Instructions to perform when the Stop button ispressed; e.g. set the power of all the motors to zero.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
There are a number of methods you need to construct to definean OpMode.
init(): Called once after Init is pressed.init loop(): Called every 25 milliseconds after Init ispressed.start(): This is executed once after you press the Startbutton on the Driver Station.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds.stop(): Instructions to perform when the Stop button ispressed; e.g. set the power of all the motors to zero.
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
These are the methods you will mainly use:
init(): Load the robot configuration into your code.DcMotor leftDrive =
hardwareMap.dcMotor.get(‘‘leftDrive’’);
loop(): This is the main part of your code. You will listento sensors, determine how to respond, and set powerlevels to motors.stop(): Turn everything off.leftDrive.setPower(0);
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
These are the methods you will mainly use:
init(): Load the robot configuration into your code.DcMotor leftDrive =
hardwareMap.dcMotor.get(‘‘leftDrive’’);
loop(): This is the main part of your code. You will listento sensors, determine how to respond, and set powerlevels to motors.
stop(): Turn everything off.leftDrive.setPower(0);
David Austin FTC Programming with Android Studio
The life cycle of an OpMode
These are the methods you will mainly use:
init(): Load the robot configuration into your code.DcMotor leftDrive =
hardwareMap.dcMotor.get(‘‘leftDrive’’);
loop(): This is the main part of your code. You will listento sensors, determine how to respond, and set powerlevels to motors.stop(): Turn everything off.leftDrive.setPower(0);
David Austin FTC Programming with Android Studio
LinearOpMode
You may want to write OpModes for autonomous operationusing LinearOpMode, which hides the event-driven modelenabling you to write sequentially executed code.
David Austin FTC Programming with Android Studio
Resources
Resources:FTC resources:https://www.firstinspires.org/node/5291
Github repository:https://github.com/ftctechnh/ftc app
User’s manual:https://github.com/ftctechnh/ftc app/releases
FTC Control System Wiki:https://github.com/ftctechnh/ftc app/wiki
David Austin: [email protected]
David Austin FTC Programming with Android Studio
Resources
Resources:FTC resources:https://www.firstinspires.org/node/5291
Github repository:https://github.com/ftctechnh/ftc app
User’s manual:https://github.com/ftctechnh/ftc app/releases
FTC Control System Wiki:https://github.com/ftctechnh/ftc app/wiki
David Austin: [email protected]
David Austin FTC Programming with Android Studio
Resources
Resources:FTC resources:https://www.firstinspires.org/node/5291
Github repository:https://github.com/ftctechnh/ftc app
User’s manual:https://github.com/ftctechnh/ftc app/releases
FTC Control System Wiki:https://github.com/ftctechnh/ftc app/wiki
David Austin: [email protected]
David Austin FTC Programming with Android Studio
Resources
Resources:FTC resources:https://www.firstinspires.org/node/5291
Github repository:https://github.com/ftctechnh/ftc app
User’s manual:https://github.com/ftctechnh/ftc app/releases
FTC Control System Wiki:https://github.com/ftctechnh/ftc app/wiki
David Austin: [email protected]
David Austin FTC Programming with Android Studio
Resources
Resources:FTC resources:https://www.firstinspires.org/node/5291
Github repository:https://github.com/ftctechnh/ftc app
User’s manual:https://github.com/ftctechnh/ftc app/releases
FTC Control System Wiki:https://github.com/ftctechnh/ftc app/wiki
David Austin: [email protected]
David Austin FTC Programming with Android Studio