Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
rover_guidance_steering.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Jesús Bautista <jesusbautistavillar@gmail.com>
3 * Hector García <noeth3r@gmail.com>
4 * 2025 Gautier Hattenberger <gautier.hattenberger@gmail.com>
5 *
6 * This file is part of paparazzi.
7 *
8 * paparazzi is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * paparazzi is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with paparazzi; see the file COPYING. If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef ROVER_GUIDANCE_STEERING_H
24#define ROVER_GUIDANCE_STEERING_H
25
32#include "std.h"
33#include <math.h>
35
36#include "generated/airframe.h"
37
38// Check critical global definitiones
39#ifndef SERVO_MOTOR_THROTTLE_IDX
40#error "Steering rover firmware requires the servo MOTOR_THROTTLE"
41#endif
42
43#ifndef SERVO_MOTOR_STEERING_IDX
44#error "Steering rover firmware requires the servo MOTOR_STEERING"
45#endif
46
47#ifndef COMMAND_THROTTLE
48#error "Steering rover firmware requires the command COMMAND_THROTTLE"
49#endif
50
51#ifndef COMMAND_STEERING
52#error "Steering rover firmware requires the command COMMAND_STEERING"
53#endif
54
55
58// MIN_DELTA, MAX_DELTA: Min and max wheels turning angle (deg)
59// You should measure this angle if you want to have an
60// efficient control in your steering
61#ifndef MAX_DELTA
62#define MAX_DELTA 15.0
63#endif
64#ifndef MIN_DELTA
65#define MIN_DELTA MAX_DELTA
66#endif
67
68// This variables allow you to configurate de max and min
69// steering actuator signal. There is a mecanic limitation
70// for the actuator in the steering of our rover, so we have
71// to limit the actuator travel.
72#ifndef MAX_CMD_SHUT
73#define MAX_CMD_SHUT 0
74#endif
75#ifndef MIN_CMD_SHUT
76#define MIN_CMD_SHUT 0
77#endif
78
79// MIN_SPEED, MAX_SPEED: Min and max state speed (m/s)
80#ifndef MAX_SPEED
81#define MAX_SPEED 999.0 //We don't really use that variable
82#endif
83#ifndef MIN_SPEED
84#define MIN_SPEED 0.2 //But this one is mandatory because we have
85#endif //to deal with GPS noise (and 1/v in guidance control).
86
87// DRIVE_SHAFT_DISTANCE: Distance between front and rear wheels (m)
88#ifndef DRIVE_SHAFT_DISTANCE
89#define DRIVE_SHAFT_DISTANCE 0.25
90#warning "Construction variable DRIVE_SHAFT_DISTANCE for steering wheel rover not defined"
91#endif
92
93// SR_MEASURED_KF: Lineal feed forward control constant (have to be measured in new servos)
94#ifndef SR_MEASURED_KF
95#define SR_MEASURED_KF 10
96#warning "Construction constant SR_MEASURED_KF for steering wheel rover not defined"
97#endif
98
99
101// High level commands
102typedef struct {
103 float speed;
104 float delta;
105} sr_cmd_t;
106
107// Main structure
108typedef struct {
110 float throttle;
112 float omega_sp;
113
114 float pos_kp;
117 float kf;
118 float kp;
119 float ki;
120} rover_ctrl;
121
123
125extern void rover_guidance_steering_init(void);
126extern void rover_guidance_steering_periodic(void); // call state machine
127extern void rover_guidance_steering_heading_ctrl(float omega);
128extern void rover_guidance_steering_speed_ctrl(void);
129extern void rover_guidance_steering_setpoints(struct EnuCoor_f pos_sp, float *heading_sp);
130extern void rover_guidance_steering_pid_reset(void);
131extern void rover_guidance_steering_kill(void);
132
133extern void rover_guidance_steering_set_speed_pgain(float pgain);
134extern void rover_guidance_steering_set_speed_igain(float igain);
135
137// Bound delta
138#define BoundDelta(delta) (delta < -MIN_DELTA ? -MIN_DELTA : \
139 (delta > MAX_DELTA ? MAX_DELTA : \
140 delta))
141
142// Bound speed
143#define BoundSpeed(speed) (speed < MIN_SPEED ? MIN_SPEED : \
144 (speed > MAX_SPEED ? MAX_SPEED : \
145 speed))
146
147// Bound throttle
148#define BoundThrottle(throttle) TRIM_PPRZ((int)throttle)
149
150// Set low level commands from high level commands
151#define GetCmdFromDelta(delta) (delta >= 0 ? delta/MAX_DELTA * (MAX_PPRZ - (int)MAX_CMD_SHUT) : \
152 delta/MIN_DELTA * (MAX_PPRZ - (int)MIN_CMD_SHUT))
153
154// This macro is for NAV state
155#define GetCmdFromThrottle(throttle) (autopilot_throttle_killed() ? 0 : TRIM_PPRZ((int)throttle))
156
157// Set AP throttle value
158#define SetAPThrottleFromCommands(void) { \
159 autopilot.throttle = commands[COMMAND_THROTTLE]; \
160 }
161
162#endif // ROVER_GUIDANCE_STEERING_H
uint16_t foo
Definition main_demo5.c:58
Paparazzi floating point math for geodetic calculations.
vector in East North Up coordinates Units: meters
void rover_guidance_steering_kill(void)
rover_ctrl guidance_control
void rover_guidance_steering_speed_ctrl(void)
void rover_guidance_steering_set_speed_igain(float igain)
void rover_guidance_steering_periodic(void)
void rover_guidance_steering_init(void)
Steering rover guidance EXT FUNCTIONS.
float omega_sp
omega setpoint
float heading_sp
heading setpoint
void rover_guidance_steering_pid_reset(void)
PID RESET function.
void rover_guidance_steering_setpoints(struct EnuCoor_f pos_sp, float *heading_sp)
void rover_guidance_steering_heading_ctrl(float omega)
CTRL functions.
void rover_guidance_steering_set_speed_pgain(float pgain)
Steering rover guidance STRUCTURES.