Using Encoders to go Straight

Slides:



Advertisements
Similar presentations
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Advertisements

While Loops and If-Else Structures
Team 5220 Roboknights. Outline  Getting Started  Hardware Setup/Wiring  Software Setup/Pragmas  Programming with RobotC  Grammar/Syntax  Basic Statements.
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Chapter 2 Review Questions
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.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
Testbed: Exercises.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
CS140: Intro to CS An Overview of Programming in C by Erin Chambers.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Vex Robotics program three: using motors and sensors together.
CPSC 233 Tutorial January 21 st /22 nd, Linux Commands.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August.
Sensor Information: while loops and Boolean Logic.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Variables. A variable is a space in your robot’s memory where you can store data, such as whole numbers, decimal numbers, and words. Variable names follow.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Introduction to Programming in RobotC
Variables and Functions
Data Types and Expressions
Variables and Functions
Variables and Functions
Robotics Programming Using Shaft Encoders
ROBOTC for VEX Online Professional Development
EGR 2261 Unit 4 Control Structures I: Selection
Introduction to Gobbit Programming
Variables and Functions
Movement using Shaft Encoders
Autonomy using Encoders
Programming – Touch Sensors
Variables and Functions
Variables and Functions
Variables and Functions
Variables and Functions
Using variables, for..loop and functions to help organize your code
While Loops and If-Else Structures
Basketball Drill Programming Alternatives
An Introduction to Java – Part I, language basics
Variables and Functions
Auto Straightening using VEX Shaft Encoders
Programming – Remote Control Statements
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
RobotC While loop When and how to use the while loop
SE1H421 Procedural Programming LECTURE 4 Operators & Conditionals (1)
if-else Structures Principles of Engineering
Robotics Programming Using Shaft Encoders
Robotics Programming Using Shaft Encoders
Chapter 2 Programming Basics.
While Loops and If-Else Structures
Robotics Programming Review and Quiz.
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
While Loops And If-Else Structures
Variables and Constants
Is there an alternative to copy-paste for repeating code?
Presentation transcript:

Using Encoders to go Straight Limit drifting when trying to go straight In this section we will look at if else Variables and types Applying all of this to help the robot go straight

Pseudo Code (What we are trying to get the robot to do) While the robot has not reached the destination If the left motor has gone farther, slow the left motor and have right motor go at speed If the right motor has gone farther, slow the right motor and have the left motor go at speed If the motors are the same, have both motors go at speed

If Statements When your robot reaches an if Statement in the program, it evaluates the condition contained between the parenthesis. If the condition is true, any commands between the braces are run. If the condition is false, those same commands are ignored. Very similar to how a while loop works, but does not repeat the code!

Going Straight: Translating to Code Pseudo Code While the robot has not reached the destination If the left motor has gone farther, slow the left motor and have right motor go at speed If the right motor has gone farther, slow the right motor and have the left motor go at speed If the motors are the same, have both motors go at speed

If-else statements The if-else Statement is an expansion of the basic if Statement. The “if” section still checks the condition and runs the appropriate commands when it evaluates to true Using the “else” allows for specific code to be run only when the condition is false. Either the “if” or the “else” branch is always run; no more, no less.

Chaining if..else if ..else

Implementing if..else

But… If the motors are not close in their Power to Speed then the difference between 50 and 63 might not be sufficient. So it will take some tweaking. Rather than changing the 63 to another value when modifying the ‘at speed’ needed, you can use variables.

RobotC Variables int float string char bool Stores integer values: 5, 0, -100 float Stores floating point (real) values: 3.01, -5.21, 0 string Stores words: “Hello World” char Stores single characters: “A”, “@” bool Stores Boolean (true, false) values

Code After Using Variables for Speed Values Declaring the variables. type name Initialize the variables. Try modifying the fullSpeed and slowerSpeed values to see how if changes the robot behavior.

Summary motor[] SensorValue[] wait1Msec() while if if..else Conditions Conjunctions Motors and Sensor Quadrature Encoder Strategies on going straight Timing vs. distance

Driving Straight Activity Use the Clawbot Driving Straight II using encoders When complete, demo to Smith, continued on Physical Movement Challenges, and installing Shaft Encoders.