|
RSeries astromech firmware
|
|
Go to the documentation of this file.
4 #include <Adafruit_BNO055.h>
27 Adafruit_BNO055(55, BNO055_ADDRESS_A+id),
37 if ((fReady = begin()) ==
true)
39 setExtCrystalUse(
true);
44 DEBUG_PRINTLN(
"Ooops, no BNO055 detected ... Check your wiring or I2C ADDR");
54 return int(fCurrentYaw);
62 float prevYaw = fPreviousYaw;
63 fPreviousYaw = fCurrentYaw;
65 return (prevYaw != fCurrentYaw);
73 return int(fCurrentRoll);
81 float prevRoll = fPreviousRoll;
82 fPreviousRoll = fCurrentRoll;
84 return (prevRoll != fCurrentRoll);
92 return int(fCurrentPitch);
100 float prevPitch = fPreviousPitch;
101 fPreviousPitch = fCurrentPitch;
102 pitch = fCurrentPitch;
103 return (prevPitch != fCurrentPitch);
113 sensors_event_t event;
116 if (event.orientation.x != fLastEvent.orientation.x ||
117 event.orientation.y != fLastEvent.orientation.y ||
118 event.orientation.z != fLastEvent.orientation.z)
120 float yaw = float(event.orientation.x);
121 float roll = float(event.orientation.y);
122 float pitch = float(event.orientation.z);
123 if (fCurrentYaw == -1)
125 fPreviousYaw = fCurrentYaw = yaw;
129 fPreviousYaw = fCurrentYaw;
132 if (fCurrentRoll == -1)
134 fPreviousRoll = fCurrentRoll = roll;
138 fPreviousRoll = fCurrentRoll;
141 if (fCurrentPitch == -1)
143 fPreviousPitch = fCurrentPitch = roll;
147 fPreviousPitch = fCurrentPitch;
148 fCurrentPitch = pitch;
152 if (fCurrentYaw != fPreviousYaw ||
153 fCurrentRoll != fPreviousRoll ||
154 fCurrentPitch != fPreviousPitch)
171 float fPreviousYaw = -1;
172 float fCurrentYaw = -1;
173 float fPreviousRoll = -1;
174 float fCurrentRoll = -1;
175 float fPreviousPitch = -1;
176 float fCurrentPitch = -1;
178 sensors_event_t fLastEvent;
Base class for all animated devices. AnimatedEvent::animate() is called for each device once through ...
Definition: AnimatedEvent.h:18
static void send_end()
Definition: ReelTwoSMQ.h:463
Base class for all devices that require setup that cannot happen in the constructor....
Definition: SetupEvent.h:15
static bool sendTopic(const smq_id id)
Definition: ReelTwoSMQ.h:155
virtual void animate()
Reads the IMU and publishes any change in heading.
Definition: Orientation.h:109
#define DEBUG_PRINTLN(s)
Definition: ReelTwo.h:188
float getYaw()
Returns the last recorded yaw.
Definition: Orientation.h:52
bool getRollChanged(float &roll)
Returns true if roll has changed since last calling this function.
Definition: Orientation.h:79
float getPitch()
Returns the last recorded pitch.
Definition: Orientation.h:90
static void send_float(const msg_id id, float val)
Definition: ReelTwoSMQ.h:364
bool getYawChanged(float &yaw)
Returns true if yaw has changed since last calling this function.
Definition: Orientation.h:60
Orientation(uint8_t id=0)
Default Constructor.
Definition: Orientation.h:26
static void send_uint8(const msg_id id, uint8_t val)
Definition: ReelTwoSMQ.h:292
bool getPitchChanged(float &pitch)
Returns true if pitch has changed since last calling this function.
Definition: Orientation.h:98
virtual void setup()
Perform any initialzation not possible in the constructor.
Definition: Orientation.h:35
float getRoll()
Returns the last recorded roll.
Definition: Orientation.h:71
Encapsulates an Adafruit BNO055 IMU.
Definition: Orientation.h:19