View Single Post
  #8   Spotlight this post!  
Unread 18-01-2017, 20:35
Penchant Penchant is online now
Registered User
FRC #4607
Team Role: College Student
 
Join Date: Jan 2015
Rookie Year: 2015
Location: Becker, MN, USA
Posts: 4
Penchant has a spectacular aura aboutPenchant has a spectacular aura about
Re: command based, gyro, omnidrive

I have done programming with similar systems, and if you are looking for how to make it field centric rather than robot centric, I just took in the joystick values as polar coordinates, which is a magnitude and direction, then converted them to cartesian coordinates but in the conversion process adjusted the angle by the angle of the gyro.

So a snippet of the code:
Code:
adjustmentAngle = gyro->GetAngle()*3.14/180+3.14/2;
x=Pilot->GetMagnitude()*cos(Pilot->GetDirectionRadians()-adjustmentAngle);
y=Pilot->GetMagnitude()*sin(Pilot->GetDirectionRadians()-adjustmentAngle);
Reply With Quote