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.