FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin...

Post on 27-Jun-2020

0 views 0 download

Transcript of FTC Programming with App Inventorftckickoff.allendalerobotics.com › wp-content › ...David Austin...

FTC Programming with Android Studio

David Austin

Allendale Robotics

HexaSonics, FTC Team 7023

david.austin.m@gmail.com

David Austin FTC Programming with App Inventor

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

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

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

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

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

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

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

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

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

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

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

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

New hardware configuration

David Austin FTC Programming with App Inventor

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Resources

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

http://ftc.edu.intelitek.com

David Austin, david.austin.m@gmail.com

David Austin FTC Programming with App Inventor

Resources

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

http://ftc.edu.intelitek.com

David Austin, david.austin.m@gmail.com

David Austin FTC Programming with App Inventor

Resources

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

http://ftc.edu.intelitek.com

David Austin, david.austin.m@gmail.com

David Austin FTC Programming with App Inventor