James Albert > RobotC-Wrapper-0.01 > RobotC-Wrapper

Download:
RobotC-Wrapper-0.01.tar.gz

Annotate this POD

View/Report Bugs
Source   Latest Release: RobotC-Wrapper-0.06

NAME ^

RobotC-Wrapper - An easy to read, fully functional RobotC for Vex wrapper.

SYNOPSIS ^

    #!/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;

DESCRIPTION

ROBOT::PERL ^

    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'
    );

THE USE OF YAML FILES ^

    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).

LIST OF FUNCTIONS ^

start_void($name)

    Starts a void function. $name is the name of the function being declared.

start_task()

    Starts the main task. This function must always be present while using RobotC-Wrapper.

start_if($condition)

    Starts an if statement. $condition is, of course, the condition.

start_for(init => $init, end => $end, )

    Starts a for loop. Takes two arguments: a start value ( usually 0 ), and an end value,

start_while($condition, )

    Starts a while loop. Takes the condition.

end()

    Prints a brace "}" and starts a newline.

var(type => $num, name => $name, value => $value)

    Declares a new variable, takes three arguments: a number symbolizing data
    type ( 1-3; 1 => int, 2 => char, 3 => long ), name, and value.

battery(name => $variable_name)

    Declares a variable containing the current battery level, takes the variable
    name as the only argument.

kill(task => $any_function)

    Kills the function specified as a parameter.

mute()

    Turns off all tones and sounds.

sound(freq => $frequency, dur => $duration)

    Plays a tone, takes two arguments: frequency, and duration.

tone(tone => "beep")

    Plays tone, takes one parameter: must be "buzz", "beep", or "click".

sound_power(bool => "true")

    Turns sound on and off, true or false as a parameter.

if_sound()

    Starts an if statement with a predeclared condition (if sound is available).

if_active()

    Does the same thing as if_sound, but checks for controller activity.

pragma(in => "in2", name => $name, type => "Touch")

    Sets up sensors. Should be the first thing called after start_robot.
    Takes three parameters: in port, name, and sensor type ("Touch, SONAR, etc").

reflect(port => $port2, bool => "true")

    Reflects a designated port, takes two parameters: port name ( "port2", "port3", etc ), and boolean ( most likely true ).

auto(bool => "true")

    Toggles autonomous mode depending on the boolean parameter.

motor(port => $port2, speed => $speed)

    Sets motor value, takes two parameters: port name and speed ( -127 - 127 ).

speed_up(port => $port2, speed => $increment)

    Speeds up to motors, takes two arguments: port name, and a number to be added to the current speed.

clear_time()

    Clears and starts a timer.

time_while($what_time_to_stop, )

    Takes one argument: a time limit which makes the condition false.

wait($duration)

    Pauses the robot for the given amount of seconds. ( yes, SECONDS! )

cont(port => $port2, channel => $Ch2)

    Denotes a given motor port to a transmitter channel.

call($function_name)

    Calls a given function.

THESE FUNCTIONS SHOULD BE USED AS VALUES ^

cos($var)

    Equal to the cosine of $var.

sin($var)

    Equal to the sin of var.

tan($var)

    Equal to the tangent of $var.

d_r($var)

    Converts parameter from degrees to radians

r_d($var)

    Converts parameter from radians to degrees

AUTHORS

    James Albert <james.albert72@gmail.com>
    Casey Vega   <casey.vega@gmail.com>
syntax highlighting: