Go to Post So yeah I love the minibot because it was a great vehicle to promote our team, make new friends, and possibly make sure a team makes it past their 1st or 2nd year. - Mr V [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 29-01-2013, 18:36
progal's Avatar
progal progal is offline
Programmer
AKA: Shelby
FRC #0384 (Sparky)
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Glen Allen
Posts: 15
progal is an unknown quantity at this point
Gyro angle increasing while robot is static

We're trying to get the angle during Teleop mode. It worked in the past perfectly, and now every time we enable (and disable) the reading on the Driver Station LCD is rapidly decreasing 1/100th every second. But if the gyro feels like it, it will rapidly increase 1/100th every second.

This is how we're initiating it:
Code:
#include "WPILib.h"

/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */ 
class RobotDemo : public SimpleRobot
{
	RobotDrive myRobot; // robot drive system
	Joystick stick1, stick2; // only joystick
	ADXL345_I2C adxl;
	Gyro gyro;
	Relay *blinkylight;

public:
	RobotDemo(void):
		myRobot(2, 3),	// these must be initialized in the same order
		stick1(1),		// as they are declared above.
		stick2(2),
		adxl(1, ADXL345_I2C::kRange_2G),
		gyro(2)
	{
		myRobot.SetExpiration(0.1);
		blinkylight = new Relay(4);
	}
And this is how we're utilizing it:

Code:
void OperatorControl(void)
	{
		gyro.Reset();
		gyro.SetSensitivity(0.007);
		DriverStationLCD *dsLCD = DriverStationLCD::GetInstance();
		myRobot.SetSafetyEnabled(true);
		bool motorinv = false;
		
		while (true)
		{
			blinkylight->Set(Relay::kForward);
			/*
			ADXL345_I2C::AllAxes ax = adxl.GetAccelerations();
			//printf("X: %f, Y: %f, Z: %f", ax.XAxis, ax.YAxis, ax.ZAxis);
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line1, "X: %f", ax.XAxis);
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Y: %f", ax.YAxis);
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line3, "Z: %f", ax.ZAxis);
			*/
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line1, "X: %f",
					adxl.GetAcceleration(ADXL345_I2C::kAxis_X));
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line2, "Y: %f",
					adxl.GetAcceleration(ADXL345_I2C::kAxis_Y));
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line3, "Z: %f",
					adxl.GetAcceleration(ADXL345_I2C::kAxis_Z));
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line4, "Gyro: %f", gyro.GetAngle());
			dsLCD->PrintfLine(DriverStationLCD::kUser_Line6, "Motorinv: %d", motorinv);
			dsLCD->UpdateLCD();
			
			if(stick1.GetRawButton(2) || stick2.GetRawButton(2))
			{
				if(motorinv == false)
				{
					motorinv = true;
				}
				else if(motorinv == true)
				{
					motorinv = false;
				}
			}
			myRobot.SetInvertedMotor(myRobot.kRearLeftMotor, motorinv);
			myRobot.SetInvertedMotor(myRobot.kRearRightMotor, motorinv);
			if((stick1.GetTrigger() == true) && (stick2.GetTrigger() == true))
			{
				myRobot.TankDrive(stick1,stick2);
			}
			else if(stick1.GetTrigger() == true && (stick2.GetTrigger() == false))
			{
				myRobot.ArcadeDrive(stick1);
				}
			else if(stick2.GetTrigger() == true && (stick1.GetTrigger() == false))
			{
				myRobot.ArcadeDrive(stick2);
			}
			else
			{
				myRobot.TankDrive(0.0, 0.0);
			}
			Wait(0.005);				// wait for a motor update time
		}
	}
};

START_ROBOT_CLASS(RobotDemo);
I guess the question is, what are we doing wrong to get such extreme values? Like I said, this previously worked and we switched out gyros - same problem.

Thank you in advance!
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 14:12.

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