FTC controls and programming with AndroidStudio
David Austin
Allendale Robotics
HexaSonics, FTC Team 7023
1
Point-to-point wireless communication
There is not a Field Control System.
Advantage: Running at an event is just like running in yourpractice space.
2
Point-to-point wireless communication
There is not a Field Control System.
Advantage: Running at an event is just like running in yourpractice space.
2
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.
3
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.
3
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.
3
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
4
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
4
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
4
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
4
Hardware configuration
5
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.
6
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.
6
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.
6
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.
6
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.
6
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.
7
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.
7
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 to
remember 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 controller
app.
8
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 your
expansion 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 controller
app.
8
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 your
expansion hub(s).• Give each motor and sensor a name. You will need to
remember 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 controller
app.
8
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 your
expansion hub(s).• Give each motor and sensor a name. You will need to
remember 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 controller
app.
8
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 your
expansion hub(s).• Give each motor and sensor a name. You will need to
remember 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 controller
app.
8
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 your
expansion hub(s).• Give each motor and sensor a name. You will need to
remember 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.
8
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 your
expansion hub(s).• Give each motor and sensor a name. You will need to
remember 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 controller
app. 8
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 AndroidStudio
• Write your OpModes
• Install your app through Android Studio
9
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 AndroidStudio
• Write your OpModes
• Install your app through Android Studio
9
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 AndroidStudio
• Write your OpModes
• Install your app through Android Studio
9
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 AndroidStudio
• Write your OpModes
• Install your app through Android Studio
9
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 AndroidStudio
• Write your OpModes
• Install your app through Android Studio
9
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.
10
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.
10
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.
10
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")
// @Disabled
public class AmazingAuto extends OpMode
• You may also extend LinearOpMode. More on that later.
11
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")
// @Disabled
public class AmazingAuto extends OpMode
• You may also extend LinearOpMode. More on that later.
11
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")
// @Disabled
public class AmazingAuto extends OpMode
• You may also extend LinearOpMode. More on that later.
11
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.
12
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.
12
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.
12
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.
12
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.
12
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);
13
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);
13
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);
13
LinearOpMode
You may want to write OpModes for autonomous operationusing LinearOpMode, which hides the event-driven modelenabling you to write sequentially executed code.
14
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]
15
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]
15
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]
15
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]
15
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]
15