blob: 955707209987bc53eea471c4d5c0c8598b70bd9b [file] [log] [blame]
Brian Silverman6ae77dd2013-03-29 22:28:08 -07001#include "aos/aos_core.h"
2#include "math.h"
3
4#include "frc971/queues/GyroAngle.q.h"
5#include "frc971/queues/CameraTarget.q.h"
6#include "aos/common/time.h"
7#include "vision/RingBuffer.h"
8
9using frc971::vision::RingBuffer;
10using frc971::sensors::gyro;
11using frc971::vision::targets;
12using frc971::vision::target_angle;
13
14int main(){
15 RingBuffer< ::aos::time::Time,double> buff;
16 ::aos::Init();
17 while (true) {
18 gyro.FetchNextBlocking();
19 buff.Sample(gyro->sent_time, gyro->angle);
20 if(targets.FetchNext()){
21 const frc971::vision::CameraTarget *goal = targets.get();
22 ::aos::time::Time stamp = ::aos::time::Time::InNS(goal->timestamp);
23 double angle_goal =
24 buff.ValueAt(stamp) - M_PI * goal->percent_azimuth_off_center / 4;
25 printf("%g ",angle_goal);
26 printf("%g\n",gyro->angle);
27
28 target_angle.MakeWithBuilder()
29 .target_angle(angle_goal).Send();
30 }
31 }
32 ::aos::Cleanup();
33}
34