MotorController
orientation.h
Go to the documentation of this file.
1 /** @file */
2 
3 #ifndef ORIENTATION_H
4 #define ORIENTATION_H
5 
6 #include "hal.h"
7 
8 #define HEADING_MAX_VALUE 5760
9 #define HEADING_MIN_VALUE 0
10 #define HEADING_RANGE 5760
11 
12 /******************************************************************************/
13 /* Public variables */
14 /******************************************************************************/
15 
16 /**
17  * The last computed orientation of the robot.
18  */
19 extern int16_t orientation;
20 
21 extern int16_t delta_alpha;
22 
23 /**
24  * Offset to apply to the raw value given by the IMU.
25  */
26 extern int16_t heading_offset;
27 
28 /******************************************************************************/
29 /* Function prototypes */
30 /******************************************************************************/
31 
32 /**
33 * @brief Set the euler heading angle offset.
34 *
35 * @details WARNING : setting angles DOES NOT MOVE the robot, it offsets the angle.
36 *
37 * @param[in] heading The current heading angle.
38 *
39 * @return An int32_t indicating success, else an error code.
40 * @retval NO_ERROR No error, offset set.
41 * @retval INVALID_PARAMETER heading out of range.
42 */
43 extern int32_t set_orientation(int16_t heading);
44 
45 /**
46 * @brief Set the euler pitch angle offset.
47 *
48 * @details WARNING : setting angles DOES NOT MOVE the robot, it offsets the angle.
49 *
50 * @return An int32_t indicating success, else an error code.
51 * @retval NO_ERROR No error, offset set.
52 * @retval INVALID_PARAMETER pitch out of range.
53 *
54 * @param[in] pitch The current pitch angle.
55 */
56 extern int32_t set_pitch(int16_t pitch);
57 
58 /**
59 * @brief Set the euler roll angle offset.
60 *
61 * @details WARNING : setting angles DOES NOT MOVE the robot, it offsets the angle.
62 *
63 * @return An int32_t indicating success, else an error code.
64 * @retval NO_ERROR No error, offset set.
65 * @retval INVALID_PARAMETER roll out of range.
66 *
67 * @param[in] roll The current roll angle.
68 */
69 extern int32_t set_roll(int16_t roll);
70 
71 /**
72  * @brief Get the relative heading (relative to the last setting) in trigo sense.
73  *
74  * @return The relative heading. The range is [0, 5760] and the value decreases
75  * when turning clockwise.
76  * The sense of the angle is changed compared to the value returned by
77  * the BNO055.
78  */
79 extern int16_t get_relative_heading(void);
80 
81 /**
82  * @brief Get the relative pitch angle (relative to the last setting).
83  *
84  * @return The relative pitch. The range is [-2880, 2880] and the value increases
85  * when the inclination increases.
86  */
87 extern int16_t get_relative_pitch(void);
88 
89 /**
90  * @brief Get the relative roll angle (relative to the last setting).
91  *
92  * @return The relative roll. The range is [-1440, 1440] and the value increases
93  * when the inclination increases.
94  */
95 extern int16_t get_relative_roll(void);
96 
97 /**
98  * @brief Update the current orientation.
99  *
100  * @details This function uses either the IMU or the coding wheels to compute
101  * the new orientation value. A threshold on the angular speed is used
102  * to select one of the two sources.
103  */
104 extern void update_orientation(void);
105 
106 #endif /* ORIENTATION_H */
int32_t set_roll(int16_t roll)
Set the euler roll angle offset.
Definition: orientation.c:130
int16_t orientation
Definition: orientation.c:32
void update_orientation(void)
Update the current orientation.
Definition: orientation.c:169
int16_t get_relative_roll(void)
Get the relative roll angle (relative to the last setting).
Definition: orientation.c:155
int16_t get_relative_heading(void)
Get the relative heading (relative to the last setting) in trigo sense.
Definition: orientation.c:65
int16_t heading_offset
Definition: orientation.c:31
int32_t set_pitch(int16_t pitch)
Set the euler pitch angle offset.
Definition: orientation.c:90
int32_t set_orientation(int16_t heading)
Set the euler heading angle offset.
Definition: orientation.c:38
int16_t get_relative_pitch(void)
Get the relative pitch angle (relative to the last setting).
Definition: orientation.c:115