Go to Post some people sing in the shower........i pretend to be an emcee at championships......:cool: - BanksKid [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 28-01-2011, 22:57
Lawlhwut Lawlhwut is offline
Registered User
None #2853
 
Join Date: Jan 2011
Location: Hawaii
Posts: 17
Lawlhwut is an unknown quantity at this point
Programming gyro, noob programmer

Quote:
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{
static const float Kp = 0.03;
RobotDrive myRobot;
Gyro gyro;

public:
RobotDemo(void):
myRobot(1, 2), // these must be initialized in the same order
gyro (1)
{
myRobot.SetExpiration(0.1);
}

void Autonomous(void) {
gyro.Reset();
while (IsAutonomous())
DriverStationLCD *screen = DriverStationLCD::GetInstance();
{
float angle = gyro.GetAngle(); // current heading (0 = target)
myRobot.Drive(-1.0, -angle / 30.0); // proportionally drive in a straight line
Wait(0.004);
screen->PrintfLine(DriverStationLCD::kUser_Line1,"KimpeeA ngle", gyro.GetAngle());
screen->UpdateLCD();
Wait(0.1);
}
myRobot.Drive(0.0, 0.0);

};
START_ROBOT_CLASS(RobotDemo);
This is the program i'm writing for the gyro. It is supposed to get the angle from the gyro and print it on the driverstation dashboard. But it is not compiling. Some fixes and basic syntax/structure info pl0x.
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2011, 23:27
Bot190's Avatar
Bot190 Bot190 is offline
Registered User
FRC #0166 (ChopShop)
Team Role: Programmer
 
Join Date: Sep 2009
Rookie Year: 2009
Location: Merrimack NH
Posts: 105
Bot190 will become famous soon enough
Re: Programming gyro, noob programmer

Generally when posting asking for help its a good idea to include any and ALL errors you get. You had a number of "{" and "}" that didn't match up. Most of your problems stemmed from the fact that you weren't closing some of your functions, and while loops and such.

Also, if you use [ CODE] and [ /CODE] without the spaces, when posting code, it stays indented making it easier to read.

Code:
#include "WPILib.h"
class RobotDemo : public SimpleRobot
{
static const float Kp = 0.03;
RobotDrive myRobot;
Gyro gyro;

public:
	RobotDemo(void): myRobot(1, 2), // these must be initialized in the same order
	gyro (1)
	{
		myRobot.SetExpiration(0.1);
	}
void Autonomous(void) {
	gyro.Reset();
	while (IsAutonomous())
	{
		DriverStationLCD *screen = DriverStationLCD::GetInstance();
		float angle = gyro.GetAngle(); // current heading (0 = target)
		myRobot.Drive(-1.0, -angle / 30.0); // proportionally drive in a straight line
		Wait(0.004);
		screen->PrintfLine(DriverStationLCD::kUser_Line1,"KimpeeA ngle", gyro.GetAngle());
		screen->UpdateLCD();
		Wait(0.1);
	}
	myRobot.Drive(0.0, 0.0);
}

};
START_ROBOT_CLASS(RobotDemo);
__________________


Last edited by Bot190 : 28-01-2011 at 23:34. Reason: Added fixed code
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 02:35.

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