MotorController
settings.h
Go to the documentation of this file.
1 /** @file */
2 
3 #ifndef SETTINGS_H
4 #define SETTINGS_H
5 
6 /******************************************************************************/
7 /* Includes */
8 /******************************************************************************/
9 #include "ch.h"
10 #include "coding_wheels.h"
11 #include "motor.h"
12 
13 /******************************************************************************/
14 /* Constants */
15 /******************************************************************************/
16 /*
17  * Datasheet says that this value should be 900 if angles are measured in radians.
18  * But the maximum value remains 5760, whatever the unit selected. And
19  * 5760 / 2 * pi = 916.73.
20  */
21 #define ANGLE_MULT_RAD 917
22 
23 #define ANGLE_MULT_DEG 16
24 
25 /******************************************************************************/
26 /* Types */
27 /******************************************************************************/
28 /**
29  * Structure representing PID coefficients.
30  */
31 typedef struct {
32  uint16_t p; /**< Proportionnal coeff */
33  uint16_t i; /**< Integral coeff */
34  uint16_t d; /**< Deriavtion coeff */
35 } pid_coeffs_t;
36 
37 /**
38  * Structure holding all the configuration values used by this firmware.
39 */
40 typedef struct {
41  uint16_t wheels_gap; /**< Distance between the middle of the 2 coding wheels in mm. */
42  uint16_t ticks_per_m; /**< Number of coding wheel ticks per m. */
43  uint16_t angular_trust_threshold; /**< Threshold for angular speed above which we can't trust the IMU anymore. */
44  uint16_t max_linear_acceleration; /**< Maximum linear acceleration authorized, in cm.s-2 */
45  uint16_t max_angular_acceleration; /**< Maximum angular acceleration authorized, in 1/917 radian.s-2 */
46  uint16_t cruise_linear_speed; /**< Target cruise linear speed, in cm.s-1 */
47  uint16_t cruise_angular_speed; /**< Target cruise angular speed, in 1/917 radian.s-1 */
48  /* PID coeffs. Value will be divided by DIVISION_FACTOR (see control.c) */
49  pid_coeffs_t linear_coeff; /**< PID coeffs for linear control */
50  pid_coeffs_t angular_coeff; /**< PID coeffs for angular control */
51  coding_wheels_config_t coding_wheels_config; /**< Configuration of the coding wheels */
52  motor_sense_t motor_right_forward_sense; /**< Rotation direction of the right
53  motor corresponding to a "forward" move of the robot */
54  motor_sense_t motor_left_forward_sense; /**< Rotation direction of the left
55  motor corresponding to a "forward" move of the robot */
56  uint16_t linear_allowance; /**< Threshold (in coding wheels ticks) below
57  which a linear move is considered as completed */
58  uint16_t angular_allowance; /**< Threshold (in coding wheels ticks) below
59  which an angular move is considered as completed */
61 
62 /******************************************************************************/
63 /* Variables */
64 /******************************************************************************/
65 /**
66  * @brief Global variable used to store the configuration in use.
67  */
68 extern volatile robot_settings_t settings;
69 
70 #endif /* SETTINGS_H */
Configuration structure for coding wheels.
Definition: coding_wheels.h:22
uint16_t max_linear_acceleration
Definition: settings.h:44
uint16_t cruise_angular_speed
Definition: settings.h:47
pid_coeffs_t linear_coeff
Definition: settings.h:49
uint16_t i
Definition: settings.h:33
motor_sense_t motor_right_forward_sense
Definition: settings.h:52
pid_coeffs_t angular_coeff
Definition: settings.h:50
motor_sense_t motor_left_forward_sense
Definition: settings.h:54
uint16_t wheels_gap
Definition: settings.h:41
uint16_t linear_allowance
Definition: settings.h:56
coding_wheels_config_t coding_wheels_config
Definition: settings.h:51
uint16_t max_angular_acceleration
Definition: settings.h:45
motor_sense_t
Alias for motor orientation.
Definition: motor.h:40
uint16_t d
Definition: settings.h:34
uint16_t angular_trust_threshold
Definition: settings.h:43
uint16_t angular_allowance
Definition: settings.h:58
uint16_t ticks_per_m
Definition: settings.h:42
uint16_t p
Definition: settings.h:32
uint16_t cruise_linear_speed
Definition: settings.h:46
volatile robot_settings_t settings
Global variable used to store the configuration in use.
Definition: settings.c:9