Download presentation
Presentation is loading. Please wait.
1
Programming Autonomy By Joshua Shaw
2
Autonomy Many of todays robots operate independent of an operator
This PowerPoint is optional for the BEST Robotics Competition However, adding autonomy to the robot can simply tasks for the driver
3
Beginning an Autonomous Program
Open EasyC Click on New Standalone Project
4
Beginning an Autonomous Program cont’d
Select Joystick Project (WIFI) Click OK
5
Variables An autonomous program requires variables to operate
To create a variable double click on variable in the program The Local Variable dialog box will appear
6
Variables Cont’d Click on the box under the header Type
Select int from the dropdown menu This creates an integer variable Give the variable a name under Name This example uses ButtonControl Set value to 0
7
Create another Variable
Repeat the previous slide for a new variable Use the name ServoControl Click OK
8
Create a While Loop Then click and drag While Loop from the list and place it on the vertical line between Variable box and End box. At this point a dialog box appears Type a true expression such as (3>2) Click OK
9
Get information from a button on the controller
Drag and Drop Get Joystick Digital into the While Loop The Get Joystick Digital dialog box will appear
10
Get information from a button on the controller cont’d
Click the drop down menu for Retrieve to Select ButtonControl Click OK
11
Adding an If Statement Drag and drop if from the Program Flow block under Get Joystick Digital statement The if dialog box will appear
12
Adding an If Statement cont’d
For this example type ButtonControl == 1 && ServoControl <= 124 If the button is pressed and if ServoControl value is less than or equal to 124. Than the program will do what ever we put into the If Statement Click OK
13
Adding an Assignment Now Drag and Drop an Assignment from Program Flow into the If statement The Assignment Dialog Box will come up.
14
Adding an Assignment Cont’d
Here we will change the ServoControl value For this example type ServoControl = ServoControl + 4 Click OK
15
Add another Get Joystick Digital
Drag and Drop Get Joystick Digital into the While Loop under the if statement The Get Joystick Digital dialog box will appear
16
Add another Get Joystick Digital Cont’d
Choose 2 for the Button # dropdown menu Select ButtonControl from the Retrieve to dropdown menu Click OK
17
Add Another If Statment
Add Another If Statement under Get Joystick Digital
18
Adding an If Statement cont’d
For this example type ButtonControl == 1 && ServoControl >= -124 If the button is pressed and if ServoControl value is greater than or equal to 124. Click Ok
19
Adding another Assignment
Drag and Drop an Assignment into the new If statement The Assignment Dialog Box will come up
20
Adding another Assignment cont’d
Here we will change the ServoControl value For this example type ServoControl = ServoControl - 4 Click OK
21
Adding a Servo Module Now open the + for Output
Drag and Drop Servo Module under the second If Statement The Servo Module dialog box will appear
22
Adding a Servo Module cont’d
Select the Motor Number which the servo will be put into In this example use 2 Remember 1 and 10 can not be used
23
Adding a Servo Module cont’d
Select the circle User Value Select ServoControl under the drop down menu Click OK
24
The Program thus Far If we put this program on the Cortex the servo would almost immediately set to one side and stay there This makes it difficult to operate the program
25
Wait… no really a wait statement
A Wait statement will allow the driver to react to the servo Go to Program Flow Drag and Drop Wait into the While Loop above the first ButtonControl The Wait Dialog Box will appear
26
Wait Dialog Box Right now the program is being told to wait milliseconds (ms) or 1 second This is long enough to fix our initial problem, but it is a bit too long to wait
27
Wait Dialog Box cont’d The average reaction time for a human (visually) is around seconds (250 ms) For our example set the number to 300 (300 ms) This will give the driver time to react and not have to wait to long Click OK
28
The Program The program should look like this
You can modify this program to add autonomy to your robot
29
Build and Download Build and Download the program to the cortex and try it out The servo should look like it is ticking from one position to another
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.