Presentation is loading. Please wait.

Presentation is loading. Please wait.

Block Programming Hello my name is Stephanie. I have been apart of FIRST for 6 years and have 3 years of programming experience. I am currently a member.

Similar presentations


Presentation on theme: "Block Programming Hello my name is Stephanie. I have been apart of FIRST for 6 years and have 3 years of programming experience. I am currently a member."— Presentation transcript:

1 Block Programming Hello my name is Stephanie. I have been apart of FIRST for 6 years and have 3 years of programming experience. I am currently a member of team Brain Stormz. Today we will be going over the FTC Block Program. Each Slide is numbered on the top right hand corner as reference. If you have any questions during the presentation feel free to write them down and the slide number as we will have a Q&A towards the end of the session.

2 Agenda What is Block Programming Getting Started
Pairing Android Phones Connecting Your Laptop to Block Programming Mode Server Block Programming Layout Creating Your First Teleop Adding Telemetry Saving Our Op Mode Creating Your First Autonomous Block Programming Resources Q & A Extra

3 What is Block Programming

4 What is This? … 200 more lines
To the left this is an example of Android studios Java, a writing based program. This is just the first few lines of a teleop program. There is about 200 more lines after this that completes the program. To the right is what we will be learning today, Block Programming, a visual based program. This is a simple teleop program that we will go more into detail later.

5 What is FTC Block Programming?
The FTC Blocks Programming Tool is a user-friendly program that is operated by the Robot Controller phone. A user can create custom op modes, or programs, for their robot using the Block Tool and save these op modes directly onto the Robot Controller. Users drag and drop jigsaw-shaped programming blocks onto a “canvas” and arrange these blocks to create the program logic for their op modes. The FTC Blocks Programming Tool is powered by Google’s Blockly software and was developed with support from Google. The FTC Blocks Programming Tool is a user-friendly program that is operated by the Robot Controller phone. Take note that this program is operated on the Robot Controller phone. All your programs will be saved only to the RC phone. Jigsaw-shaped programming blocks are dragged onto a “canvas” and arrange in order to create the program logic for the op modes.

6 Getting Started

7 Getting Started (Modern Robotics System)
Example of Wifi renaming screen. You will need to have two FIRST-approved Android smartphones for the control system. One phone will be used as the Robot Controller, the other will be used as the Driver Station. Each phone must have a unique name. This will ensure that your phones will be communicating with each other rather than other teams’ phones at meets and tournaments. All phones are required by FTC to be changed in the Wi-Fi direct setting to be identifiable. For example your team number is 1234 your Robot Controller phone should be named “1234-RC” . The driver station phone should be named “1234-DS”. In this presentation we will assume we are using the Modern Robotics Electronic System. Teams are also allowed to use the REV Robotics Electronic System this year. The setup steps for REV are slightly different. Don’t worry later in the presentation there will be a link that you can obtain for the setup of using REV. You will need to have two FIRST-approved Android smartphones for the control system. One phone will be used as the Robot Controller, the other will be used as the Driver Station. Each phone must have a unique name. This will ensure that your phones will be communicating with each other rather than other teams’ phones at meets and tournaments For example your team number is 1234 your Robot Controller phone should be named “1234-RC” . The driver station phone should be named “1234-DS”.

8 Installing FTC Apps The FTC apps are available to download for free from the Google Play store. You will need to have both Android phones connected to a Wi-Fi network that has Internet access before you can access the Google Play store. You will need a Google account to be able to download the apps. Once you have made a Google Play Account in the search window of the Google Play app, type in the words “FTC Robot Controller” to find the Robot Controller or “FTC Driver Station” to find the appropriate FTC app for your phone. Install the appropriate app for each phone. Once installation is complete disconnect both phones from the Wi-Fi network. The FTC apps are available to download for free from the Google Play store. You will need to have both Android phones connected to a Wi-Fi network. You must first make a Google Play Account before you can access the Google Play Store. Once you have made a Google Play Account in the search window of the Google Play app, type in the words “FTC Robot Controller” to find the Robot Controller or “FTC Driver Station” to find the appropriate FTC app for your phone. Once installation is complete you must disconnect both phones from the Wi-Fi network.

9 Pairing Android Phones

10 Pairing Driver Station and Robot Controller
Look for the Airplane mode icon and if the icon is not activated, touch the icon to put the phones into airplane mode. Placing the phone into airplane mode will turn off the Wifi connection. If the Wifi icon has a diagonal line through it, then the Wifi connection is disabled. You will need to touch the Wifi icon on the configuration screen to turn it on. Here our Wifi is enabled and so is our Airplane Mode. Airplane Mode and Wifi are deactivated here Look for the Airplane mode icon and if the icon is not activated, touch the icon to put the phones into airplane mode. Placing the phone into airplane mode will turn off the Wifi connection. If the Wifi icon has a diagonal line through it then the Wifi connection is disabled. You will need to touch the Wifi icon on the configuration screen to turn it on.

11 Phone Pairing (Continued)
Launch the Robot Controller phone and the Driver Station phone. Verify that the Robot Controller app is running. The Robot Status field should read “running”. On the Driver Station phone tap the three vertical dots on the upper right hand corner of the main screen and select Settings. From the Settings screen, look for and select “Connect with Robot Controller” . Find the name of your Robot Controller from the list and select it. On the Driver Station phone return to the main screen. The first time you attempt to connect to the Robot Controller a prompt should appear on the Robot Controller screen. Click on the “ACCEPT” button to accept the connection request from the Driver Station. Next, Launch the Robot Controller phone and the Driver Station phone. On the Driver Station phone tap the three vertical dots on the upper right hand corner of the main screen and select Settings. From the Settings screen, look for and select “Connect with Robot Controller” . Find the name of your Robot Controller from the list and select it. Return to the main screen on both phones. The first time you attempt to connect to the Robot Controller a prompt should appear on the Robot Controller screen. Click on the “ACCEPT” button to accept the connection request from the Driver Station.

12 Connecting Your Laptop to Block Programming Mode Server

13 Installation Requirements
To be able to program using the blocks programming mode server, your laptop will need a Javascript-enabled browser. Google Chrome is highly recommended by FIRST as the Javascript-enabled browser for the FTC Blocks Programming Tool. Visit the Google Chrome website and follow onscreen instructions to download and install Chrome. To be able to program using the blocks programming mode server, your laptop will need a Javascript-enabled browser. Google Chrome is highly recommended by FIRST as the Javascript-enabled browser for the FTC Blocks Programming Tool.

14 Connecting Your Laptop to the FTC Blocks Programming Mode Server
You will need to put your Robot Controller smartphone into FTC Blocks Programming Mode. This allows the phone to become a Programming Mode server, and enables your laptop to connect to this server so that you can start creating your op modes. On the Robot Controller, touch the three dots in the upper right hand corner of the screen to launch the pop-up menu. Select “Programming Mode” to place the Robot Controller into Programming Mode. Programming Mode main screen You will need to put your Robot Controller smartphone into FTC Blocks Programming Mode. This allows the phone to become a Programming Mode server, and enables your laptop to connect to this server. On the Robot Controller, touch the three dots in the upper right hand corner of the screen to launch the pop-up menu. Select “Programming Mode” to place the Robot Controller into Programming Mode.

15 Laptop to the FTC Blocks Programming Mode (Continued)
The Programming Mode screen displays important information that you can use to connect your laptop to the FTC Blocks Programming Mode server. Verify the network name and pass phrase for the Programming Mode’s wireless network. On your laptop look for the wireless network that matches the name displayed on the Robot Controller. Click on it to select it. When prompted, provide the network passphrase Information displayed on Programming mode screen to access server Connect your Laptop to the Block Programming Mode Server that matches the one displayed on the RC screen. The Programming Mode screen displays important information that you can use to connect your laptop to the FTC Blocks Programming Mode server. On your laptop look for the wireless network name that matches the one displayed on the RC phone. Select this network and when prompted enter in the passphrase.

16 Launching The Block Programming Browser
Launch the Javascript-enabled web browser on your laptop. Find the web address that is displayed on the Programming Mode screen of the Robot Controller. Type this web address into your browser to navigate to the Programming Mode web server. Verify that your web browser is connected to the programming mode server. If it is connected to the programming mode server, the main FTC Blocks Development Tool project screen will be displayed. Press the “Create New Op Mode” button which should be visible towards the upper left hand corner of the browser window. When prompted, specify a name for the op mode and hit “OK” to continue. Launch the Javascript-enabled web browser on your laptop. Find the web address that is displayed on the Programming Mode screen of the Robot Controller. Type this web address into your browser to navigate to the Programming Mode web server. Press the “Create New Op Mode” button which should be visible towards the upper left hand corner of the browser window. When prompted, specify a name for the op mode and hit “OK”.

17 Block Programming Layout

18 Block Programming Browser Layout
On the left-hand side of your browser’s screen contains a list of categorized, color coded programming blocks. If you click on a category, the browser will display a list of available programming blocks related to the topic of that category. For example clicking on the actuators drop down will open up options for DC Motors and Servo controls. The right-hand side of the screen is where you drag and arrange your programming blocks on the “canvas” to create the logic for your op mode. On the left-hand side of your browser’s screen contains a list of categorized, color coded programming blocks. If you click on a category, the browser will display a list of available programming blocks related to the topic of that category. For example clicking on the actuators drop down will open up options for DC Motors and Servo controls. The right-hand side of the screen is where you drag and arrange your programming blocks on the “canvas” to create the logic for your op mode.

19 Creating Your First Teleop
In FTC there is a 2:30 time period. The first 30 seconds is the pre- programmed autonomous time period. The next 2 minutes is the driver controlled time period. We are going to talk about Teleop Block Programming first as this can be much simpler than Autonomous and the Teleop time period takes up the majority of the total game time.

20 Creating Your First Teleop OpMode
When you first create a new op mode, there should already be a set of programming blocks that are placed on the design canvas for your op mode. The main body of your op mode will defined by the outer purple bracket that has the words “myFirstOpMode” at the top. This name can be different depending on what is the name of your op mode program. All your teleop blocks will be placed inside of this. You can find this in the purple Functions tab. When you first create a new op mode, there should already be a set of programming blocks that are placed on the design canvas for your op mode. The main body of your op mode will defined by the outer purple bracket that has the words “myFirstOpMode” at the top. This name will be different depending on the name of your op mode program. All your teleop blocks will be placed inside of this. You can find this in the purple Functions tab.

21 Before you can start giving commands to the robot, you need to define how many motors you have and identify them with a name. We will identify four motors for this OpMode. Since we have four motors facing in towards each other, we’ll need to identify in initialization that two motors will be reversed. You can find the blocks for this under the actuator-DCMotor tab. The blue block is our comment box. You can type anything in here to help you. Before you can start giving commands to the robot, you need to define how many motors you have and identify them. We will identify four motors for this OpMode. Since we have four motors facing in towards each other, we’ll need to identify in initialization that two motors will be reversed. You can find the blocks for this under the actuator-DCMotor tab.

22 Once you have initialized and set your motor directions
Once you have initialized and set your motor directions. Next, you’ll need to tell your program to “waitForStart”. You can find this command in the LinearOpMode tab. This tells the program that it can not run the program any further until the play button on the Driver Station is pressed. Any programming blocks that are placed before “call MyFirstOpMode.waitForStart” block will be executed when the op mode is first selected by a user at the Driver Station. Any code after the “call MyFirstOpMode.waitForStart” block will get executed after the Start button has been pressed. Once you have initialized and set your motor directions. Next, you’ll need to tell your program to “waitForStart”. You can find this command in the LinearOpMode tab. This tells the program that it can not run the program any further until the play button on the Driver Station is pressed.

23 Once we have pressed play, we need to enter into a “while loop” to execute our teleop commands.
Any blocks that are placed after “call MyFirstOpMode.waitForStart” and before the green block labeled “repeat while call MyFirstOpMode.opModeIsActive” will be executed sequentially by the Robot Controller after the Start button has been pressed. The green block labeled “repeat while call MyFirstOpMode.opModeIsActive” can be found in the LinearOpMode tab. Once the user presses the Stop button, the “call MyFIRSTOpMode.opModeIsActive” clause is no longer true and the “repeat while loop “ will stop repeating itself. Once we have pressed play, we need to enter into a “while loop” to execute our teleop commands. Any blocks that are placed after “call MyFirstOpMode.waitForStart” and before the green block labeled “repeat while call MyFirstOpMode.opModeIsActive” will be executed sequentially by the Robot Controller after the Start button has been pressed. The green block labeled “repeat while call MyFirstOpMode.opModeIsActive” can be found in the LinearOpMode tab. When the users presses stop on the DS phone the program will stop running.

24 In our teleop we want to put all control blocks for driving in our “while loop”.
Here we state which motors we want to control and with which gamepad controls. In this example we’ll use the joysticks to control our motors. In a standard tank drive control we allow the left joystick to control the left motors and the right joystick to control the right motors. Notice the gamepad values are set to negative. This is because joysticks have a range of -1 to 1 however pushing the joystick up produces a negative value. We want to use a negative value on the joystick to cancel out this negative. In our teleop we want to put all control blocks for driving in our “while loop”. Here we state which motors we want to control and with which gamepad controls. In a standard tank drive control we allow the left joystick to control the left motors and the right joystick to control the right motors. Notice the gamepad values are set to negative. This is because joysticks have a range of -1 to 1 however pushing the joystick up produces a negative value. We want to use a negative value on the joystick to cancel out this negative.

25 Adding Telemetry

26 Adding Telemetry Your op mode is just about ready to run. You can chose to add a couple of telemetry statements that will send information from the Robot Controller to the Driver Station for display on the Driver Station user interface. This telemetry mechanism is a useful way to display status information from the robot on the Driver Station. Telemetry can be used to display sensor data, motor status, gamepad state, etc. from the Robot Controller to the Driver Station. The telemetry block can be found under the category Utilities. For this example we want to keep track of how much power our back motors are receiving we chose “call telemetry.addData” block that has a key and number input. The key is the name of what will be displayed on the driver station. The number is what we are keeping track of. Your op mode is just about ready to run. You can chose to add a couple of telemetry statements that will send information from the Robot Controller to the Driver Station for display on the Driver Station user interface. Telemetry us useful in sending date from the RC Phone on the robot to the DS Phone. Information such as sensors, and motor status can be displayed on the DS Phone. The telemetry block can be found under the category Utilities. For this example we want to keep track of how much power our back motors are receiving we chose “call telemetry.addData” block that has a key and number input. The key is the name of what will be displayed on the driver station. The number is what we are keeping track of.

27 Here we are keeping track of the power given to the two back motors.
Data that is added to the telemetry buffer will not be sent to the Driver Station until “telemetry.update” is called. Here we are keeping track of the power given to the two back motors. Data that is added to the telemetry buffer will not be sent to the Driver Station until we call “telemetry.update”. Here we are keeping track of the power given to the two back motors.

28 Saving Our OpMode

29 Saving Our OpMode After you have modified your op mode, it is very important to save the op mode to the Robot Controller. Press the “Save Op Mode” button to save the op mode to the Robot Controller programming mode server. If your save was successful, you should see “Save completed successfully” in green letters next to the button. If you receive an error message indicating that the “Save project failed. Error code 0” you might not be connected to the blocks programming mode server. Ensure that your Robot Controller Phone is in Programming Mode. Once we have completed our op mode it is very important that we save it to the RC Phone. To do this we click on the “Save Op Mode” button. This can been found on the upper left hand side of the block programming browser. If you receive an error message indicating that the “Save project failed. Error code 0” the most likely cause to this is that you are not connected to the blocks programming mode server.

30 Creating Your First Autonomous

31 Creating your First Autonomous OpMode
Like teleop , our autonomous will be defined within the purple bracket that has the words “runOpMode” at the top. This name can be different depending on what is the name of your OpMode program. We have to define that this is an autonomous program. Below our save OpMode selection we need to select autonomous. Like teleop , our autonomous will be defined within the purple bracket that has the words “runOpMode” at the top. This name can be different depending on what is the name of your OpMode program. We have to define that this is an autonomous program. Below our save OpMode selection we need to select autonomous.

32 Our next step is to define how many motors are in use, and identify them with a name. We will identify four motors for this OpMode. We have to remember to reverse two of the motors when placing our blocks to be initialized. Our next step is to define how many motors are in use and their direction. We will identify four motors for this OpMode just like we did for teleop. It is best to keep the same motors you reverse in teleop reversed in autonomous

33 Moving Forward with Encoders
In this example of autonomous we will move forward using encoders. Encoder are used to measure the movement of the motor. We set a target position for each motor to allow for more precise movements. This is the alternative to running under time which can be less accurate for many factors. Before we can give a target position to our motors we have to declare we are using encoders on our motors when initialized. Each motor has to be set onto “RunMode.RUN_TO_POSITION”. This tells the motors that they will be given a target position to run to. In this example of autonomous we will move forward using encoders. Encoder are used to measure the movement of the motor. We set a target position for each motor to allow for more precise movements. This is the alternative to running under time which can be less accurate for many factors. Before we can give a target position to for our motors we have to declare we are using encoders on our motors when initialized. Each motor has to be set onto “RunMode.RUN_TO_POSITION”. This tells the motors that they will be given a target position to run to.

34 For motors to run the most accurate under encoders you have to reset each motor count back to zero. This must be done during the initialized section of your OpMode. To do this we call “RunMode.STOP_AND_RESET_ENCODER”. Our initialized of our OpMode should declare the direction motors are moving, are they using encoders, and the resetting of encoders. For motors to run the most accurate under encoders you have to reset each motor count back to zero. This must be done during the initialized section of your OpMode. To do this we call “RunMode.STOP_AND_RESET_ENCODER”. In our initialized we will be declaring the direction motors are moving, are they using encoders, and the resetting of encoders.

35 Under this block we can start giving commands to our motors.
Once you have initialized your motors, next we tell the program to “waitForStart”. Under this block we can start giving commands to our motors. The first command we want to run is set target position blocks. This is were we tell our motors how far they will be running. Once you have initialized your motors, next we tell the program to “waitForStart”. Under this block we can start giving commands to our motors. The first command we want to run is set target position blocks. This is were we tell our motors how far they will be running.

36 Setting motors to a power of 0 will stop the motors from running.
Now that we have defined a target position, we need to define the power those motors will be running at. Motors can have a power in the range of -1 to 1. Setting motors to a power of 0 will stop the motors from running. Setting motors to a power of 0.5 will run the motors with half power. Setting motors to a power of 1 will run the motors with full power. Now that we have defined a target position, we need to define the power those motors will be running at. Motors can have a power in the range of -1 to 1. Setting motors to a power of 0 will stop the motors from running. Setting motors to a power of 0.5 will run the motors with half power. Setting motors to a power of 1 will run the motors with full power.

37 When running with encoders, we don’t want the motors to stop running until they have reached their set target position. In this case we want the motors to keep looping until they have reached their positions. We will make a loop that will keep running until one front motors has reached its position and one back motor has reached its position. When running with encoders, we don’t want the motors to stop running until they have reached their set target position. In this case we want the motors to keep looping until they have reached their positions. We will make a loop that will keep running until one front motors has reached its position and one back motor has reached its position. Blue blocks are our logic blocks and can be found in the logic category

38 We need to tell our motors to stop running once they have reached their positions. This command is simply executed by setting all motors to a power of 0. This command will not be executed until we have completed the requirements from our loop we previously created. We need to tell our motors to stop running once they have reached their positions. This command is simply executed by setting all motors to a power of 0. This command will not be executed until we have completed the requirements from our loop we previously created.

39 Full Autonomous (No Mechanisms)
Full Teleop (No Mechanisms)

40 Block Programming Resources

41 Resources FTC SOCAL Website http://www.firsttechsocal.org/
Brain Stormz Website or FTC Block Documents: Blocks Programming Training Manual FTC Blocks Programming Training Manual: REV Robotics Expansion Hub Edition Blocks Programming One Page Description Blocks Video Tutorials

42 Q & A

43 Extra OpMode- A set of code containing instructions for a specific robot behavior. Teleop- The 2 minute time period where the robot is operated by the drive team. Telemetry- The automated communications process by which data is collected at remote points and transmitted to receiving equipment for monitoring. Autonomous- The 30 second time period where the robot is pre-programmed to operate on its own.


Download ppt "Block Programming Hello my name is Stephanie. I have been apart of FIRST for 6 years and have 3 years of programming experience. I am currently a member."

Similar presentations


Ads by Google