Merged release_v1.0.0 into master

This commit is contained in:
Lorenz Meier
2015-05-27 15:28:41 -07:00
102 changed files with 977 additions and 2266 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ Airspeed::update_status()
true,
true,
_sensor_ok,
SUBSYSTEM_TYPE_DIFFPRESSURE
subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE
};
if (_subsys_pub != nullptr) {
+18 -2
View File
@@ -67,6 +67,21 @@
*/
#define RC_INPUT_RSSI_MAX 100
/**
* Minimum value
*/
#define RC_INPUT_LOWEST_MIN_US 500
/**
* Maximum value
*/
#define RC_INPUT_HIGHEST_MAX_US 2500
/**
* Maximum deadzone value
*/
#define RC_INPUT_MAX_DEADZONE_US 500
/**
* @addtogroup topics
* @{
@@ -84,7 +99,8 @@ enum RC_INPUT_SOURCE {
RC_INPUT_SOURCE_PX4IO_PPM,
RC_INPUT_SOURCE_PX4IO_SPEKTRUM,
RC_INPUT_SOURCE_PX4IO_SBUS,
RC_INPUT_SOURCE_PX4IO_ST24
RC_INPUT_SOURCE_PX4IO_ST24,
RC_INPUT_SOURCE_MAVLINK
};
/**
@@ -103,7 +119,7 @@ struct rc_input_values {
/** number of channels actually being seen */
uint32_t channel_count;
/** receive signal strength indicator (RSSI): < 0: Undefined, 0: no signal, 255: full reception */
/** receive signal strength indicator (RSSI): < 0: Undefined, 0: no signal, 100: full reception */
int32_t rssi;
/**
+8 -6
View File
@@ -330,13 +330,13 @@ Gimbal::cycle()
orb_copy(ORB_ID(vehicle_command), _vehicle_command_sub, &cmd);
if (cmd.command == VEHICLE_CMD_DO_MOUNT_CONTROL
|| cmd.command == VEHICLE_CMD_DO_MOUNT_CONTROL_QUAT) {
if (cmd.command == vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL
|| cmd.command == vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL_QUAT) {
_control_cmd = cmd;
_control_cmd_set = true;
} else if (cmd.command == VEHICLE_CMD_DO_MOUNT_CONFIGURE) {
} else if (cmd.command == vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONFIGURE) {
_config_cmd = cmd;
_config_cmd_set = true;
@@ -357,10 +357,11 @@ Gimbal::cycle()
if (_control_cmd_set) {
VEHICLE_MOUNT_MODE mountMode = (VEHICLE_MOUNT_MODE)_control_cmd.param7;
unsigned mountMode = _control_cmd.param7;
debug("control_cmd: %d, mountMode %d | param1: %8.4f param2: %8.4f", _control_cmd.command, mountMode, (double)_control_cmd.param1, (double)_control_cmd.param2);
if (_control_cmd.command == VEHICLE_CMD_DO_MOUNT_CONTROL && mountMode == VEHICLE_MOUNT_MODE_MAVLINK_TARGETING) {
if (_control_cmd.command == vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL &&
mountMode == vehicle_command_s::VEHICLE_MOUNT_MODE_MAVLINK_TARGETING) {
/* Convert to range -1 ... 1, which corresponds to -180deg ... 180deg */
roll += 1.0f / M_PI_F * M_DEG_TO_RAD_F * _control_cmd.param1;
pitch += 1.0f / M_PI_F * M_DEG_TO_RAD_F * _control_cmd.param2;
@@ -369,7 +370,8 @@ Gimbal::cycle()
updated = true;
}
if (_control_cmd.command == VEHICLE_CMD_DO_MOUNT_CONTROL_QUAT && mountMode == VEHICLE_MOUNT_MODE_MAVLINK_TARGETING) {
if (_control_cmd.command == vehicle_command_s::VEHICLE_CMD_DO_MOUNT_CONTROL_QUAT &&
mountMode == vehicle_command_s::VEHICLE_MOUNT_MODE_MAVLINK_TARGETING) {
float gimbalDirectionQuat[] = {_control_cmd.param1, _control_cmd.param2, _control_cmd.param3, _control_cmd.param4};
math::Vector<3> gimablDirectionEuler = math::Quaternion(gimbalDirectionQuat).to_dcm().to_euler();
+2 -2
View File
@@ -111,9 +111,9 @@ publish_gam_message(const uint8_t *buffer)
// Publish it.
esc.timestamp = hrt_absolute_time();
esc.esc_count = 1;
esc.esc_connectiontype = ESC_CONNECTION_TYPE_PPM;
esc.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_PPM;
esc.esc[0].esc_vendor = ESC_VENDOR_GRAUPNER_HOTT;
esc.esc[0].esc_vendor = esc_status_s::ESC_VENDOR_GRAUPNER_HOTT;
esc.esc[0].esc_rpm = (uint16_t)((msg.rpm_H << 8) | (msg.rpm_L & 0xff)) * 10;
esc.esc[0].esc_temperature = static_cast<float>(msg.temperature1) - 20.0F;
esc.esc[0].esc_voltage = static_cast<float>((msg.main_voltage_H << 8) | (msg.main_voltage_L & 0xff)) * 0.1F;
+1 -1
View File
@@ -621,7 +621,7 @@ MB12XX::start()
true,
true,
true,
SUBSYSTEM_TYPE_RANGEFINDER
subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER
};
static orb_advert_t pub = nullptr;
+2 -2
View File
@@ -601,11 +601,11 @@ MK::task_main()
esc.counter++;
esc.timestamp = hrt_absolute_time();
esc.esc_count = (uint8_t) _num_outputs;
esc.esc_connectiontype = ESC_CONNECTION_TYPE_I2C;
esc.esc_connectiontype = esc_status_s::ESC_CONNECTION_TYPE_I2C;
for (unsigned int i = 0; i < _num_outputs; i++) {
esc.esc[i].esc_address = (uint8_t) BLCTRL_BASE_ADDR + i;
esc.esc[i].esc_vendor = ESC_VENDOR_MIKROKOPTER;
esc.esc[i].esc_vendor = esc_status_s::ESC_VENDOR_MIKROKOPTER;
esc.esc[i].esc_version = (uint16_t) Motor[i].Version;
esc.esc[i].esc_voltage = 0.0F;
esc.esc[i].esc_current = static_cast<float>(Motor[i].Current) * 0.1F;
+1 -1
View File
@@ -568,7 +568,7 @@ PX4FLOW::start()
true,
true,
true,
SUBSYSTEM_TYPE_OPTICALFLOW
subsystem_info_s::SUBSYSTEM_TYPE_OPTICALFLOW
};
static orb_advert_t pub = nullptr;
+40 -3
View File
@@ -67,6 +67,7 @@
#include <systemlib/mixer/mixer.h>
#include <systemlib/pwm_limit/pwm_limit.h>
#include <systemlib/board_serial.h>
#include <systemlib/param/param.h>
#include <drivers/drv_mixer.h>
#include <drivers/drv_rc_input.h>
@@ -77,6 +78,7 @@
#include <uORB/topics/actuator_controls_3.h>
#include <uORB/topics/actuator_outputs.h>
#include <uORB/topics/actuator_armed.h>
#include <uORB/topics/parameter_update.h>
#ifdef HRT_PPM_CHANNEL
@@ -132,6 +134,7 @@ private:
unsigned _current_update_rate;
int _task;
int _armed_sub;
int _param_sub;
orb_advert_t _outputs_pub;
actuator_armed_s _armed;
unsigned _num_outputs;
@@ -157,6 +160,7 @@ private:
uint16_t _disarmed_pwm[_max_actuators];
uint16_t _min_pwm[_max_actuators];
uint16_t _max_pwm[_max_actuators];
uint16_t _reverse_pwm_mask;
unsigned _num_failsafe_set;
unsigned _num_disarmed_set;
@@ -167,9 +171,10 @@ private:
uint8_t control_group,
uint8_t control_index,
float &input);
void subscribe();
void subscribe();
int set_pwm_rate(unsigned rate_map, unsigned default_rate, unsigned alt_rate);
int pwm_ioctl(file *filp, int cmd, unsigned long arg);
void update_pwm_rev_mask();
struct GPIOConfig {
uint32_t input;
@@ -253,6 +258,7 @@ PX4FMU::PX4FMU() :
_current_update_rate(0),
_task(-1),
_armed_sub(-1),
_param_sub(-1),
_outputs_pub(nullptr),
_armed{},
_num_outputs(0),
@@ -269,6 +275,7 @@ PX4FMU::PX4FMU() :
_pwm_limit{},
_failsafe_pwm{0},
_disarmed_pwm{0},
_reverse_pwm_mask(0),
_num_failsafe_set(0),
_num_disarmed_set(0)
{
@@ -543,6 +550,26 @@ PX4FMU::subscribe()
}
}
void
PX4FMU::update_pwm_rev_mask()
{
_reverse_pwm_mask = 0;
for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16];
int32_t ival;
/* fill the channel reverse mask from parameters */
sprintf(pname, "PWM_AUX_REV%d", i + 1);
param_t param_h = param_find(pname);
if (param_h != PARAM_INVALID) {
param_get(param_h, &ival);
_reverse_pwm_mask |= ((int16_t)(ival != 0)) << i;
}
}
}
void
PX4FMU::task_main()
{
@@ -550,6 +577,7 @@ PX4FMU::task_main()
_current_update_rate = 0;
_armed_sub = orb_subscribe(ORB_ID(actuator_armed));
_param_sub = orb_subscribe(ORB_ID(parameter_update));
/* advertise the mixed control outputs */
actuator_outputs_s outputs;
@@ -567,7 +595,7 @@ PX4FMU::task_main()
/* initialize PWM limit lib */
pwm_limit_init(&_pwm_limit);
log("starting");
update_pwm_rev_mask();
/* loop until killed */
while (!_task_should_exit) {
@@ -684,7 +712,7 @@ PX4FMU::task_main()
uint16_t pwm_limited[num_outputs];
/* the PWM limit call takes care of out of band errors and constrains */
pwm_limit_calc(_servo_armed, num_outputs, _disarmed_pwm, _min_pwm, _max_pwm, outputs.output, pwm_limited, &_pwm_limit);
pwm_limit_calc(_servo_armed, num_outputs, _reverse_pwm_mask, _disarmed_pwm, _min_pwm, _max_pwm, outputs.output, pwm_limited, &_pwm_limit);
/* output to the servos */
for (unsigned i = 0; i < num_outputs; i++) {
@@ -723,6 +751,14 @@ PX4FMU::task_main()
}
}
orb_check(_param_sub, &updated);
if (updated) {
parameter_update_s pupdate;
orb_copy(ORB_ID(parameter_update), _param_sub, &pupdate);
update_pwm_rev_mask();
}
#ifdef HRT_PPM_CHANNEL
// see if we have new PPM input data
@@ -768,6 +804,7 @@ PX4FMU::task_main()
}
}
::close(_armed_sub);
::close(_param_sub);
/* make sure servos are off */
up_pwm_servo_deinit();
+2 -1
View File
@@ -3,7 +3,8 @@
#
MODULE_COMMAND = fmu
SRCS = fmu.cpp
SRCS = fmu.cpp \
px4fmu_params.c
MODULE_STACKSIZE = 1200
+109
View File
@@ -0,0 +1,109 @@
/****************************************************************************
*
* Copyright (c) 2015 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file px4fmu_params.c
*
* Parameters defined by the PX4FMU driver
*
* @author Lorenz Meier <lorenz@px4.io>
*/
#include <nuttx/config.h>
#include <systemlib/param/param.h>
/**
* Invert direction of aux output channel 1
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV1, 0);
/**
* Invert direction of aux output channel 2
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV2, 0);
/**
* Invert direction of aux output channel 3
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV3, 0);
/**
* Invert direction of aux output channel 4
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV4, 0);
/**
* Invert direction of aux output channel 5
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV5, 0);
/**
* Invert direction of aux output channel 6
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_AUX_REV6, 0);
+2 -1
View File
@@ -40,7 +40,8 @@ MODULE_COMMAND = px4io
SRCS = px4io.cpp \
px4io_uploader.cpp \
px4io_serial.cpp \
px4io_i2c.cpp
px4io_i2c.cpp \
px4io_params.c
# XXX prune to just get UART registers
INCLUDE_DIRS += $(NUTTX_SRC)/arch/arm/src/stm32 $(NUTTX_SRC)/arch/arm/src/common
+36 -3
View File
@@ -281,6 +281,7 @@ private:
int _t_actuator_armed; ///< system armed control topic
int _t_vehicle_control_mode;///< vehicle control mode topic
int _t_param; ///< parameter update topic
bool _param_update_force; ///< force a parameter update
int _t_vehicle_command; ///< vehicle command topic
/* advertised topics */
@@ -514,6 +515,7 @@ PX4IO::PX4IO(device::Device *interface) :
_t_actuator_armed(-1),
_t_vehicle_control_mode(-1),
_t_param(-1),
_param_update_force(false),
_t_vehicle_command(-1),
_to_input_rc(nullptr),
_to_outputs(nullptr),
@@ -766,7 +768,7 @@ PX4IO::init()
cmd.param5 = 0;
cmd.param6 = 0;
cmd.param7 = 0;
cmd.command = VEHICLE_CMD_COMPONENT_ARM_DISARM;
cmd.command = vehicle_command_s::VEHICLE_CMD_COMPONENT_ARM_DISARM;
/* ask to confirm command */
cmd.confirmation = 1;
@@ -917,6 +919,8 @@ PX4IO::task_main()
fds[0].fd = _t_actuator_controls_0;
fds[0].events = POLLIN;
_param_update_force = true;
/* lock against the ioctl handler */
lock();
@@ -1005,7 +1009,7 @@ PX4IO::task_main()
orb_copy(ORB_ID(vehicle_command), _t_vehicle_command, &cmd);
// Check for a DSM pairing command
if (((int)cmd.command == VEHICLE_CMD_START_RX_PAIR) && ((int)cmd.param1 == 0)) {
if (((int)cmd.command == vehicle_command_s::VEHICLE_CMD_START_RX_PAIR) && ((int)cmd.param1 == 0)) {
dsm_bind_ioctl((int)cmd.param2);
}
}
@@ -1017,7 +1021,8 @@ PX4IO::task_main()
*/
orb_check(_t_param, &updated);
if (updated) {
if (updated || _param_update_force) {
_param_update_force = false;
parameter_update_s pupdate;
orb_copy(ORB_ID(parameter_update), _t_param, &pupdate);
@@ -1089,6 +1094,26 @@ PX4IO::task_main()
param_get(param_find("RC_RSSI_PWM_MAX"), &_rssi_pwm_max);
param_get(param_find("RC_RSSI_PWM_MIN"), &_rssi_pwm_min);
/*
* Set invert mask for PWM outputs (does not apply to S.Bus)
*/
int16_t pwm_invert_mask = 0;
for (unsigned i = 0; i < _max_actuators; i++) {
char pname[16];
int32_t ival;
/* fill the channel reverse mask from parameters */
sprintf(pname, "PWM_MAIN_REV%d", i + 1);
param_t param_h = param_find(pname);
if (param_h != PARAM_INVALID) {
param_get(param_h, &ival);
pwm_invert_mask |= ((int16_t)(ival != 0)) << i;
}
}
(void)io_reg_set(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_PWM_REVERSE, pwm_invert_mask);
}
}
@@ -2095,7 +2120,15 @@ PX4IO::print_status(bool extended_status)
for (unsigned i = 0; i < _max_actuators; i++)
printf(" %u", io_reg_get(PX4IO_PAGE_SERVOS, i));
uint16_t pwm_invert_mask = io_reg_get(PX4IO_PAGE_SETUP, PX4IO_P_SETUP_PWM_REVERSE);
printf("\n");
printf("reversed outputs: [");
for (unsigned i = 0; i < _max_actuators; i++) {
printf("%s", (pwm_invert_mask & (1 << i)) ? "x" : "_");
}
printf("]\n");
uint16_t raw_inputs = io_reg_get(PX4IO_PAGE_RAW_RC_INPUT, PX4IO_P_RAW_RC_COUNT);
printf("%d raw R/C inputs", raw_inputs);
+131
View File
@@ -0,0 +1,131 @@
/****************************************************************************
*
* Copyright (c) 2015 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file px4io_params.c
*
* Parameters defined by the PX4IO driver
*
* @author Lorenz Meier <lorenz@px4.io>
*/
#include <nuttx/config.h>
#include <systemlib/param/param.h>
/**
* Invert direction of main output channel 1
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV1, 0);
/**
* Invert direction of main output channel 2
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV2, 0);
/**
* Invert direction of main output channel 3
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV3, 0);
/**
* Invert direction of main output channel 4
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV4, 0);
/**
* Invert direction of main output channel 5
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV5, 0);
/**
* Invert direction of main output channel 6
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV6, 0);
/**
* Invert direction of main output channel 7
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV7, 0);
/**
* Invert direction of main output channel 8
*
* Set to 1 to invert the channel, 0 for default direction.
*
* @min 0
* @max 1
* @group PWM Outputs
*/
PARAM_DEFINE_INT32(PWM_MAIN_REV8, 0);
+1 -1
View File
@@ -619,7 +619,7 @@ TRONE::start()
true,
true,
true,
SUBSYSTEM_TYPE_RANGEFINDER
subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER
};
static orb_advert_t pub = nullptr;