ftc programming with app inventorftckickoff.allendalerobotics.com › wp-content › ...david austin...

48
FTC Programming with Android Studio David Austin Allendale Robotics HexaSonics, FTC Team 7023 [email protected] David Austin FTC Programming with App Inventor

Upload: others

Post on 27-Jun-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

FTC Programming with Android Studio

David Austin

Allendale Robotics

HexaSonics, FTC Team 7023

[email protected]

David Austin FTC Programming with App Inventor

Page 2: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Point-to-point wireless communication

There is no longer a Field Control System.

Advantage: Running at an event is just like running in yourpractice space.

David Austin FTC Programming with App Inventor

Page 3: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Point-to-point wireless communication

There is no longer a Field Control System.

Advantage: Running at an event is just like running in yourpractice space.

David Austin FTC Programming with App Inventor

Page 4: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play

“Forget” any wireless networksPhone in airplane modeRename under WiFi Direct: e.g. “7023-DS”Update app later in the seasonVery useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 5: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play“Forget” any wireless networks

Phone in airplane modeRename under WiFi Direct: e.g. “7023-DS”Update app later in the seasonVery useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 6: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play“Forget” any wireless networksPhone in airplane mode

Rename under WiFi Direct: e.g. “7023-DS”Update app later in the seasonVery useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 7: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play“Forget” any wireless networksPhone in airplane modeRename under WiFi Direct: e.g. “7023-DS”

Update app later in the seasonVery useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 8: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play“Forget” any wireless networksPhone in airplane modeRename under WiFi Direct: e.g. “7023-DS”Update app later in the season

Very useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 9: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Driver Station

Set up one time:Download FTC Driver Station app from Google Play“Forget” any wireless networksPhone in airplane modeRename under WiFi Direct: e.g. “7023-DS”Update app later in the seasonVery useful: the driver station app displays telemetry datawe can send back from the robot.

David Austin FTC Programming with App Inventor

Page 10: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

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 App Inventor

Page 11: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

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 App Inventor

Page 12: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

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 App Inventor

Page 13: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

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 App Inventor

Page 14: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

New hardware configuration

David Austin FTC Programming with App Inventor

Page 15: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play

“Forget” wireless network, airplane modeRename under WiFi Direct: e.g. “7023-DC”Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotControllerAccept the invitation on the controllerThe Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 16: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play“Forget” wireless network, airplane mode

Rename under WiFi Direct: e.g. “7023-DC”Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotControllerAccept the invitation on the controllerThe Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 17: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play“Forget” wireless network, airplane modeRename under WiFi Direct: e.g. “7023-DC”

Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotControllerAccept the invitation on the controllerThe Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 18: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play“Forget” wireless network, airplane modeRename under WiFi Direct: e.g. “7023-DC”Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotController

Accept the invitation on the controllerThe Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 19: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play“Forget” wireless network, airplane modeRename under WiFi Direct: e.g. “7023-DC”Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotControllerAccept the invitation on the controller

The Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 20: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

The main task of the programming team is to write an FTCRobot Controller app.

Download a minimal version from Google Play“Forget” wireless network, airplane modeRename under WiFi Direct: e.g. “7023-DC”Pair the Driver Station and Robot Controller:From the Driver Station: Settings −→ Pair with RobotControllerAccept the invitation on the controllerThe Driver Station and Robot Controller can nowcommunicate

David Austin FTC Programming with App Inventor

Page 21: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

To install your app from Android Studio, the phone must have“USB debugging enabled.”

(Phone) Settings→ About Phone→ Build number; Tap it 7times to become developer.

(Phone) Settings→ Developer Options→ USB Debugging.

David Austin FTC Programming with App Inventor

Page 22: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

To install your app from Android Studio, the phone must have“USB debugging enabled.”

(Phone) Settings→ About Phone→ Build number; Tap it 7times to become developer.(Phone) Settings→ Developer Options→ USB Debugging.

David Austin FTC Programming with App Inventor

Page 23: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

More specifically, the main task of the programming team is towrite OpModes within the FTC Robot Controller app. But first,we need to configure the hardware within the controller app.With the phone connected to the robot, open the Controller app:

Settings −→ Configure Robot

Choose New and then Scan. This should detect the motorcontrollers and sensor module.Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.

David Austin FTC Programming with App Inventor

Page 24: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

More specifically, the main task of the programming team is towrite OpModes within the FTC Robot Controller app. But first,we need to configure the hardware within the controller app.With the phone connected to the robot, open the Controller app:

Settings −→ Configure RobotChoose New and then Scan. This should detect the motorcontrollers and sensor module.

Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.

David Austin FTC Programming with App Inventor

Page 25: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

More specifically, the main task of the programming team is towrite OpModes within the FTC Robot Controller app. But first,we need to configure the hardware within the controller app.With the phone connected to the robot, open the Controller app:

Settings −→ Configure RobotChoose New and then Scan. This should detect the motorcontrollers and sensor module.Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.

Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.

David Austin FTC Programming with App Inventor

Page 26: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

More specifically, the main task of the programming team is towrite OpModes within the FTC Robot Controller app. But first,we need to configure the hardware within the controller app.With the phone connected to the robot, open the Controller app:

Settings −→ Configure RobotChoose New and then Scan. This should detect the motorcontrollers and sensor module.Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Save the configuration and give it a name

Select Activate to use this configuration in the controllerapp.

David Austin FTC Programming with App Inventor

Page 27: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Robot Controller

More specifically, the main task of the programming team is towrite OpModes within the FTC Robot Controller app. But first,we need to configure the hardware within the controller app.With the phone connected to the robot, open the Controller app:

Settings −→ Configure RobotChoose New and then Scan. This should detect the motorcontrollers and sensor module.Give each motor and sensor a name. You will need toremember these names so you may want to write themdown.Save the configuration and give it a nameSelect Activate to use this configuration in the controllerapp.

David Austin FTC Programming with App Inventor

Page 28: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

OpModes

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 App Inventor

Page 29: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

OpModes

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 App Inventor

Page 30: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

OpModes

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 App Inventor

Page 31: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

The life cycle of an opmode

There are a small number of methods you need to construct todefine an opmode. (A method simply means a set ofinstructions grouped together.)

start(): This is executed once after you press the Startbutton on the Driver Station. Do some initialization in here;e.g. configure motors.

loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds. This is where youlisten for input from the gamepads and sensors and set themotors’ power levels. Most of your work will go in here.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 App Inventor

Page 32: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

The life cycle of an opmode

There are a small number of methods you need to construct todefine an opmode. (A method simply means a set ofinstructions grouped together.)

start(): This is executed once after you press the Startbutton on the Driver Station. Do some initialization in here;e.g. configure motors.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds. This is where youlisten for input from the gamepads and sensors and set themotors’ power levels. Most of your work will go in here.

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 App Inventor

Page 33: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

The life cycle of an opmode

There are a small number of methods you need to construct todefine an opmode. (A method simply means a set ofinstructions grouped together.)

start(): This is executed once after you press the Startbutton on the Driver Station. Do some initialization in here;e.g. configure motors.loop(): While the opmode is running, this method isexecuted roughly every 25 milliseconds. This is where youlisten for input from the gamepads and sensors and set themotors’ power levels. Most of your work will go in here.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 App Inventor

Page 34: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

The life cycle of an opmode

Soon, there will be a new button Init that can be used to, say,initialize servos or calibrate a gyro before Start is pressed. Youcan use these methods.

init(): Called once after Init is pressed.

init loop(): Called every 25 milliseconds after Init ispressed.

David Austin FTC Programming with App Inventor

Page 35: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

The life cycle of an opmode

Soon, there will be a new button Init that can be used to, say,initialize servos or calibrate a gyro before Start is pressed. Youcan use these methods.

init(): Called once after Init is pressed.init loop(): Called every 25 milliseconds after Init ispressed.

David Austin FTC Programming with App Inventor

Page 36: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

App Inventor

Let’s get started with Android Studio! You will:

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 App Inventor

Page 37: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

App Inventor

Let’s get started with Android Studio! You will:

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 App Inventor

Page 38: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

App Inventor

Let’s get started with Android Studio! You will:

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 App Inventor

Page 39: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

App Inventor

Let’s get started with Android Studio! You will:

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 App Inventor

Page 40: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

App Inventor

Let’s get started with Android Studio! You will:

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 App Inventor

Page 41: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

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 App Inventor

Page 42: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Using the legacy motor controllers

Returning teams may wish to re-use the motor controllersfrom last year. You may do this by connecting the motorcontrollers to the Legacy Module, which connects to thePower Module.

There are some complications since the controllers use theI2C communications protocol, which can only sendinformation in one direction at a time.The controllers need to be set in write mode to set thepower and read mode to read encoders. It takes a coupleof cycles for the switch to occur.Don’t worry about this if you are using the new motorcontrollers.

David Austin FTC Programming with App Inventor

Page 43: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Using the legacy motor controllers

Returning teams may wish to re-use the motor controllersfrom last year. You may do this by connecting the motorcontrollers to the Legacy Module, which connects to thePower Module.There are some complications since the controllers use theI2C communications protocol, which can only sendinformation in one direction at a time.

The controllers need to be set in write mode to set thepower and read mode to read encoders. It takes a coupleof cycles for the switch to occur.Don’t worry about this if you are using the new motorcontrollers.

David Austin FTC Programming with App Inventor

Page 44: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Using the legacy motor controllers

Returning teams may wish to re-use the motor controllersfrom last year. You may do this by connecting the motorcontrollers to the Legacy Module, which connects to thePower Module.There are some complications since the controllers use theI2C communications protocol, which can only sendinformation in one direction at a time.The controllers need to be set in write mode to set thepower and read mode to read encoders. It takes a coupleof cycles for the switch to occur.

Don’t worry about this if you are using the new motorcontrollers.

David Austin FTC Programming with App Inventor

Page 45: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Using the legacy motor controllers

Returning teams may wish to re-use the motor controllersfrom last year. You may do this by connecting the motorcontrollers to the Legacy Module, which connects to thePower Module.There are some complications since the controllers use theI2C communications protocol, which can only sendinformation in one direction at a time.The controllers need to be set in write mode to set thepower and read mode to read encoders. It takes a coupleof cycles for the switch to occur.Don’t worry about this if you are using the new motorcontrollers.

David Austin FTC Programming with App Inventor

Page 46: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Resources

http://ftcforum.usfirst.org/forumdisplay.php?156-FTC-Technology

http://ftc.edu.intelitek.com

David Austin, [email protected]

David Austin FTC Programming with App Inventor

Page 47: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Resources

http://ftcforum.usfirst.org/forumdisplay.php?156-FTC-Technology

http://ftc.edu.intelitek.com

David Austin, [email protected]

David Austin FTC Programming with App Inventor

Page 48: FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin FTC Programming with App Inventor. Robot Controller The main task of the programming

Resources

http://ftcforum.usfirst.org/forumdisplay.php?156-FTC-Technology

http://ftc.edu.intelitek.com

David Austin, [email protected]

David Austin FTC Programming with App Inventor