View Single Post
  #10   Spotlight this post!  
Unread 23-01-2012, 18:27
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Help Needed with some Simple Programming

I assume if you are using the SimpleRobot template, you will have something similar to the code below. Since I don't have Wind River in front of me, I am writing the code from my memory, so some names may be wrong and the code may not be exactly the same as the template but it gives you an idea where to put things.
Code:
#include "WPILib.h"
#include "macros.h"   //Or put the macros here directly.
 
class MyRobot: public SimpleRobot
{
    Joystick leftStick;
    Joystick rightStick;
    RobotDrive drive;
 
    MyRobot():
        leftStick(1),   //Please use correct Joystick port
        rightStick(2),  //Please use correct Joystick port
        drive(1, 2)     //Please use correct PWM channels
    {
    }
    ...
    ...
    void OperatorControl()
    {
        while (IsEnable() && IsOperatorControl())
        {
            float leftPower = DEADBAND_INPUT(-leftStick.GetY());
            float rightPower = DEADBAND_INPUT(-rightStick.GetY());
            drive.TankDrive(leftPower, rightPower);
            ...
            ...
            Wait(0.05);
        }
    }
};
__________________

Last edited by mikets : 23-01-2012 at 18:35.
Reply With Quote