Difference between revisions of "FTC Just Enough Android Studio 20220223"

From wikidb
Jump to: navigation, search
(References)
(Download a project from GitHub)
 
(29 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
* Assure that the training robots are configured correctly for the tutorials
 
* Assure that the training robots are configured correctly for the tutorials
 
* Introduce a '''Happy Path''' to starting a project. This is not by any means a complete tutorial.
 
* Introduce a '''Happy Path''' to starting a project. This is not by any means a complete tutorial.
* Best Known Methods (BKM) are critical and are guided by the individual FTC teams. BKM will be integrated into my material but core Java skills will be the focus.
+
* '''Best Known Methods''' (BKM) are critical and are guided by the individual FTC teams. BKMs advice will be integrated into my material but core Java skills will be the focus.
 +
* We'll be lite on Github today
 +
 
 +
= Android Studio =
 +
 
 +
* [https://androidstudio.googleblog.com/2020/11/android-studio-411-available.html Android Studio 4.1.1]
  
 
= Download a project from GitHub =
 
= Download a project from GitHub =
  
 
* Set up a GitHub account
 
* Set up a GitHub account
 +
 +
*  https://github.com/edcepp/FTCJavaLabs
 +
 +
= Add an Op Mode =
 +
 +
* click on <tt>org.firstinspires.ftc.teamcode</tt> folder which is itself in the <tt>TeamCode/java</tt> in the Project view
 +
** File menu
 +
*** New item
 +
**** Java Class - at the top of the list
 +
***** Type in the class name <tt>TestMotorEpp</tt> select <tt>Class Name</tt>
 +
****** answer the GitHub question
 +
****** find the class in the TeamCode of the project and enter your code
 +
 +
* Paste the downloaded code into the newprograms
 +
= Demo Program =
 +
 +
Drive the motors forward until stop press or for 30 seconds.
 +
* [[TestMotorEpp20220224]]
 +
* Paste it into new class
 +
 +
= Run =
 +
 +
Pressing '''Run''' (right pointing green triangle) and be excited when it works
  
 
= The Configuration File =
 
= The Configuration File =
Line 18: Line 46:
  
 
* Section 9.4
 
* Section 9.4
 +
 +
== MiniBot Kit ==
 +
 +
Example
 +
 +
* name: OrRAS
 +
** Webcam 1: 9BB6F610
 +
** Control Hub Portal: embedded
 +
*** Control Hub
 +
**** Motors
 +
***** 0: REV Robotics Core Hex Motor: myLeftMotor
 +
***** 1: REV Robotics Core Hex Motor: myRightMotor
 +
****  I2C Bus 0
 +
***** REV Expansion Hub IMU: imu
  
 
= Build Project =
 
= Build Project =
 +
 +
* Green right pointing triangle - Run your code
 +
* Red square - Stop
  
 
=  Modify and Build =
 
=  Modify and Build =
 +
 +
= Code Walk Through =
 +
 +
Not enough time to go into detail. For now this code is just how it has to be.
 +
 +
Point Out.
 +
* public void runOpMode
 +
* telemetry
 +
* waitForStart
 +
* DcMotor myLeftMotor
 +
** hardwareMap.get - see <tt>Configure</tt> file myLeftMotor mapped to 0: REV Robotics Core Hex Motor: myLeftMotor
 +
** go over the import
 +
* myLeftMotor.setPower
 +
** [https://first-tech-challenge.github.io/SkyStone/index.html FTC API reference]
 +
** in DcMotorSimple "Sets the power level of the motor, expressed as a fraction of the maximum possible power / speed supported according to the run mode in which the motor is operating"
 +
* while (opModeIsActive ())
 +
* shut off motors
 +
* Autonomous
 +
* Disable
 +
* public class TestMotorEppd extends LinearOpMode
 +
 +
= Exercises =
 +
 +
# Download the TestMotorEpp.java program from Github and test it.
 +
## Be sure the <tt>Configure</tt> file is set the hardware to software link up correctly
 +
## Watch your fingers, shirt sleeves and hair - the motors have a lot of pull and the gears are sharp
 +
# Remove the incorrect comment:
 +
## Commit
 +
## Push
 +
## Set up your own GitHub repository and push it there
 +
# Convert the program from its linear to iterative version
 +
## [https://github.com/FIRST-Tech-Challenge/FtcRobotController/blob/master/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/BasicOpMode_Iterative.java Basic OpMode Iterative]
 +
### in <tt>FtcRobotController/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/</tt>
  
 
= References =
 
= References =
Line 27: Line 105:
 
* [https://www.firstinspires.org/resource-library/ftc/technology-information-and-resources FTC Programming Resources]
 
* [https://www.firstinspires.org/resource-library/ftc/technology-information-and-resources FTC Programming Resources]
 
* [https://www.youtube.com/playlist?list=PLEuGrYl8iBm7wW9gyxpLDhBJAOWDZid1P Java Video Tutorials]
 
* [https://www.youtube.com/playlist?list=PLEuGrYl8iBm7wW9gyxpLDhBJAOWDZid1P Java Video Tutorials]
 +
** [https://www.youtube.com/watch?v=7CDK5-m-vQw&list=PLEuGrYl8iBm7wW9gyxpLDhBJAOWDZid1P&index=2 Writing an Op Mode - Java]
 +
** [https://www.youtube.com/watch?v=cRcdGPaZ70Y&list=PLEuGrYl8iBm7wW9gyxpLDhBJAOWDZid1P&index=3 registering and Installing an Op Mode - Java]
 +
* [https://github.com/FIRST-Tech-Challenge/FtcRobotController FTC SDK version 7.1]
 +
* [https://www.youtube.com/watch?v=IEWxGbj0SII How To Set Up A Github Repository For FTC]

Latest revision as of 17:44, 28 May 2022

Strategy

  • Assure that the training robots are configured correctly for the tutorials
  • Introduce a Happy Path to starting a project. This is not by any means a complete tutorial.
  • Best Known Methods (BKM) are critical and are guided by the individual FTC teams. BKMs advice will be integrated into my material but core Java skills will be the focus.
  • We'll be lite on Github today

Android Studio

Download a project from GitHub

  • Set up a GitHub account

Add an Op Mode

  • click on org.firstinspires.ftc.teamcode folder which is itself in the TeamCode/java in the Project view
    • File menu
      • New item
        • Java Class - at the top of the list
          • Type in the class name TestMotorEpp select Class Name
            • answer the GitHub question
            • find the class in the TeamCode of the project and enter your code
  • Paste the downloaded code into the newprograms

Demo Program

Drive the motors forward until stop press or for 30 seconds.

Run

Pressing Run (right pointing green triangle) and be excited when it works

The Configuration File

Connection Details

Creating a Configuation File Using the Driver Station

  • Section 9.4

MiniBot Kit

Example

  • name: OrRAS
    • Webcam 1: 9BB6F610
    • Control Hub Portal: embedded
      • Control Hub
        • Motors
          • 0: REV Robotics Core Hex Motor: myLeftMotor
          • 1: REV Robotics Core Hex Motor: myRightMotor
        • I2C Bus 0
          • REV Expansion Hub IMU: imu

Build Project

  • Green right pointing triangle - Run your code
  • Red square - Stop

Modify and Build

Code Walk Through

Not enough time to go into detail. For now this code is just how it has to be.

Point Out.

  • public void runOpMode
  • telemetry
  • waitForStart
  • DcMotor myLeftMotor
    • hardwareMap.get - see Configure file myLeftMotor mapped to 0: REV Robotics Core Hex Motor: myLeftMotor
    • go over the import
  • myLeftMotor.setPower
    • FTC API reference
    • in DcMotorSimple "Sets the power level of the motor, expressed as a fraction of the maximum possible power / speed supported according to the run mode in which the motor is operating"
  • while (opModeIsActive ())
  • shut off motors
  • Autonomous
  • Disable
  • public class TestMotorEppd extends LinearOpMode

Exercises

  1. Download the TestMotorEpp.java program from Github and test it.
    1. Be sure the Configure file is set the hardware to software link up correctly
    2. Watch your fingers, shirt sleeves and hair - the motors have a lot of pull and the gears are sharp
  2. Remove the incorrect comment:
    1. Commit
    2. Push
    3. Set up your own GitHub repository and push it there
  3. Convert the program from its linear to iterative version
    1. Basic OpMode Iterative
      1. in FtcRobotController/FtcRobotController/src/main/java/org/firstinspires/ftc/robotcontroller/external/samples/

References