Go to Post What is this word "done" of which you speak? - Rick TYler [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

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-23-2015, 05:05 PM
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
  #2   Spotlight this post!  
Unread 01-23-2015, 05:43 PM
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: getting g++ and gcc errors

Please edit your post and add [code] and [/code] tags around your code. Without them, any formatting you use is lost (and it takes up a whole lot of page).
Reply With Quote
  #3   Spotlight this post!  
Unread 01-27-2015, 07:35 AM
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
Red face Re: getting g++ and gcc errors

Ok...I apologize for the original post. I had a former student that came back this year to try to mentor post, and it was not very organized.

We have looked at other posts and come to the realization that the g++ and gcc errors SHOULDN"T be a big deal...hopefully that works out for us. Here is what we are having trouble with still:

All we are trying to do is program an XBox controller button. Last year in Windriver, we wrote the program this way:

if(Assist_Controller->GetRawButton(4)==1{
Talon5->Set(1);
}
else if(Assist_Controller->GetRawButton(1)==1){
Talon5->Set(-1);
}
else{
Talon5->Set(0);

This would make the "Y" button make the motor go one direction and the "A" button go the other direction.

This year, we have looked through the libraries and are unable to figure out how to code this appropriately. So far, this is what our coding team has come up with, but it results in a yellow question mark and says "Syntax Error":

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

Will this code work? If there is something wrong with this, any help is greatly appreciated.

Our coding mentor from the past two years is deep into his Electrical Engineering Degree and is not able to commit time to help us this year. I am the team lead mentor, but am having a very difficult time with programming (I am woodshop teacher by trade, trying to build robots with kids). We stuck with C++ because we liked our code from last year and had the basics understood, but with the Eclipse small changes are struggling.

Thank you in advance for your time and help.

...by the way, I tried to go in and edit the first post, and cannot figure out where to go to make that happen.
__________________
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
  #4   Spotlight this post!  
Unread 01-27-2015, 08:06 AM
James Kuszmaul James Kuszmaul is offline
NEFIRST CSA
FRC #0971 (Spartan Robotics)
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Worcester, MA
Posts: 61
James Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud ofJames Kuszmaul has much to be proud of
Re: getting g++ and gcc errors

Quote:
Originally Posted by Mr.Paulson View Post
Code:
 if(Driver_Controller->bool GetRawButton(4)==0){
			Talon3->Set(1);
		}
		else if(Driver_Controller->bool GetRawButton(1)==0){
			Talon3->Set(-1);
		}
		else{												
			Talon3->Set(0);
You will almost certainly have trouble with the lines:
Code:
if(Driver_Controller->bool GetRawButton(4)==0){
and
Code:
else if(Driver_Controller->bool GetRawButton(1)==0){
You should not have that bolded bool there; it simply is not necessary in C/C++ to put that identifier there when calling a function. It's certainly possible that you have other problems, but your code won't compile if you leave those in.

If you are still having issues, it would be convenient if you specifically quoted the error in question and identified the line corresponding to the error (most error messages will mention a line number; if you can point out exactly which line the error message is referring to, it is easier for people to help). Also, the code tags mentioned earlier are helpful for formatting; if you put a large chunk of code in code tags then it will keep constant width characters and handle whitespace nicely, as well as condensing the code so it doesn't take up as much space when scrolling through the thread.
__________________
FRC971 (Student) 2011-2014
FRC190 (College Mentor-ish) 2014
WPILib Development 2014-present
Reply With Quote
  #5   Spotlight this post!  
Unread 01-27-2015, 08:07 AM
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 985
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: getting g++ and gcc errors

Your exact code from last year should be the fine, but the button mappings may or may not have changed, check the USB tab on the DriverStation for your controller to make sure you are getting the right button (they start at 1 in C++ and Java WPILib).

The bool in the middle is probably the source of your syntax error.
Reply With Quote
Reply


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 09:12 AM.

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