Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
servo_lidar.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 Alejandro Rochas <alrochas@ucm.es>
3 *
4 * This file is part of paparazzi.
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 *
21 */
22
28 // Depends on the lidar (it doesnt make any sense without it)
29
30#include "mcu_periph/uart.h"
31#include "modules/core/abi.h"
33#include "servo_lidar.h"
35
36
37
38#ifndef SERVO_LIDAR_SPEED
39#define SERVO_LIDAR_SPEED 5
40#endif
41
42bool enable_servo = false;
43
45
46void servoLidar_init(void) {
47 servoLidar.enabled = false;
48 servoLidar.speed = SERVO_LIDAR_SPEED; // default speed
50 servoLidar.angle = 0;
53}
54
55
56#ifdef COMMAND_SERVO
57void servoLidar_periodic(void) {
60
62 // Update servo position
63 servoLidar.position += (servoLidar.direction == 0) ? 100 : -100;
66 }
67
68 // Set servo command
71
72 // Send ABI message
74 }
75 else {
76 commands[COMMAND_SERVO] = 0; // Center servo when disabled
77 }
78 }
79}
80#else
82 // No servo functionality; do nothing
83 #error "You need to define COMMAND_SERVO to use servoLidar_periodic()"
84}
85#endif
Main include for ABI (AirBorneInterface).
#define AGL_LIDAR_TFMINI_ID
uint32_t get_sys_time_msec(void)
Get the time in milliseconds since startup.
uint16_t foo
Definition main_demo5.c:58
#define MAX_PPRZ
Definition paparazzi.h:8
struct ServoLidar servoLidar
Definition servo_lidar.c:44
bool enable_servo
Definition servo_lidar.c:42
void servoLidar_periodic(void)
Definition servo_lidar.c:81
void servoLidar_init(void)
Definition servo_lidar.c:46
#define SERVO_LIDAR_SPEED
Definition servo_lidar.c:39
driver for the servo to move the lidar
#define PWM2ANGLE(pwm)
Definition servo_lidar.h:34
uint32_t last_update
Definition servo_lidar.h:42
uint8_t direction
Definition servo_lidar.h:41
float angle
Definition servo_lidar.h:40
uint8_t speed
Definition servo_lidar.h:38
int32_t position
Definition servo_lidar.h:39
static const ShellCommand commands[]
Definition shell_arch.c:78
struct TFMini tfmini
Definition tfmini.c:53
driver for the TFMini lidar
float distance
Definition tfmini.h:57
arch independent UART (Universal Asynchronous Receiver/Transmitter) API