RobotC-Wrapper - An easy to read, fully functional RobotC for Vex wrapper.
#!/usr/bin/perl -w use strict; use RobotC::Wrapper::Utils; my $SV = "SensorValue"; my $r = Robot::Perl::Utils->new( config => "/home/jbert/dev/RobotPerl/Robot/Perl/data.yaml" ); $r->basic_movements; $r->start_task; $r->call( "drive" ); $r->start_while( "true" ); $r->start_if( "true" ); $r->call( "turn_left" ); $r->end; $r->end; $r->end;
The Robot::Perl base library has a series of functions that you can call which will spit out RobotC. Start by initiating it. use Robot::Perl; my $r = RobotC::Wrapper->new( config => '/the/path/to/the/yaml.yaml' );
When the constuctor is initiated, a config file (yaml file) must be defined as seen aboved. If the path is not defined, an error will occur and compilation will fail. The yaml file should be formatted as such: --- motor_port: right: left: 2: 3: 4: 5: channel: 0: 1: 2: 3: 4: 5: speed: forward: reverse: stopped: auto: state: reflect: state: port: All values are inputted by the user (the only user input the program takes).
Starts a void function. $name is the name of the function being declared.
Starts the main task. This function must always be present while using RobotC-Wrapper.
Starts an if statement. $condition is, of course, the condition.
Starts a for loop. Takes two arguments: a start value ( usually 0 ), and an end value,
Starts a while loop. Takes the condition.
Prints a brace "}" and starts a newline.
Declares a new variable, takes three arguments: a number symbolizing data type ( 1-3; 1 => int, 2 => char, 3 => long ), name, and value.
Declares a variable containing the current battery level, takes the variable name as the only argument.
Kills the function specified as a parameter.
Turns off all tones and sounds.
Plays a tone, takes two arguments: frequency, and duration.
Plays tone, takes one parameter: must be "buzz", "beep", or "click".
Turns sound on and off, true or false as a parameter.
Starts an if statement with a predeclared condition (if sound is available).
Does the same thing as if_sound, but checks for controller activity.
Sets up sensors. Should be the first thing called after start_robot. Takes three parameters: in port, name, and sensor type ("Touch, SONAR, etc").
Reflects a designated port, takes two parameters: port name ( "port2", "port3", etc ), and boolean ( most likely true ).
Toggles autonomous mode depending on the boolean parameter.
Sets motor value, takes two parameters: port name and speed ( -127 - 127 ).
Speeds up to motors, takes two arguments: port name, and a number to be added to the current speed.
Clears and starts a timer.
Takes one argument: a time limit which makes the condition false.
Pauses the robot for the given amount of seconds. ( yes, SECONDS! )
Denotes a given motor port to a transmitter channel.
Calls a given function.
Equal to the cosine of $var.
Equal to the sin of var.
Equal to the tangent of $var.
Converts parameter from degrees to radians
Converts parameter from radians to degrees
James Albert <firstname.lastname@example.org> Casey Vega <email@example.com>