Go to Post A good teacher always needs to be a good student - Redhead Jokes [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 23-01-2015, 17:05
Mr.Paulson's Avatar
Mr.Paulson Mr.Paulson is offline
Registered User
FRC #4539
 
Join Date: Jan 2014
Rookie Year: 2010
Location: Minnesota
Posts: 43
Mr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud ofMr.Paulson has much to be proud of
getting g++ and gcc errors

Also getting If and Else if, button value syntax errors in the start of the teleoperatedPeriod


#include "WPILib.h"

/**
* This is an easy way to keep track of connections
* This code assumes the following connections:
* - Driver Station:
* - USB 1 - Main Drive Xbox controller
* - USB 2 - Secondary Xbox
* - Robot:
* - Digital Sidecar 1:
* - PWM 1 - Left Drive
* - PWM 2 - Right Drive
* - PWM 3 - Shooter
* - PWM 4 - Ball Intake
* - PWM 5 - Intake arm/lifter
* - PWM 6 - Catcher
* - PWM 7 - Connected to
* - PWM 8 - Connected to
* - PWM 9 - Connected to
* -Digital Sensors
* -I/O 1 - Pneumatic sensor
* -I/O 2 -
*
*/

class Robot : public IterativeRobot
{

RobotDrive *TankDrive; // robot drive system
Joystick *Driver_Controller;
Joystick *Assistant_Controller;
LiveWindow *lw;
int autoLoopCounter;

Talon *Talon0; //Left Drive
Talon *Talon1; //Right Drive
Talon *Talon2; //up and down
Talon *Talon3; //arm close and open
Talon *Talon4; //intake wheels
Talon *Talon5; //spare

float Left_X_Axis_Driver; //when CamelCase doesn't fit, underscores work too
float Right_X_Axis_Driver; //float means long decimel
float Left_Y_Axis_Driver;
float Right_Y_Axis_Driver;

float Left_X_Axis_Assist; //when CamelCase doesn't fit, underscores work too
float Right_X_Axis_Assist; //float means long decimel
float Left_Y_Axis_Assist;
float Right_Y_Axis_Assist;

float AutoTimer;

public:
Robot() :
TankDrive(1, 2), // these must be initialized in the same order
Driver_Controller(1), // as they are declared above.
Assistant_Controller(2),
Talon0(0),
Talon1(1),
Talon2(2),
Talon3(3),
Talon4(4),
Talon5(5),
AutoTimer(),

lw(NULL),
autoLoopCounter(0)


{
TankDrive-> SetExpiration(0.1);

Left_X_Axis_Driver =0; //when CamelCase doesn't fit, underscores work too
Right_X_Axis_Driver =0; //float means long decimel
Left_Y_Axis_Driver =0;
Right_Y_Axis_Driver =0;

Left_X_Axis_Assist =0; //when CamelCase doesn't fit, underscores work too
Right_X_Axis_Assist =0; //float means long decimel
Left_Y_Axis_Assist =0;
Right_Y_Axis_Assist =0;
}

private:
void RobotInit()
{
lw = LiveWindow::GetInstance();
}

void AutonomousInit()
{
autoLoopCounter = 0;
}

void AutonomousPeriodic(void) {

AutoTimer=Timer::Timer();

if(AutoTimer==0){ //starts timer and makes sure everything is stopped
void Timer::Start();
Talon1 -> Set(0);
Talon2 -> Set(0);
Talon3 -> Set(0);
Talon4 -> Set(0);
Talon5 -> Set(0);
}
else if(AutoTimer<2){ //Drive forward for 2 seconds
Talon1 -> Set(.3); //left drive 30%
Talon2 -> Set(-.3); //right drive 30%
Talon3 -> Set(0); //shooter 0%
Talon4 -> Set(0); //ball intake 0%
Talon5 -> Set(0); //intake arm/lifer 50%
}
else if(AutoTimer<7){ //Move launch motor for 5 seconds
Talon1 -> Set(0); //No movement
Talon2 -> Set(0);
Talon3 -> Set(0); //shooter 100%
Talon4 -> Set(0);
Talon5 -> Set(0);
}
else if(AutoTimer<8){ //Robot turning around-1 second (Zero Turn)
Talon1 -> Set(.5); //Left drive 50%
Talon2 -> Set(-.5); //Right drive 50% (backwards)
Talon3 -> Set(0);
Talon4 -> Set(0);
Talon5 -> Set(0);
}
else if(AutoTimer<10){ //Nothing going on
Talon1 -> Set(0);
Talon2 -> Set(0);
Talon3 -> Set(0);
Talon4 -> Set(0);
Talon5 -> Set(0);
}
else if(AutoTimer>10){ //Nothing going on
Talon1 -> Set(0);
Talon2 -> Set(0);
Talon3 -> Set(0);
Talon4 -> Set(0);
Talon5 -> Set(0);
void Timer::Stop(); //you can do a TON of clever stuff with one timer, and it gets bigger as you add more timers. be sure to take advantage of timers!
}

}

/** XBOX Controller Notes

* Buttons:
* A=1
* B=2
* X=3
* Y=4
* LB=5
* RB=6
* Back=7
* Start=8
* LeftAnalog=9
* RightAnalog=10

* Axis:
* LeftX=1
* LeftY=2
* RightX=4
* RightY=5
* Trigger=3 (Left moves -, Right moves +)
*/

void TeleopInit()
{

}

void TeleopPeriodic()
{
void RobotDrive::TankDrive (float leftValue,float rightValue,bool squaredInputs = true);

Talon1 -> Set(-Left_Y_Axis_Driver); //Sets speed to Joy stick value
Talon2 -> Set(Right_Y_Axis_Driver);


if(Driver_Controller->bool GetRawButton(5)==0){
Talon3->Set(1);
}

else if(Driver_Controller->bool GetRawButton(9)==0){
Talon3->Set(-1);

}
else{ //never forget your else
Talon3->Set(0);

}
TestPeriodic();
{
lw->Run();
}
};

'START_ROBOT_CLASS(Robot);
__________________
Team #4539
2015- Lake Superior Regional #1 Captain and Semifinalist (3276 & 4845)
Quality Award Sponsored by Motorola
1st Place Junkyard Robot
2015- 10,000 Lakes Regional #3 Captain and Quarterfinalist (1816 & 3081)
2014- Lake Superior Regional #4 Captain and Semifinalist (3755 & 3277)
1st Place Junkyard Robot
2013- FIRST Championship Newton Division Judges Award
Lake Superior Regional Finalists(3276 & 3277), Rookie All-Star Award, Highest Seeded Rookie Award, Most Creative Junkyard Robot Award
Team #3276
2012- Lake Superior Regional Quarterfinalist (3755 & 1816)
2011- 10,000 Lakes Regional Semifinalist (141 & 3082)
2010- 10,000 Lakes Regional Rookie Inspiration Award
Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:01.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi