V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the...

38
VEX COACHES' TRAINING October 12, 2013

Transcript of V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the...

Page 1: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

VEX COACHES' TRAINING

October 12, 2013

Page 2: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Agenda for Today

• 9 – 10 AM : Tina Reeves and the Engineering Notebook

• 10 – Noon : Finish Building, Basic Robot C• 12-12:30 : Lunch• 12:30 – 2:30 Basic Programs, Functions,

Robot C Video Trainer, Setting up Competition Template

• 2:30-3:00 Wrap up, Clean Up

Page 3: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Engineering Notebook

Page 4: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Continue Building

• 4 motors wired as last step in build– 3 to 2 wire converters

• Get charged battery• 9V back-up battery?

Page 5: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Program Basics – Drive Motors• Motors to achieve “tank drive”– Left stick (ch3) drive left wheels– Right stick (ch2) drive right wheels– Other modes: Arcade – 1 stick drives and turns

• Left drive motor connected to Port 1– Port 1 is a dedicated 2 wire port

• Right drive motor connected to Port 10– Port 10 is a dedicated 2 wire port

• For today, VEXnet joystick will control drive

Page 6: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Program Basics – Arm and Claw motors

• 1 motor dedicated to raise and lower arm– Port 7 will be used with a 3 to 2 wire converter– We will assign it to Ch2 on partner joystick

• 1 motor used to open and close the claw– Port 6 will be used with a 3 to 2 converter– We will assign button 5U to open claw– We will assign button 5D to close claw

Page 7: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Writing a Basic Program

• All new files begin withtask main()

{

}

Code you want the robot to run goes between the braces

Page 8: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Writing a Basic Program

• After task main() – All code that needs to be continuously executed

must be enclosed in a while () statement

while (true){

}

Page 9: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Sample Drive Program

Page 10: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Sample Drive - Download

• Once program is entered– Click Robot tab and select Compile• You will be asked to save file• Give it an easy to identify name

• Use Wireless programming cable– Connect USB side to same port on computer– Connect phone jack to VEXnet joystick– Turn on Cortex and joystick and wait for them to

sync

Page 11: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Sample Drive - Download• Select Robot tab and

click Compile and Download

• Program will be sent to Cortex over wifi

• When done, click on Start and disconnect phone jack

• Drive!• May have to reverse

negative sign.

Page 12: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Other Programming Method…

• New programming wireless kit exists– Provides constant power to joystick

• You can use USB A – A cable– Connect cable to Cortex directly– Compile and Download– Reset Cortex afterwards and sync with joystick– Be careful with this method• Continuously removing/inserting VEX key will lead to

undue wear and eventual VEXnet issues

Page 13: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Complete 2 Joystick Program

Page 14: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Notes on Motor Speed

• In VEX, motor speed and direction controlled by a +/- number between -127 and +127– Negative 127 is full on “reverse”– Positive 127 is full “forward”– Sometimes, we switch the sign– Zero is always “Stop”

• Any value in-between can be assigned to a motor

• Analog joystick Ch 1,2,3,4 return such a value

Page 15: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

A simple Autonomous Program

• This program will take drive commands away and make the robot run entirely by a string of commands

• See Sample Program 03 – Simple Auto

Page 16: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Combine Programs to Make a Homemade Competition Template

• Every VEX game has a an Autonomous and Driver modes– 15 seconds Auto– 1min 45 seconds of driver commands

• Sample 04 – Homemade Competition will combine the two previous examples

Page 17: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Homemade Competition Template

• You can copy and paste simple autonomous in the 15 second section

• You can copy and basic drive commands into the 1min 45 second section

Page 18: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

More Efficient Program…• Writing the same code over and over gets

boring• Better to write it once and recycle• In Robot C, Functions are segments of code

that can be called upon whenever needed– You can pass a variable to Functions– Functions can return values• For us today, we will just use simple variable accepting

functions

Page 19: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Program with Functions: Sample 05-Functions Program

int fullSpeed = 127; //global variable for full speed

int halfSpeed = 64; //global variable for 1/2 speed

int quarterSpeed = 32; //global variable for 1/4 speed

void forward(int waitTime){ motor[port1]=halfSpeed; //Turn on motors and go forward

motor[port10]=-halfSpeed; //desired speed

wait1Msec(waitTime); //for desired time

}

Page 20: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Program with Functions: Sample 05-Functions Program

Page 21: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Better Motor Definitions

• Using Port # is cumbersome– Any changes in port assignment means changes

through whole program– Port # doesn’t tell you anything about the

function of the motor when reviewing code• Better to use a labeling system to set motors

and sensors– Under Robot Tab• Motor and Sensor Setup

Page 22: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Motor and Sensor Set Up

Page 23: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Motor and Sensor Set Up

Page 24: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Motor and Sensor Set Up• We label left motor on port 1 – leftDrive– Set it as a 393 regular motor

• We label right motor on port 10 – rightDrive– Set it as a 393 regular motor– Note we selected to reverse it– Program will now handle inverted motors

• Claw on port 6 – clawMotor• Arm on port7 - armMotor

Page 25: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Motor and Sensor Set Up

• Program adds the following header– Don’t modify directly– Any edits should be done in the window

• This will make changing port numbers later on much easier

Page 26: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Sample 06 – Sample Program

Page 27: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Template• Once all code has been debugged and tested to

satisfaction, time to copy and paste it to competition template file

• Competition Template is a sample program found under File->Open Sample Program– Select VEX2 ->Templates– Open VEX_Competition_Template

• You can Copy and Paste your variables, functions, autonomous commands, and driver controls

• You need to retype Motor and Sensor set up

Page 28: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Program

Page 29: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Program

Page 30: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Program

Page 31: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Program

Page 32: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Competition Program

Page 33: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Robot C Curriculum Trainer

• Step by Step Instruction Series of videos and documents that teach how to use Robot C

Page 34: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

VEX Cortex Video Trainer

Page 35: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Virtual Worlds

• You can start practicing your programming skills

• Lets you virtually control a preset robot with defined motors and sensors

• Can play Toss Up• You must change Compile Target to Virtual

World under Robot Tab

Page 36: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Virtual Worlds

Page 37: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Virtual Worlds

• When ready to test, compile and download code– Virtual World will launch– Can click start and test– Login as Guest

• Can also drive robot around to practice– Must select Robot Skills mode– AWSD steers, <> raises arm, ; ‘ open close claw

Page 38: V EX C OACHES ' T RAINING October 12, 2013. Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.

Virtual Worlds