robotc for vex online professional development. homework questions thoughts? questions?

32
ROBOTC for VEX Online Professional Development

Upload: corey-lawson

Post on 25-Dec-2015

218 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

ROBOTC for VEXOnline Professional Development

Page 2: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Homework Questions

• Thoughts?

• Questions?

Page 3: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Warm-up Questions

• How do the Shaft Encoders work?

• Compare and contrast the while loop with the if statement.

• What is Boolean logic?

Page 4: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Troubleshooting

• Student: One of my encoders is counting down even though the wheels are spinning forward.

Page 5: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Troubleshooting

• Student: My robot won’t stop turning.

Page 6: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Remote Control

Page 7: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Joysticks

• An out-of-box VEX Cortex comes with basic built-in Remote Control functionality– The VEXnet Joysticks do not have settings

like the older Radio Control Transmitters

• ROBOTC enables full customization of how the VEXnet Joystick signals controls the Cortex– If the Cortex and VEXnet Joystick are linked over VEXnet,

there is no extra code to enable remote control – they’re already linked!

Page 8: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Joysticks

• The VEXnet Joysticks and Cortex (when linked) continually send data back and forth– Two Joysticks with two “Channels” each

• Values range from -127 to 127

– 12 Buttons• A Pressed button = 1, released = 0

– Built in Accelerometer• X and Y values

• No crystal or chance of interference, Cortex and VEXnet Joysticks create their own wireless network over VEXnet

Page 9: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Wireless Programming and Debugging

• The connection between the VEXnet Joysticks and Cortex can be used to wirelessly download the ROBOTC Firmware, ROBOTC Programs, and debugger data!

• Even when you’re not actively “using” the VEXnet Joysticks, it’s transmitting and the batteries are draining. Batteries last ~2 hours; use it wisely!

Page 10: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Configuration

1. Switch your VEX Cortex Download Method to Download using VEXnet or USB

Remember that you will need to download a program and power-cycle the Cortex for the setting to take effect.

Page 11: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Configuration

2. Connect the VEXnet Joysticks to the computer and update its firmware

Page 12: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Configuration3. Establish a VEXnet Link between the Cortex and Remote Control

Page 13: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

VEXnet Configuration

4. Insert VEXnet Keys and Test!

Page 14: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Remote Control Reset• The VEXnet Joysticks should be recalibrated before use

– The VEXnet Remote Control may not have its joystick values calibrated correctly, since it’s last firmware download

• The Cortex and VEXnet Joysticks must be synched before the joystick values can be calibrated

Page 15: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

vexRT[] Command• The vexRT[] Command allows you to access any of the

values from the VEXnet Joysticks• The values from the joystick axis are identified by the the

letters “Ch” + the number closest to them• Channel variable names:

– Ch1 - X-Axis - Right Joystick – Ch2 - Y-Axis - Right Joystick – Ch3 - Y-Axis - Left Joystick – Ch4 - X-Axis - Left Joystick

Page 16: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

vexRT[] Command• The buttons are identified by the letters “Btn” + the number closest

to it + the letter etched into itButton variable names:•Btn5U - Button group 5 - "U" (up) •Btn5D - Button group 5 - "D" (down) •Btn6U - Button group 6 - "U" (up) •Btn6D - Button group 6 - "D" (down) •Btn7U - Button group 7 - "U" (up) •Btn7D - Button group 7 - "D" (down) •Btn7L - Button group 7 - "L" (left) •Btn7R - Button group 7 - "R" (right) •Btn8U - Button group 8 - "U" (up) •Btn8D - Button group 8 - "D" (down)•Btn8L - Button group 8 - "L" (left) •Btn8R - Button group 8 - "R" (right)

Page 17: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Joystick Value Mapping• Direct Value Mapping

– Values from the remote control are directly used to control the motors (1:1 ratio)

Page 18: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Joystick Value Mapping• Indirect Value Mapping

– Values from the remote control are modified before being used to control motors

– Can make the robot easier to control– Appropriate in situations that require more “delicate” movements– Notice: the robot reads the right side of the equal sign first

Page 19: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

ROBOT Motion

• Commands that cause the entire robot to perform a behavior– arcadeControl()– tankControl()

Page 20: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Tank Control

• One Joystick/Channel controls the right side of the robot; another joystick/channel controls the other side of the robot

Page 21: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Arcade Control

• One Joystick/Channel controls the forward/backward movement of the robot; another joystick/channel controls the turning of the robot

Page 22: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Remote Control

• Follow along with the Remote Control > Joystick Mapping Videos for Review

Page 23: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Remote Control Exercise 1

• Part 1: Write a program that uses the left joystick to control the power level of the left motor, and the right joystick to control the power level of the right motor. The program should run forever.

• Part 2: Modify your program so that 1/3 of the left and right joystick values are applied to the motors.

Page 24: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Advanced Remote Control

• More loop control please?– Is remote controlling the robot forever always appropriate?– Question: Where would the wait statement go if we wanted the

robot to be remote controlled for a controlled amount of time?– Answer: Nowhere! We need something else.

• Solution: Timers– Can be thought of as internal stopwatches (4 available)– Like encoders, timers should be “cleared” anytime before they

are used• Watch where you clear them!

Page 25: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Timers• Standard ROBOTC:

• Natural Language:

Page 26: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Timers

• Follow along with the Remote Control > Timers Videos for Review

Page 27: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Button Control• Wasting Time?

– The time it takes to turn on the VEX Cortex and start using the Joysticks is wasted time.

– Could we make the robot wait to start it’s timer until we were ready? Any ideas?

• Wait for a Remote Control Button press– The robot won’t start the timer until we say so– The robot also can’t move until we says so– Could this idea also be used to make a “more friendly” start

button on a non- remote controlled robot?

• Other ideas of how to improve remote control?– Use the buttons to initiate common actions

• Turn 90 degrees, move straight forward, ect

Page 28: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Button Control

• Attach the Arm!• Use the buttons to control the arm

– The VEXnet Joystick buttons send values of 0 or 1

Page 29: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Button Control

• Standard ROBOTC Version

Page 30: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Button Control

• Natural Language Version

Page 31: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Buttons

• Follow along with the Remote Control > Buttons Videos for Review

Page 32: ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?

Homework• VCVT Videos

– Watch remaining Remote Control Videos

• Challenges:– RoboDunk (Autonomous version)– Round-Up– Turn Buttons Investigation

• Remember to Pseudocode• Day 3 Practice Quiz• Remember to shut off your robot and remote

control when they’re not in use!