
Essentially, it is how the robot makes decisions, based.
) and bump switches (floor1, floor2. ) are analog buttons and return a value of 0 if not pressed and 1 if pressed. The motor (mainMotor) rotates the gear which causes the mechanism to travel upwards on the slide. When the shaft sticking out the motor mechanism moves up and down, it presses limit switches and causes it to return a value of 1. Programming VEX Robotics Wiki Most Popular Law Newest at Courses.

In this post, I go through the following: In RobotC you must program these items yourself. Unlike easyC, the standard text-based RobotC does not have joystick blocks that one can simply drag and drop and poof! you have arcade drive.
Programming In Robotc Code Does X
And god forbid there’s a programming emergency at a competition, and none of the team’s programmers are there (or you, if you’re the only programmer) now people who are not experts at programming are going to have to start poking around in your code, changing stuff, and praying. Without comments, the next programmer will waste lots of time (a) figuring out what you did, or (b) assuming your code does X when it really does Y, and adding more code, assuming the stuff that’s there does X. When your team has multiple programmers jumping in and out of the code, comments are vital so that other programmers can understand what you have done and why you’ve done it. When you write some code, and the robot doesn’t do what you’re expecting, having comments placed throughout your program will help you evaluate the code you’ve written — does the code below do what the comment says it should do? Mom … Do I hafta? Why? Why? Why?
Programming In Robotc How To Do Something
So then YOU’RE going to waste a lot of time trying to reconstruct your own thought process to figure out WHAT THE HECK YOU DID. Do you think you’re going to remember what that nifty, complex section of code does, exactly? Or why you had to do ABC in a sort-of convoluted way? HAH! No, you’re not. Now in January you’re getting ready for States and you see that your code needs to be modified. Imagine this: you figure out how to do something really cool and complicated in your code during the summer, and your team goes along happily most of the year using that nifty code. Really, you are doing YOURSELF a huge favor by putting comments in your code.
To set a motor to a fixed power level, one would type something like: motor = 100 But how about connecting it to the joystick? In RobotC, controller buttons and joysticks start with the reference vexRT — VEX Remote Transmitter. In RobotC, you must type this stuff in yourself. In the setup window, you simply put some descriptive name, like “rightFront” into the setup window, and from that point on, you can just reference it by that name.In easyC, if you want to turn on a motor, you drag over a motor block, tell the popup window which one you’re using, and give it a power level. RobotC Motor CommandsIn the motors & sensors setup window, you can give each motor a name (recommended) in lieu of having to remember that the right-front motor is plugged into, say, port 7.
If the syntax is wrong, your program will not compile or (worse) it will compile but will not do what it’s supposed to do when downloaded to the robot. So the following 2 lines of code do the same thing, except the second line is for the partner joystick: motor = vexRT // main joystickMotor = vexRT // partner joystick Don’t forget the semicolons and braces!Since RobotC requires you to type the information yourself (instead of the motor block “typing” it for you), spelling and punctuation matter. In RobotC, the format for the partner joysticks exactly the same as the main joystick, but with “Xmtr2” appended to the end of the Channel (Ch) or Button (Btn) code (“Xmtr2” = “transmitter 2”). Note that button groups 5 & 6 only have U and D.To set a motor equal to the value of a joystick, one would type something like: motor = vexRT Partner JoystickSo how do I control the robot using the partner joystick? In easyC in the joystick blocks, there’s just a dropdown asking you if you want it on joystick 1 (main) or joystick 2 (partner). vexRT to get the 0/1 value from button group 6, top ( Up) button possible values Btn5–Btn8, and either U ( Up), D ( Down), L ( Left), or R ( Right). vexRT, for getting the 127 to -127 value from the position of joystick channel 2 possible values Ch1 – Ch4.
Like tank drive? You’re sitting pretty. Hmm, 127 to -127, what convenient numbers! Tank DriveTank drive is the easiest motion to program. Movement of a joystick along one of these axes returns a value between 127 (all the way “north” or “east”) to -127 (all the way “south” or “west”). By “channel” I mean the north/south and east/west movement of each joystick lever, identified by the numbers 1 and 2 (next to the right-hand stick) and 3 and 4 (next to the left-hand stick). Joystick Channels & ValuesIn RobotC, it’s easiest to think of each joystick channel like a sensor.
