Go to Post Pushing match, what pushing match? If they can't catch you they can't push you around. - IndySam [more]
Home
Go Back   Chief Delphi > Technical > Programming
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
  #2   Spotlight this post!  
Unread 03-03-2010, 20:57
Bongle's Avatar
Bongle Bongle is offline
Registered User
FRC #2702 (REBotics)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2002
Location: Waterloo
Posts: 1,069
Bongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond reputeBongle has a reputation beyond repute
Send a message via MSN to Bongle
Re: Using one gyro sensor as two viritual gyros in code

You could make a class of your own that holds a pointer to your original gyro class. It could have a reset function that takes note of the current absolute heading, and a getangle function which returns your difference since the last time you reset.
Code:
class RelativeGyro
{
public:
  RelativeGyro(Gyro* pAbsoluteGyro) : m_pGyro(pAbsoluteGyro), m_dBaseAngle(0.0)
  {
  }

  void Reset()
  {
    m_dBaseAngle = m_pGyro->GetAngle();
  }
  double GetAngle()
  {
    return m_pGyro->GetAngle() - m_dBaseAngle;
  }
private:
  double m_dBaseAngle;
  Gyro* m_pGyro;
}
An advantage of this design is that you could actually create multiple RelativeGyro classes within your robot, if that is what you want. You could have one for shooting, one for target-finding, etc.

If you're not using C++, you'll have to adapt my idea to LabView or Java if you like it.
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
CODE: Using the gyro in autonomous Kingofl337 Programming 1 20-01-2008 19:11
two gyros? gmiller_1249 Programming 7 24-05-2007 03:23
problems using gyro/adc code with camera default code tanstaafl Programming 7 22-01-2006 23:09
Code violation using Hall effect sensor pickle Programming 9 19-01-2005 00:10
Using two spikes for one motor supergrover Control System 6 24-02-2004 15:36


All times are GMT -5. The time now is 03:37.

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