Well my team seems to believe it is not necessarily a problem with our code but, with deploying the c++ code itself onto the robot but yes hear is our prototype drive code:
Code:
#include <WPILib.h>
#include <Vision/RGBImage.h>
#include <Vision/BinaryImage.h>
#include <Math.h>
class RobotDemo : public IterativeRobot
{
Joystick* Stick_xy;
Joystick* Stick_z;
Jaguar* motor1;
Jaguar* motor2;
Jaguar* motor3;
Jaguar* motor4;
Jaguar* motor5;
PWM* connect1;
PWM* connect2;
PWM* connect3;
PWM* connect4;
PWM* connect5;
//RobotDrive* myRobot;
Servo* xCam;
Servo* yCam;
DriverStation* Station;
DriverStationLCD* Station_out;
public:
RobotDemo(void) // as they are declared above.
{
Stick_xy = new Joystick(1);
Stick_z = new Joystick(2);
motor1 = new Jaguar(1);
motor2 = new Jaguar(2);
motor3 = new Jaguar(3);
motor4 = new Jaguar(4);
motor5 = new Jaguar(5);
connect1 = new PWM(1,1);
connect2 = new PWM(2,2);
connect3 = new PWM(3,3);
connect4 = new PWM(4,4);
connect5 = new PWM(5,5);
//myRobot = new RobotDrive(1,2,3,4);
Station = DriverStation::GetInstance();
Station_out = DriverStationLCD::GetInstance();
}
~RobotDemo(void)
{
delete Stick_xy;
delete Stick_z;
delete motor1;
delete motor2;
delete motor3;
delete motor4;
delete motor5;
//delete myRobot;
delete Station;
delete Station_out;
delete xCam;
delete yCam;
}
void Autonomous(void)
{
}
void TeleopContinuous(void)
{
if (Stick_xy->GetRawAxis(2)!= 0)//if the stick is moved up or down
{
motor1->SetSpeed(Stick_xy->GetRawAxis(1));
motor3->SetSpeed(Stick_xy->GetRawAxis(1));
}
if(Stick_xy->GetRawAxis(1) != 0)//if the stick moves left or right
{
motor2->SetSpeed(Stick_xy->GetRawAxis(2));
motor4->SetSpeed(Stick_xy->GetRawAxis(2));
}
if(Stick_z->GetRawAxis(2)!= 0)//if the z stick moves left or right
{
motor1->SetSpeed(Stick_z->GetRawAxis(1));
motor3->SetSpeed(-(Stick_z->GetRawAxis(1)));
}
if(Stick_z->GetRawAxis(1) != 0)
{
motor5->SetSpeed(Stick_z->GetRawAxis(1));
}
else
{
Stop();
}
}
void Test() {
}
private:
void Stop()
{
motor1->SetSpeed(0);
motor2->SetSpeed(0);
motor3->SetSpeed(0);
motor4->SetSpeed(0);
}
/*void GetCamPosition()
{
float xPos = 170 * Stick_z->GetRawAxis(1)+85;
float yPos = 170 * Stick_xy->GetRawAxis(2)+85;
if(Stick_z->GetRawAxis(2)!= 0)
{
while(xCam->SetAngle(2) >insert ammount && xCam->SetAngle(2)<insert Right angle)
{
xCam->SetAngle(Stick_z->GetRawAxis(2));
}
}
}*/
void Target()
{
/*
* MIDDLE GOALS have openings that are 54 in. wide and 21 in. tall
* bottom edge of the MIDDLE GOAL is located 88 5/8 in. above the FIELD
*----------------------------------------------------------------------
* HIGH GOAL is 54 in. wide and 12 in. tall
* bottom edge of the opening located 104 1/8 in. above the FIELD
*/
}
};
START_ROBOT_CLASS(RobotDemo);
some of it has been customized since the last time I posted. And it probably wont be used on the robot this year but, I am just curious how to fix it.