mybestnomad.blogg.se

Robotc functions
Robotc functions








robotc functions

In this case, this function is called by startup() which is a function you include at the beginning of your RobotC programs. Rather, there are one or more other functions that call this one. Int nFileSize = defaultFileSize // Only need space to store 4 Float values. Int defaultFileSize = 40 // Only need space to store 4 Float values. Define internal constants and temporary handles for the file processes.Ĭonst string sFileNameRD = "RobotDimensions.txt"

#Robotc functions code

could use the same code as long as each robot's physical dimensions are stored in this file. developed independent of the physical characteristics of the Robot.

robotc functions

Robot dimensions are stored in a text file on the NXT brick. Variables used to Configure Robot Dimensions While it is possible to declare all variables at the top of the file, it sometimes is easier to read and understand the program if variables are declared next to the functions that use them. Int lineIsAtLevel = 20 // Percentage of light that is used to determine presence of a line.įloat motorError = Variables Defined Next to the Functions That Use Them If false, robot will stop after each action Int sideOfLine = RIGHTSIDE // Initialize a variable to keep track of which side of the line the robot is followingīool keepGoing = false // Some functions allow for the robot to keep moving when true Int direction = STOPPED // Initial direction of the robot is set to Stopped Int powerLevelAccessory = 20 // Level of power used by the accessory motor Int powerLevelRev = 0 // Level of power used by all Reverse motor actions Int powerLevel = 0 // Level of power used by all motor actions the config function will change this value Int mDir = FORWARD // Orientation of the motors.

robotc functions

Int BACKWARD = -1 // These are declared as variables so they can be reversed for certain robot designs Int FORWARD = 1 // General navigation used to keep track of which direction the robot is going Internal constants used to write more readable code.Ĭonst int RIGHTSIDE = 1 // Line following constants used to tell which side of line to follow Define constants and variables to be used in the functions below Most are assigned a value in their declaration. The statements below show the definitions of various constants and variables. This is also somewhat necessary since a constant or variable cannot be used by any part of the program before it has been defined (declared). The format of this structure is one where the constants and variables are declared (for the most part) at the beginning of the file. Most function libraries have a structure to help make them easier to understand by programmers. The compilter will do that at the time your program is compiled. You can simply use one line of code to tell the compiler to include the contents of the entire library into your program. Also, if these functions and variables are stored in a file separate from your program, then you do not have to include all of the code below in order to access it. Many programs can refer to and use the same function library. The purpose of keeping these functions and variables in one file is to make your programs more modular. The functions and variables in the library can then be referenced and called upon as needed in your program. Our Function Library (Updated Spring 2013)Ī function library is a set of functions, variables, constants, and algorithms that are included with the basic RobotC programs. A Non-Functioning EV3 (i.e., frozen or dead).










Robotc functions