RobotC Remote Control. Learning Objectives: Focusing on Virtual World with Physical Examples Understand Real-Time Joystick Mapping Understand how to use.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Jason Howard. Agenda I. How to download robotc II. What is tele-op used for? III. How to build a basic tele-op program IV. Getting the robot to drive.
Automation and Robotics
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
RobotC Programming for LEGO Mindstorms NXT Carnegie Mellon Dacta Lego Timothy Friez Miha Štajdohar SOURCES:
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Testbed: Exercises.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Making a Boat Racing Game in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2010.
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
Teacher/Mentor Institute Using easyC Joel Kirkland July 30-31, 2015.
RobotC Advanced Concepts SSI Robotics September 7, 2013 Capitol College.
ROBOTC Training Session 1 Timothy Friez 1/10/08 Revision 1.
FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.
Programming - Buttons. Ch 5-8 Joysticks work by moving the stick along an axis and thus any value between 127 & -127 can be sent. With the buttons they.
Introduction to Vexnet
Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Take out your notes.
Programming with LabVIEW Intro to programming and.
Programming - Motion Intro to Robotics. Motors and Sensors Setup The first thing we need to do is tell ROBOTC that we have motors on our robot. Choose.
Programming your Robot
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Vex Robotics program three: using motors and sensors together.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
Robotc Vex Arm (Surgical robotic 3-axis arm) By: Maxim, Andrew, Paul.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Introduction to Vexnet
Introduction to Programming in RobotC
ClawBot Beginning Programing.
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Robotics Programming Using Shaft Encoders
StartStruck in a Virtual World
Automation and Robotics
StarStruck in a Virtual World: Fantasticbot Version
Movement using Shaft Encoders
Using Encoders to go Straight
RobotC Sensors.
Getting Started in RobotC
By Willem Scholten Learning Access Institute
Using variables, for..loop and functions to help organize your code
Automation and Robotics
Sensors and Logic Switches
Basketball Drill Programming Alternatives
Controlling your quadcopter
Getting Started in RobotC
Auto Straightening using VEX Shaft Encoders
Programming – Remote Control Statements
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Programming - Buttons Intro to Robotics.
Robotics Programming Using Shaft Encoders
Programming - Buttons Intro to Robotics.
Robotics Programming Using Shaft Encoders
Remote Control For this activity we will use the Squarebot
While Loops and If-Else Structures
Robotics Programming Using Shaft Encoders
Compiled from various Internet sources Presented by Mr. Hatfield
While Loops and If-Else Structures
While Loops And If-Else Structures
Controlling your quadcopter
Introduction to Programing the Cortex for BEST
Presentation transcript:

RobotC Remote Control

Learning Objectives: Focusing on Virtual World with Physical Examples Understand Real-Time Joystick Mapping Understand how to use timers Understand how to incorporate buttons into controlling robot arms

Looking at the Joysticks on the Remote Ch1 Right = 127 Middle = 0 Left = -127 Ch2 Up= 127 Middle = 0 Down = -127 Ch3 Up = 127 Middle = 0 Down = -127 Ch4 Right = 127 Middle = 0 Left = -127

Accessing the Value for the Remote Commands Physical vexRT[ChannelNumber] Virtual //Place before task main() #pragma debuggerWindows(“joystickSimple”); #include “JoystickDriver.c”; //Place inside the loop prior to joystick. Command getJoystickSettings(joystick); joystick.joy#_axis#

Example Using the Remote Values to Drive the Motors Physical Robot Virtual World

Joystick Mapping: Virtual ChannelLeft/DownMiddleRight/Up vexRT[Ch1]-127…0…127 vexRT[Ch2]-127…0…127 vexRT[Ch3]-127…0…127 vexRT[Ch4]-127…0…127 ChannelLeft/DownMiddleRight/Up joystick.joy1_x2-127…0…127 joystick.joy1_y2-127…0…127 joystick.joy1_y1-127…0…127 joystick.joy1_x1-127…0…127 Up - Ch2 - Dn x1 y1 x2 y2 Joystick Mapping: Physical //Place before task main() #pragma debuggerWindows(“joystickSimple”); #include “JoystickDriver.c”; //Place inside the loop prior to joystick. Command getJoystickSettings(joystick); Up - Ch3 - Dn Note: If you copy- paste these into your program, you will need to retype in the “”.

Online Time: Configure the motors and code the following Physical Robot Virtual World Configure the motors as before: leftMotor, port 1 rightMotor, port 10 and reversed

Driving in the Virtual World Compile and Download the Program Select Virtual World (Utility – Huge Table is good for starters) Open ‘Joystick Control –Basic ‘ Debugger Window’ Robot-> Debugger Windows - > ‘Joystick Control – Basic’ Refresh List if the remote does not show up.

Robot Creeping? Y1 and Y2 values might not go exactly to ‘0’ when you release the buttons which can cause your robot to creep. Can correct this in the code. Pseudo Code If the joystick reading is close to 0, say +/- 20 Give a 0 power value to the motor Else Give the joystick reading to the motor

A Little RobotC Math to Help RobotC Function DescriptionExample abs() Finds the absolute value of a number float x; x = abs(5-10); pow() Calculates a powerfloat x; x = pow(10,3); //Calculates and returns 10^3 sqrt() Finds the square root of a number float x; x = sqrt(8);

Physical: Getting Rid of the Creep Using a variable to make threshold changes easier Using the abs command to simplify the condition. if (vexRT[Ch3] >(-threshold)) && (vexRT[Ch3] < (threshold)) Would give the same results. Executes this line of code when the above condition is true. Executes the commands in the ‘else’ when the above condition is false. Do the same for the rightMotor

Virtual Getting Rid of the Creep Add the pragma directive and include file. If you copy and paste from the PowerPoint you will need to retype in the “”. Add the getJoystickSettings(joystick); command inside the while loop. Replaced vexRT(Ch2) with joystick.joy1_y2 Replaced vexRT(Ch3) with joystick.joy1_y1

More Control Options To fight motors timing out, you can modify the drive code to lower the power sent to the motors. Go half-power Create an equation that maps remote input to output. Had some math wizzes that used a 5 th degree polynomial to provide more control when going slow. Can put together a bunch of ‘stepped’ if elses to give different power values for different ranges of input values.

Physical No Creep, Half Power Half Power

Virtual No Creep Half Power: Half Power Online Time: Test it on the Utilities -> Huge Table

RobotC Timers: Using an Internal Timer to Stop the Robot RobotC has 4 Timers (T1, T2, T3, T4) Commands clearTimer(T1);//Resets timer T1 to 0. time1[T1];// Gives the amount of time in milliseconds since the last reset.

Physical Using Timer to limit how long you can drive Will let the user drive for 5 seconds (5000 milliseconds) Instead of while(true) which goes forever, this loop will only repeat when T1 is less than 5000.

Virtual World With Timer Instead of while(true) which goes forever, this loop will only repeat when T1 is less than 5000.

Online Time Complete and test the drive code with the Anti-Creep code Test to see if the code works in the Utility -> Huge Table In the Virtual Worlds go to the Remote Control Tab Bull in the Ring: Knocking out cans in < 10 sec Robo Slalom I: Driving through a course. A good time to practice refining remote to controller mapping to make driving more accurate Round up: How many laps can you complete in one minute? The code will need to stop you from driving!

Buttons Learning Objectives Be able to use the buttons to control motors on your robot. Complete challenges that incorporate buttons.

Joystick Buttons: Physical Buttons return a value of ‘1’ when pushed and ‘0’ when not pushed ButtonDescriptionExample 5UTop button on back leftvexRT[Btn5U] 5DBottom button, back leftvexRT[Btn5D] 6UTop button, back rightvexRT[Btn6U] 6DBottom button, back rightvexRT[Btn6D] 7UButton 7 upvexRT[Btn7U] 7DButton 7 downvexRT[Btn7D] 7RButton 7 rightvexRT[Btn7R] 7LButton 7 leftvexRT[Btn7L] 8UButton 8 upvexRT[Btn8U] 8DButton 8 downvexRT[Btn8D] 8RButton 8 rightvexRT[Btn8R] 8LButton 8 leftvexRT[Btn8L]

Using the buttons to control the arm motor First we need to go to Motors and Sensors setup to configure the arm and claw motor. Clawbot Arm: Port 7 Claw: Port 6 Robot -> Motors and Sensors setup 1)Name and set the claw and arm motors. 2)Reverse the Arm Motor for Virtual Clawbot. Might need to reverse for physical robot also. 3) Click Apply and OK when finished.

Looking at Arm Control using buttons: Pseudo- Code If button 6U is pushed raise the arm (Send a signal of 127) Else if button 6D is pushed Lower the arm (Send a signal of -127) Else Stop the arm (Send a signal of 0)

Looking at the Arm: Pseudo-Code to Code If button 6U is pushed raise the arm (Send a signal of 127) Else if button 6D is pushed Lower the arm (Send a signal of -127) Else Stop the arm (Send a signal of 0) Style Note: Indent between the {} to make the code easier to read.

Virtual World Buttons joy1Btn(4) joy1Btn(1) joy1Btn(3) joy1Btn(2) Mode joy1Btn(9) joy1Btn(8) joy1Btn(6) joy1Btn(7) joy1Btn(10) joy1Btn(12) joy1Btn(11) joy1Btn(5) joy1_TopHat

Joystick Buttons Virtual World Buttons return a value of ‘1’ when pushed and ‘0’ when not pushed, except the TopHat. ButtonDescriptionExample 1Leftjoy1Btn(1) 2Bottomjoy1Btn(2) 3Rightjoy1Btn(3) 4Topjoy1Btn(4) 5Back, top leftjoy1Btn(5) 6Back, top rightjoy1Btn(6) 7Back, bottom leftjoy1Btn(7) 8Back, bottom rightjoy1Btn(8) 9Small button, top leftjoy1Btn(9) 10Small button, top rightjoy1Btn(10) 11Left joystick buttonjoy1Btn(11) 12Right joystick buttonjoy1Btn(12) TopHatReturns values -1 (Not pushed) or 0, 1, … 7 depending on which part is pushed. joystick.joy1_TopHat joy1_TopHat

Back to the Arm Movement Pseudo-Code but for Virtual Remote If button 6 is pushed raise the arm (Send a signal of 127) Else if button 8 is pushed Lower the arm (Send a signal of -127) Else Stop the arm (Send a signal of 0)

Arm Pseudo-Code to Code: Virtual World If button 6 is pushed raise the arm (Send a signal of 127) Else if button 8 is pushed Lower the arm (Send a signal of -127) Else Stop the arm (Send a signal of 0)

Where does this code go? Since you want the robot to continually check for the buttons being pressed, it needs to go inside the while(true) loop.

Online Time: Test Arm Movement Implement the code for the arm movement and test it in the Virtual or Real World. Try to use what you have learned to program the Claw motor as well using the back left buttons. Test your robot on the ‘Huge Table.’

Any problems? Arm floating down when button not pushed? How can you combat this? Arm didn’t move

Claw Motor Pseudo Code If the back, top, left button is pushed Close the claw (127) Else if the back-bottom-left button is pushed Open the claw (-127) Else Leave the claw (0) Virtual Physical

Challenge using Buttons Minefield Challenge: Clearing the table of bad mines while not disturbing others