View Single Post
  #1   Spotlight this post!  
Unread 05-02-2013, 17:33
Arrowhead Arrowhead is offline
Registered User
AKA: Daniel Brown
FRC #1369 (1369 Minotaur)
Team Role: Programmer
 
Join Date: Jan 2013
Rookie Year: 2013
Location: Tampa, Florida
Posts: 49
Arrowhead is an unknown quantity at this point
Robot Code Not Working

So we recently got our new CRio in, and after getting it set up, we started testing our code. We have just got the code uploaded to the CRio, but when we run it, none of our Victors do anything, and our code doesnt seem to be making any changes to anything. We built our code without errors. Here is our code, and here is the messages we get in the driver station diagnostics menu

Code:
#include "WPILib.h"		


class RobotDemo : public SimpleRobot
{

	
	
Victor laquanda;				//front left motor:V1
Victor anabel;					//back left motor:V2
Victor rotciv;					//front right motor:V3
Victor shanaynay;				//back right motor:V4

RobotDrive rDrive;				//declare robot drive
		
Victor shooterVictor;				//declare victor for shooter
Victor shooterVictor2;

Servo loaderArm;				//declare servo for loader arm
	
Joystick driverStick;			//declares all 3 joysticks
Joystick driverStick2;
Joystick shooterStick;

Victor climbingArm1;			//declare victors for climbing arms
Victor climbingArm2;

Solenoid SC1;				//declares solenoids for climbing arm
Solenoid SC2;

DigitalInput Disk1; 			//declares limit switches for hopper
DigitalInput Disk2; 
DigitalInput Disk3; 
DigitalInput Disk4; 



public:


	RobotDemo(void):
		
	laquanda(1),			//assign drive motors PWM ports
	anabel(2),				
	rotciv(3),				
	shanaynay(4),

	rDrive(laquanda, anabel, rotciv, shanaynay),			//assigns robot drive talons theiw PWM ports

	shooterVictor(6),		//assigns victor its PWM port
	shooterVictor2(7),

	loaderArm(5),			//assign servo its PWM port

	driverStick(1),			//assign joysticks their USB ports
	driverStick2(2),
	shooterStick(3),

	climbingArm1(8),		//assigns climbing victors PWM ports
	climbingArm2(9),

	SC1(1),				//assigns climbing pneumatics digital output ports
	SC2(2),

	Disk1(3),			//assigns limit switches digital input ports
	Disk2(4),
	Disk3(5),
	Disk4(6)

	{
	
	Watchdog().SetEnabled(false);	

	rDrive.SetExpiration(0.1);
	rDrive.SetSafetyEnabled(true);			//sets motor saftey on for all motors

	shooterVictor.SetExpiration(0.1);
	shooterVictor.SetSafetyEnabled(true);
	
	shooterVictor2.SetExpiration(0.1);
	shooterVictor2.SetSafetyEnabled(true);

	loaderArm.SetExpiration(0.1);
	loaderArm.SetSafetyEnabled(true);

	climbingArm1.SetExpiration(0.1);
	climbingArm1.SetSafetyEnabled(false);

	climbingArm2.SetExpiration(0.1);
	climbingArm2.SetSafetyEnabled(false);

	}

	
	void Autonomous(void)
	{
		
	DriverStationLCD *ds = DriverStationLCD::GetInstance();	
		
	double AutoTime = 0;			//used to measure time during autonomous

	
	rDrive.SetSafetyEnabled(false);				//turn of motor saftey timers during autonomous for convience

	shooterVictor.SetSafetyEnabled(false);
	shooterVictor2.SetSafetyEnabled(false);

	loaderArm.SetSafetyEnabled(false);

	ds->PrintfLine(DriverStationLCD::kUser_Line1, "Program Started Successfully!");
	ds->PrintfLine(DriverStationLCD::kUser_Line2, "Robot Is in Autonomous");
	
	ds->UpdateLCD();
	
	while(IsAutonomous()){

		
		/**
			//start at center autonomous 
			if(AutoTime>=0.0 && AutoTime<0.5){
				shooterVictor.Set(1.0);
				shooterVictor2.Set(1.0);
				rDrive.MecanumDrive_Cartesian( 0.0 , 0.0 , -0.5 );
				}
				
			if(AutoTime>=0.5 && AutoTime<1.0){
				loaderArm.SetAngle(180);  
				}

			if(AutoTime>=1.0 && AutoTime<1.5){
				loaderArm.SetAngle(0);
				}

			if(AutoTime>=1.5 && AutoTime<2.0){
				loaderArm.SetAngle(180);
				}

			if(AutoTime>=2.0 && AutoTime<2.5){
				loaderArm.SetAngle(0);
				}

			if(AutoTime>=2.5 && AutoTime<3.0){
				loaderArm.SetAngle(180);
				}

			if(AutoTime>=3.0 && AutoTime<3.5){
				loaderArm.SetAngle(0);
				shooterVictor.Set(0.0);
				shooterVictor2.Set(0.0);
		 		}

			if(AutoTime>=3.5 && AutoTime<4.0){
				rDrive.MecanumDrive_Cartesian( 0.0, 0.0 , 0.5 );
				}

			if(AutoTime>=4.0 && AutoTime<7.0){
				rDrive.MecanumDrive_Cartesian( 1.0 , 0.0 , 0.0 );
				}

			if(AutoTime>=7.0 && AutoTime<9.0){
				rDrive.MecanumDrive_Cartesian( 0.0 , 1.0 , 0.0 );
				}
				
			if(AutoTime>=9.0 && AutoTime<10.0){
				rDrive.MecanumDrive_Cartesian( 0.0 , 0.0 , 0.5 );
				}

			if(AutoTime>=10.0 && AutoTime<10.5){
				rDrive.MecanumDrive_Cartesian( 0.7 , 0.0 , 0.0 );
				}
		*/
		
		
		//start at left or right autonomous
		if(AutoTime>=0.0 && AutoTime<0.5){
			shooterVictor.Set(1.0);
			shooterVictor2.Set(1.0);
			loaderArm.SetAngle(180);  
			}

		if(AutoTime>=0.5 && AutoTime<1.0){
			loaderArm.SetAngle(0);
			}

		if(AutoTime>=1.0 && AutoTime<1.5){
			loaderArm.SetAngle(180);
			}

		if(AutoTime>=1.5 && AutoTime<2.0){
			loaderArm.SetAngle(0);
	 		}

		if(AutoTime>=2.0 && AutoTime<2.5){
			loaderArm.SetAngle(180);
			}

		if(AutoTime>=2.5 && AutoTime<3.0){
			loaderArm.SetAngle(0);
			shooterVictor.Set(0.0);
			shooterVictor2.Set(0.0);
	 		}

		if(AutoTime>=3.0 && AutoTime<6.0){
			rDrive.MecanumDrive_Cartesian(1.0, 0.0 , 0.0 );
			}

		if(AutoTime>=6.0 && AutoTime<7.0){
			rDrive.MecanumDrive_Cartesian( 0.0 , 0.0 , -0.5 );	//left autonomous = -0.5 turn 		right autonomous = 0.5 turn
			}

		if(AutoTime>=7.0 && AutoTime<9.0){
			rDrive.MecanumDrive_Cartesian( 0.7 , 0.0 , 0.0 );
			}

		AutoTime=AutoTime+0.02;
		Wait(0.02);
		}
	}
		

	void operatorControl(){

	rDrive.SetSafetyEnabled(true);				//turn motor saftey timers back on

		shooterVictor.SetSafetyEnabled(true);
	shooterVictor2.SetSafetyEnabled(true);

	loaderArm.SetSafetyEnabled(true);
	
	DriverStationLCD *ds = DriverStationLCD::GetInstance();
	
	ds->PrintfLine(DriverStationLCD::kUser_Line6, "Pinkie Pie Is Best Pony");

		while (IsOperatorControl()){
			
		ds->PrintfLine(DriverStationLCD::kUser_Line2, "Robot Is In TeleOp");

		rDrive.MecanumDrive_Cartesian(driverStick.GetX(), driverStick.GetY(), driverStick2.GetX());			//gets input for robot drive
																											//from joysticks 1/2
		ShooterControl();		//runs shooter control function

		LoaderControl();		//runs servo control function

		//Climbing();			//runs pryamid climbing function

		//DiskCount();			//runs diskcount function	
		
		ds->UpdateLCD();

		Wait(0.02);			//waits 0.02 seconds
			}
		}


	void ShooterControl(){			//shooter control function
		DriverStationLCD *ds = DriverStationLCD::GetInstance();
		if(shooterStick.GetRawButton(1)){
			shooterVictor.Set(1.0);			//if trigger is pressed, turn on shooter
			shooterVictor2.Set(1.0);
			ds->PrintfLine(DriverStationLCD::kUser_Line3, "Shooter Is On");
			}
		else{
			shooterVictor.Set(0.0);			//if trigger isnt pressed, turn off shooter
			shooterVictor2.Set(0.0);
			ds->PrintfLine(DriverStationLCD::kUser_Line3, "Shooter Is Off");
			}
		}


	void LoaderControl(){			//servo control function
		DriverStationLCD *ds = DriverStationLCD::GetInstance();
		if(shooterStick.GetRawButton(3)){
			loaderArm.SetAngle(180);			//if middle button is pressed, extend servo
			ds->PrintfLine(DriverStationLCD::kUser_Line4, "Loader Servo Is Extended");
			}
		else{
			loaderArm.SetAngle(0);				//if middle button isnt pressed, retract servo
			ds->PrintfLine(DriverStationLCD::kUser_Line4, "Loader Servo Is Retracted");
			}
		}


	void Climbing(){						//pyramid climbing function, happens automatically
		DriverStationLCD *ds = DriverStationLCD::GetInstance();
		if(shooterStick.GetRawButton(6) && driverStick.GetRawButton(6)){		//if button 6 pressed on both sticks, starts climb
		
		ds->PrintfLine(DriverStationLCD::kUser_Line2, "Robot Is Climbing");
		
		ds->UpdateLCD();
			
		rDrive.SetSafetyEnabled(false);				//turn of motor saftey timers during climbing for convience

		shooterVictor.SetSafetyEnabled(false);
		shooterVictor2.SetSafetyEnabled(false);

		loaderArm.SetSafetyEnabled(false);

		bool climbingRunning=true;							//checks if robot continues to climb
		double CTime = 0;
		double VCTime=0;
	
		while(climbingRunning=true){
	
			if(CTime>=0.0 && CTime<1.0){			
				climbingArm1.Set(0.4);			//raise climbing arms
				climbingArm2.Set(0.4);
				VCTime=VCTime+0.05;
				}

			if(CTime>=1.0 && CTime<1.5){
				climbingArm1.Set(0.0);			//extend climbing arms
				climbingArm2.Set(0.0);
				SC1.Set(true);
				SC2.Set(true);
				}

			
			if(CTime>=1.5 && CTime<2.0){
				rDrive.MecanumDrive_Cartesian( 0.2 , 0.0 , 0.0 );	//move towards bar
				}

			if(CTime>=2.0 && CTime<2.5){
				SC1.Set(false);		//retract climbing arms
				SC2.Set(false);
				}

			
			if(shooterStick.GetRawButton(7)){		
				climbingRunning=false;			//if button 7 pressed, stops climbing 		
				climbingArm1.Set(-0.4);			
				climbingArm2.Set(-0.4);
				Wait(VCTime);
				SC1.Set(false);		
				SC2.Set(false);

				rDrive.SetSafetyEnabled(true);				//turn motor saftey timers back on
	
				shooterVictor.SetSafetyEnabled(true);
				shooterVictor2.SetSafetyEnabled(true);
		
				loaderArm.SetSafetyEnabled(true);
				}
			

			Wait (0.05);

			CTime=CTime+0.05;
			}
			}
		}

	
	void DiskCount(){			//function that counts disk in the hopper and displays it
		DriverStationLCD *ds = DriverStationLCD::GetInstance();
		int disknum = 0;		//variable that counts disks in hopper

		if(Disk1.Get()){
			disknum=disknum+1;	//disk has activated a limit switch, add 1 to # of disks
			}
		if(Disk2.Get()){
			disknum=disknum+1;
			}
		if(Disk3.Get()){
			disknum=disknum+1;
			}
		if(Disk4.Get()){
			disknum=disknum+1;
			}

		ds->PrintfLine(DriverStationLCD::kUser_Line5, "Disk's in Hopper: %d", disknum);	//print out the number of disks in hopper
	
		
		}

	};

START_ROBOT_CLASS(RobotDemo);		//starts the class running
Warning <Code> 44002 occurred at Ping Results: link-GOOD, DS radio(.4)-bad, robot radio(.1)-bad, cRIO(.2)-GOOD, FMS-bad Driver Station
<time>2/6/2013 5:28:08 AM<unique#>104
FRC: Driver Station ping status has changed.
ERROR: A timeout has been exceeded: PWM 5 on module 1... Output not updated often enough. ...in Check() in C:/WindRiver/workspace/WPILib/MotorSafetyHelper.cpp at line 117


ERROR: A timeout has been exceeded: PWM 7 on module 1... Output not updated often enough. ...in Check() in C:/WindRiver/workspace/WPILib/MotorSafetyHelper.cpp at line 117


ERROR: A timeout has been exceeded: PWM 6 on module 1... Output not updated often enough. ...in Check() in C:/WindRiver/workspace/WPILib/MotorSafetyHelper.cpp at line 117


ERROR: A timeout has been exceeded: RobotDrive... Output not updated often enough. ...in Check() in C:/WindRiver/workspace/WPILib/MotorSafetyHelper.cpp at line 117
ERROR: A timeout has been exceeded: PWM 5 on module 1... Output not updated often enough. ...in Check() in C:/WindRiver/workspace/WPILib/MotorSafetyHelper.cpp at line 117
[/code]
Reply With Quote