PX4 Firmware
PX4 Autopilot Software http://px4.io
output_rc.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * Copyright (c) 2016 PX4 Development Team. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
14 * distribution.
15 * 3. Neither the name PX4 nor the names of its contributors may be
16 * used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 ****************************************************************************/
33 
34 /**
35  * @file output_rc.cpp
36  * @author Leon Müller (thedevleon)
37  * @author Beat Küng <beat-kueng@gmx.net>
38  *
39  */
40 
41 #include "output_rc.h"
42 
44 #include <px4_platform_common/defines.h>
45 
46 
47 namespace vmount
48 {
49 
50 OutputRC::OutputRC(const OutputConfig &output_config)
51  : OutputBase(output_config)
52 {
53 }
55 {
58  }
59 }
60 
61 int OutputRC::update(const ControlData *control_data)
62 {
63  if (control_data) {
64  //got new command
66  _set_angle_setpoints(control_data);
67  }
68 
70 
73 
75  actuator_controls.timestamp = hrt_absolute_time();
76  // _angle_outputs are in radians, actuator_controls are in [-1, 1]
77  actuator_controls.control[0] = (_angle_outputs[0] + _config.roll_offset) * _config.roll_scale;
78  actuator_controls.control[1] = (_angle_outputs[1] + _config.pitch_offset) * _config.pitch_scale;
79  actuator_controls.control[2] = (_angle_outputs[2] + _config.yaw_offset) * _config.yaw_scale;
81 
82  int instance;
85 
86  _last_update = t;
87 
88  return 0;
89 }
90 
92 {
93  PX4_INFO("Output: AUX");
94 }
95 
96 } /* namespace vmount */
97 
float pitch_offset
Offset for pitch channel in radians.
Definition: output.h:63
float yaw_scale
Scale factor for yaw channel (maps from angle in radians to actuator output in [-1,1]).
Definition: output.h:61
orb_advert_t _actuator_controls_pub
Definition: output_rc.h:66
void _handle_position_update(bool force_update=false)
check if vehicle position changed and update the setpoint angles if in gps mode
Definition: output.cpp:156
const OutputConfig & _config
Definition: output.h:103
void _calculate_output_angles(const hrt_abstime &t)
calculate the _angle_outputs (with speed) and stabilize if needed
Definition: output.cpp:201
float yaw_offset
Offset for yaw channel in radians.
Definition: output.h:65
LidarLite * instance
Definition: ll40ls.cpp:65
Definition: common.h:45
float gimbal_normal_mode_value
Mixer output value for selecting gimbal normal mode.
Definition: output.h:54
OutputRC(const OutputConfig &output_config)
Definition: output_rc.cpp:50
bool gimbal_shutter_retract
whether to lock the gimbal (only in RC output mode)
Definition: common.h:88
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
float gimbal_retracted_mode_value
Mixer output value for selecting gimbal retracted mode.
Definition: output.h:53
virtual int update(const ControlData *control_data)
Update the output.
Definition: output_rc.cpp:61
hrt_abstime _last_update
Definition: output.h:120
virtual ~OutputRC()
Definition: output_rc.cpp:54
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
Definition: drv_hrt.h:58
This defines the common API between an input and an output of the vmount driver.
Definition: common.h:55
void _set_angle_setpoints(const ControlData *control_data)
set angle setpoints, speeds & stabilize flags
Definition: output.cpp:122
float _angle_outputs[3]
calculated output angles (roll, pitch, yaw) [rad]
Definition: output.h:119
float pitch_scale
Scale factor for pitch channel (maps from angle in radians to actuator output in [-1,1]).
Definition: output.h:57
bool _retract_gimbal
Definition: output_rc.h:67
static float actuator_controls[output_max]
virtual void print_status()
report status to stdout
Definition: output_rc.cpp:91
int orb_unadvertise(orb_advert_t handle)
Definition: uORB.cpp:65
float roll_scale
Scale factor for roll channel (maps from angle in radians to actuator output in [-1,1]).
Definition: output.h:59
class OutputBase Base class for all driver output classes
Definition: output.h:76
float roll_offset
Offset for roll channel in radians.
Definition: output.h:64
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
static int orb_publish_auto(const struct orb_metadata *meta, orb_advert_t *handle, const void *data, int *instance, int priority)
Advertise as the publisher of a topic.
Definition: uORB.h:177