Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
nps_radio_control.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
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#include "nps_radio_control.h"
23
26
27#include <stdio.h>
28
29#define RADIO_CONTROL_DT (1./40.)
30
32
33
34
36{
37
41
42 switch (type) {
43 case JOYSTICK:
45 break;
46 case SPEKTRUM:
48 break;
49 case SCRIPT:
50 break;
51 case NORC:
52 break;
53 default:
54 break;
55 }
56
57}
58
59
60typedef void (*rc_script)(double);
61
62static void radio_control_script_takeoff(double time);
63static void radio_control_script_hover(double time);
64static void radio_control_script_step_roll(double time);
65static void radio_control_script_step_pitch(double time);
66static void radio_control_script_step_yaw(double time);
67static void radio_control_script_ff(double time);
68
76
77
78#define RADIO_CONTROL_TAKEOFF_TIME 8
79
80
82{
85
93 //printf("throttle: %f, roll: %f, pitch: %f, yaw: %f\n", nps_joystick.throttle, nps_joystick.roll, nps_joystick.pitch, nps_joystick.yaw);
94 } else if (nps_radio_control.type == SCRIPT) {
97 } else {
99 }
100 }
101 return TRUE;
102 }
103 return FALSE;
104}
105
106
107
108
109/*
110 * Scripts
111 *
112 *
113 */
114
116{
122 /* starts motors */
123 if (time < 1.) {
125 } else {
127 }
128
129}
130
138
139
141{
144
145 if (((int32_t)rint((time * 0.5))) % 2) {
148 } else {
149 nps_radio_control.roll = -0.2;
151 }
152}
153
155{
160 if (((int32_t)rint((time * 0.5))) % 2) {
162 } else {
164 }
165}
166
168{
173
174 if (((int32_t)rint((time * 0.5))) % 2) {
176 } else {
177 nps_radio_control.yaw = -0.5;
178 }
179}
180
181void radio_control_script_ff(double time __attribute__((unused)))
182{
187 } else if (time < RADIO_CONTROL_TAKEOFF_TIME + 6) {
188 // nps_radio_control.roll = 0.5;
190 } else {
193 }
194}
uint16_t foo
Definition main_demo5.c:58
static void radio_control_script_step_roll(double time)
void nps_radio_control_init(enum NpsRadioControlType type, int num_script, char *js_dev)
static void radio_control_script_step_yaw(double time)
static void radio_control_script_hover(double time)
static void radio_control_script_step_pitch(double time)
static void radio_control_script_takeoff(double time)
bool nps_radio_control_available(double time)
#define RADIO_CONTROL_TAKEOFF_TIME
static void radio_control_script_ff(double time)
static rc_script scripts[]
#define RADIO_CONTROL_DT
void(* rc_script)(double)
struct NpsRadioControl nps_radio_control
#define MODE_SWITCH_MANUAL
NpsRadioControlType
@ SPEKTRUM
@ SCRIPT
@ JOYSTICK
#define MODE_SWITCH_AUTO2
enum NpsRadioControlType type
void nps_radio_control_joystick_update(void)
Updates joystick buttons from events, directly reads current axis positions.
struct NpsJoystick nps_joystick
int nps_radio_control_joystick_init(const char *device)
Initializes SDL and the joystick.
int nps_radio_control_spektrum_init(const char *device)
#define TRUE
Definition std.h:4
#define FALSE
Definition std.h:5
int int32_t
Typedef defining 32 bit int type.