Uuv position control extension (#16688)

* Commit for the Integration of a position controller for the a Underwater vehicle.
This module is an extension of the uuv_att_control to control an Underwater vehicle to any position, given by the SET_POSITION_TARGET_LOCAL_NED which includes x y z yaw.
Since the position control is designed for a 6DOF Robot, the roll and pitch angle are controlled to be 0.
Additionally there is a stabilization control, which holds the robot at a defined depth, and not move in any direction.

In general the idea is to have this position module to control the position of the uuv. The position module reseives the desired position of the uuv and sends appropriate attitude setpoints to the uuv_attitude_control module.

Additionally the mixer file is adapted, to include the 6 different inputs(x y z roll pitch yaw).

* Commit for the Integration of a position controller for the a Underwater vehicle.
This module is an extension of the uuv_att_control to control an Underwater vehicle to any position, given by the SET_POSITION_TARGET_LOCAL_NED which includes x y z yaw.
Since the position control is designed for a 6DOF Robot, the roll and pitch angle are controlled to be 0.
Additionally there is a stabilization control, which holds the robot at a defined depth, and not move in any direction.

In general the idea is to have this position module to control the position of the uuv. The position module receives the desired position of the uuv and sends appropriate attitude setpoints to the uuv_attitude_control module.

Additionally the mixer file is adapted, to include the 6 different inputs(x y z roll pitch yaw).

Currently not solved/missing:
 - Problem with gazebo model(propeller moving chaotically).
 - Mixer correct gazebo vs real life (has to be tested in the future)
 - correct integration in uuv.apps (when choose which module)
 - very basic controller chosen (could be improved a lot in the future)

* Remove error caused by unused variables and a different build error

* added better description of the parameter. Additionally the group is changed.

* added better description of the parameter. Additionally the group is changed.
Fixed bug about parameter

* Added EOF to the files.

* Removed parameter for direct position control for safety reasons.

* small bugfix
This commit is contained in:
Tim
2021-02-15 18:40:28 +01:00
committed by GitHub
parent 0618f048f2
commit 540e4f9464
17 changed files with 623 additions and 16 deletions
@@ -1,32 +1,40 @@
# Motor 1 # Motor 1
M: 2 M: 3
S: 0 2 -4000 -4000 0 -4000 +4000 S: 0 2 -4000 -4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 -4000 -4000 0 -4000 +4000
# Motor 2 # Motor 2
M: 2 M: 3
S: 0 2 +4000 +4000 0 -4000 +4000 S: 0 2 +4000 +4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 +4000 +4000 0 -4000 +4000
# Motor 3 # Motor 3
M: 2 M: 3
S: 0 2 -4000 -4000 0 -4000 +4000 S: 0 2 -4000 -4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 +4000 +4000 0 -4000 +4000
# Motor 4 # Motor 4
M: 2 M: 3
S: 0 2 +4000 +4000 0 -4000 +4000 S: 0 2 +4000 +4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 -4000 -4000 0 -4000 +4000
# Motor 5 # Motor 5
M: 2 M: 3
S: 0 0 -4000 -4000 0 -4000 +4000 S: 0 0 -4000 -4000 0 -4000 +4000
S: 0 1 +4000 +4000 0 -4000 +4000 S: 0 1 +4000 +4000 0 -4000 +4000
S: 0 5 -4000 -4000 0 -4000 +4000
# Motor 6 # Motor 6
M: 2 M: 3
S: 0 0 -4000 -4000 0 -4000 +4000 S: 0 0 -4000 -4000 0 -4000 +4000
S: 0 1 -4000 -4000 0 -4000 +4000 S: 0 1 -4000 -4000 0 -4000 +4000
S: 0 5 +4000 +4000 0 -4000 +4000
# Motor 7 # Motor 7
M: 2 M: 3
S: 0 0 +4000 +4000 0 -4000 +4000 S: 0 0 +4000 +4000 0 -4000 +4000
S: 0 1 +4000 +4000 0 -4000 +4000 S: 0 1 +4000 +4000 0 -4000 +4000
S: 0 5 +4000 +4000 0 -4000 +4000
# Motor 8 # Motor 8
M: 2 M: 3
S: 0 0 +4000 +4000 0 -4000 +4000 S: 0 0 +4000 +4000 0 -4000 +4000
S: 0 1 -4000 -4000 0 -4000 +4000 S: 0 1 -4000 -4000 0 -4000 +4000
S: 0 5 -4000 -4000 0 -4000 +4000
@@ -1,32 +1,40 @@
# Motor 1 # Motor 1
M: 2 M: 3
S: 0 2 -4000 -4000 0 -4000 +4000 S: 0 2 -4000 -4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 +4000 +4000 0 -4000 +4000
# Motor 2 # Motor 2
M: 2 M: 3
S: 0 2 +4000 +4000 0 -4000 +4000 S: 0 2 +4000 +4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 -4000 -4000 0 -4000 +4000
# Motor 3 # Motor 3
M: 2 M: 3
S: 0 2 -4000 -4000 0 -4000 +4000 S: 0 2 -4000 -4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 -4000 -4000 0 -4000 +4000
# Motor 4 # Motor 4
M: 2 M: 3
S: 0 2 +4000 +4000 0 -4000 +4000 S: 0 2 +4000 +4000 0 -4000 +4000
S: 0 3 +4000 +4000 0 -4000 +4000 S: 0 3 +4000 +4000 0 -4000 +4000
S: 0 4 +4000 +4000 0 -4000 +4000
# Motor 5 # Motor 5
M: 2 M: 3
S: 0 0 -4000 -4000 0 -4000 +4000 S: 0 0 -4000 -4000 0 -4000 +4000
S: 0 1 +4000 +4000 0 -4000 +4000 S: 0 1 +4000 +4000 0 -4000 +4000
S: 0 5 +4000 +4000 0 -4000 +4000
# Motor 6 # Motor 6
M: 2 M: 3
S: 0 0 -4000 -4000 0 -4000 +4000 S: 0 0 -4000 -4000 0 -4000 +4000
S: 0 1 -4000 -4000 0 -4000 +4000 S: 0 1 -4000 -4000 0 -4000 +4000
S: 0 5 -4000 -4000 0 -4000 +4000
# Motor 7 # Motor 7
M: 2 M: 3
S: 0 0 +4000 +4000 0 -4000 +4000 S: 0 0 +4000 +4000 0 -4000 +4000
S: 0 1 +4000 +4000 0 -4000 +4000 S: 0 1 +4000 +4000 0 -4000 +4000
S: 0 5 -4000 -4000 0 -4000 +4000
# Motor 8 # Motor 8
M: 2 M: 3
S: 0 0 +4000 +4000 0 -4000 +4000 S: 0 0 +4000 +4000 0 -4000 +4000
S: 0 1 -4000 -4000 0 -4000 +4000 S: 0 1 -4000 -4000 0 -4000 +4000
S: 0 5 +4000 +4000 0 -4000 +4000
+1
View File
@@ -89,6 +89,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -84,6 +84,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -86,6 +86,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -83,6 +83,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -93,6 +93,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -91,6 +91,7 @@ px4_add_board(
sih sih
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -57,6 +57,7 @@ px4_add_board(
simulator simulator
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -55,6 +55,7 @@ px4_add_board(
simulator simulator
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -55,6 +55,7 @@ px4_add_board(
simulator simulator
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -55,6 +55,7 @@ px4_add_board(
simulator simulator
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
+1
View File
@@ -54,6 +54,7 @@ px4_add_board(
simulator simulator
temperature_compensation temperature_compensation
uuv_att_control uuv_att_control
uuv_pos_control
vmount vmount
vtol_att_control vtol_att_control
SYSTEMCMDS SYSTEMCMDS
@@ -0,0 +1,40 @@
############################################################################
#
# Copyright (c) 2020 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.
#
############################################################################
px4_add_module(
MODULE modules__uuv_pos_control
MAIN uuv_pos_control
STACK_MAIN 1200
COMPILE_FLAGS
SRCS
uuv_pos_control.cpp
)
@@ -0,0 +1,291 @@
/****************************************************************************
*
* Copyright (c) 2020 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.
*
****************************************************************************/
/**
*
* This module is a modification of the hippocampus control module and is designed for the
* BlueROV2.
*
* All the acknowledgments and credits for the fw wing app are reported in those files.
*
* @author Tim Hansen <t.hansen@jacobs-university.de>
* @author Daniel Duecker <daniel.duecker@tuhh.de>
*/
#include "uuv_pos_control.hpp"
/**
* UUV pos_controller app start / stop handling function
*
* @ingroup apps
*/
extern "C" __EXPORT int uuv_pos_control_main(int argc, char *argv[]);
UUVPOSControl::UUVPOSControl():
ModuleParams(nullptr),
WorkItem(MODULE_NAME, px4::wq_configurations::nav_and_controllers),
/* performance counters */
_loop_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle"))
{
}
UUVPOSControl::~UUVPOSControl()
{
perf_free(_loop_perf);
}
bool UUVPOSControl::init()
{
if (!_vehicle_local_position_sub.registerCallback()) {
PX4_ERR("vehicle_pos callback registration failed!");
return false;
}
return true;
}
void UUVPOSControl::parameters_update(bool force)
{
// check for parameter updates
if (_parameter_update_sub.updated() || force) {
// clear update
parameter_update_s pupdate;
_parameter_update_sub.copy(&pupdate);
// update parameters from storage
updateParams();
}
}
void UUVPOSControl::publish_attitude_setpoint(const float thrust_x, const float thrust_y, const float thrust_z,
const float roll_des, const float pitch_des, const float yaw_des)
{
//watch if inputs are not to high
vehicle_attitude_setpoint_s vehicle_attitude_setpoint = {};
vehicle_attitude_setpoint.timestamp = hrt_absolute_time();
vehicle_attitude_setpoint.roll_body = roll_des;
vehicle_attitude_setpoint.pitch_body = pitch_des;
vehicle_attitude_setpoint.yaw_body = yaw_des;
vehicle_attitude_setpoint.thrust_body[0] = thrust_x;
vehicle_attitude_setpoint.thrust_body[1] = thrust_y;
vehicle_attitude_setpoint.thrust_body[2] = thrust_z;
_att_sp_pub.publish(vehicle_attitude_setpoint);
}
void UUVPOSControl::pose_controller_6dof(const float x_pos_des, const float y_pos_des, const float z_pos_des,
const float roll_des, const float pitch_des, const float yaw_des,
vehicle_attitude_s &vehicle_attitude, vehicle_local_position_s &vlocal_pos)
{
//get current rotation of vehicle
Quatf q_att(vehicle_attitude.q);
Vector3f pos_des = Vector3f(x_pos_des, y_pos_des, z_pos_des);
Vector3f p_control_output = Vector3f(_param_pose_gain_x.get() * (pos_des(0) - vlocal_pos.x) - _param_pose_gain_d_x.get()
* vlocal_pos.vx,
_param_pose_gain_y.get() * (pos_des(1) - vlocal_pos.y) - _param_pose_gain_d_y.get() * vlocal_pos.vy,
_param_pose_gain_z.get() * (pos_des(2) - vlocal_pos.z) - _param_pose_gain_d_z.get() * vlocal_pos.vz);
Vector3f rotated_input = q_att.conjugate_inversed(p_control_output);//rotate the coord.sys (from global to body)
publish_attitude_setpoint(rotated_input(0),
rotated_input(1),
rotated_input(2),
roll_des, pitch_des, yaw_des);
}
void UUVPOSControl::stabilization_controller_6dof(const float x_pos_des, const float y_pos_des, const float z_pos_des,
const float roll_des, const float pitch_des, const float yaw_des,
vehicle_attitude_s &vehicle_attitude, vehicle_local_position_s &vlocal_pos)
{
//get current rotation of vehicle
Quatf q_att(vehicle_attitude.q);
Vector3f pos_des = Vector3f(0, 0, z_pos_des);
Vector3f p_control_output = Vector3f(0,
0,
_param_pose_gain_z.get() * (pos_des(2) - vlocal_pos.z));
//potential d controller missing
Vector3f rotated_input = q_att.conjugate_inversed(p_control_output);//rotate the coord.sys (from global to body)
publish_attitude_setpoint(rotated_input(0) + x_pos_des, rotated_input(1) + y_pos_des, rotated_input(2),
roll_des, pitch_des, yaw_des);
}
void UUVPOSControl::Run()
{
if (should_exit()) {
_vehicle_local_position_sub.unregisterCallback();
exit_and_cleanup();
return;
}
perf_begin(_loop_perf);
/* check vehicle control mode for changes to publication state */
_vcontrol_mode_sub.update(&_vcontrol_mode);
/* update parameters from storage */
parameters_update();
//vehicle_attitude_s attitude;
vehicle_local_position_s vlocal_pos;
/* only run controller if local_pos changed */
if (_vehicle_local_position_sub.update(&vlocal_pos)) {
/* Run geometric attitude controllers if NOT manual mode*/
if (!_vcontrol_mode.flag_control_manual_enabled
&& _vcontrol_mode.flag_control_attitude_enabled
&& _vcontrol_mode.flag_control_rates_enabled) {
_vehicle_attitude_sub.update(&_vehicle_attitude);//get current vehicle attitude
_pos_sp_triplet_sub.update(&_pos_setpoint);
float roll_des, pitch_des, yaw_des, x_pos_des, y_pos_des, z_pos_des;
roll_des = 0;
pitch_des = 0;
yaw_des = _pos_setpoint.current.yaw;
x_pos_des = _pos_setpoint.current.x;
y_pos_des = _pos_setpoint.current.y;
z_pos_des = _pos_setpoint.current.z;
//stabilization controller(keep pos and hold depth + angle) vs position controller(global + yaw)
if (_param_stabilization.get() == 0) {
pose_controller_6dof(x_pos_des, y_pos_des, z_pos_des,
roll_des, pitch_des, yaw_des, _vehicle_attitude, vlocal_pos);
} else {
stabilization_controller_6dof(x_pos_des, y_pos_des, z_pos_des,
roll_des, pitch_des, yaw_des, _vehicle_attitude, vlocal_pos);
}
}
}
/* Manual Control mode (e.g. gamepad,...) - raw feedthrough no assistance */
if (_manual_control_setpoint_sub.update(&_manual_control_setpoint)) {
// This should be copied even if not in manual mode. Otherwise, the poll(...) call will keep
// returning immediately and this loop will eat up resources.
if (_vcontrol_mode.flag_control_manual_enabled && !_vcontrol_mode.flag_control_rates_enabled) {
/* manual/direct control */
}
}
/* Only publish if any of the proper modes are enabled */
if (_vcontrol_mode.flag_control_manual_enabled ||
_vcontrol_mode.flag_control_attitude_enabled) {
}
perf_end(_loop_perf);
}
int UUVPOSControl::task_spawn(int argc, char *argv[])
{
UUVPOSControl *instance = new UUVPOSControl();
if (instance) {
_object.store(instance);
_task_id = task_id_is_work_queue;
if (instance->init()) {
return PX4_OK;
}
} else {
PX4_ERR("alloc failed");
}
delete instance;
_object.store(nullptr);
_task_id = -1;
return PX4_ERROR;
}
int UUVPOSControl::custom_command(int argc, char *argv[])
{
return print_usage("unknown command");
}
int UUVPOSControl::print_usage(const char *reason)
{
if (reason) {
PX4_WARN("%s\n", reason);
}
PRINT_MODULE_DESCRIPTION(
R"DESCR_STR(
### Description
Controls the attitude of an unmanned underwater vehicle (UUV).
Publishes `actuator_controls_0` messages at a constant 250Hz.
### Implementation
Currently, this implementation supports only a few modes:
* Full manual: Roll, pitch, yaw, and throttle controls are passed directly through to the actuators
* Auto mission: The uuv runs missions
### Examples
CLI usage example:
$ uuv_pos_control start
$ uuv_pos_control status
$ uuv_pos_control stop
)DESCR_STR");
PRINT_MODULE_USAGE_NAME("uuv_pos_control", "controller");
PRINT_MODULE_USAGE_COMMAND("start")
PRINT_MODULE_USAGE_DEFAULT_COMMANDS();
return 0;
}
int uuv_pos_control_main(int argc, char *argv[])
{
return UUVPOSControl::main(argc, argv);
}
@@ -0,0 +1,152 @@
/****************************************************************************
*
* Copyright (c) 2020 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.
*
****************************************************************************/
/**
*
* This module is a modification of the hippocampus control module and is designed for the
* BlueROV2.
*
* All the acknowledgments and credits for the fw wing app are reported in those files.
*
* @author Tim Hansen <t.hansen@jacobs-university.de>
* @author Daniel Duecker <daniel.duecker@tuhh.de>
*/
#include <float.h>
#include <drivers/drv_hrt.h>
#include <lib/ecl/geo/geo.h>
#include <lib/mathlib/mathlib.h>
#include <lib/perf/perf_counter.h>
#include <lib/pid/pid.h>
#include <matrix/math.hpp>
#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/defines.h>
#include <px4_platform_common/posix.h>
#include <px4_platform_common/tasks.h>
#include <px4_platform_common/module.h>
#include <px4_platform_common/module_params.h>
#include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/SubscriptionCallback.hpp>
#include <uORB/Publication.hpp>
#include <uORB/topics/manual_control_setpoint.h>
#include <uORB/topics/parameter_update.h>
#include <uORB/topics/position_setpoint_triplet.h>
#include <uORB/topics/vehicle_attitude.h>
#include <uORB/topics/vehicle_local_position.h>
#include <uORB/topics/vehicle_attitude_setpoint.h>
#include <uORB/topics/vehicle_angular_velocity.h>
#include <uORB/topics/vehicle_rates_setpoint.h>
#include <uORB/topics/vehicle_control_mode.h>
#include <uORB/topics/actuator_controls.h>
#include <uORB/uORB.h>
using matrix::Eulerf;
using matrix::Quatf;
using matrix::Matrix3f;
using matrix::Vector3f;
using matrix::Dcmf;
using uORB::SubscriptionData;
using namespace time_literals;
class UUVPOSControl: public ModuleBase<UUVPOSControl>, public ModuleParams, public px4::WorkItem
{
public:
UUVPOSControl();
~UUVPOSControl();
/** @see ModuleBase */
static int task_spawn(int argc, char *argv[]);
static int custom_command(int argc, char *argv[]);
/** @see ModuleBase */
static int print_usage(const char *reason = nullptr);
bool init();
private:
uORB::Publication<vehicle_attitude_setpoint_s> _att_sp_pub{ORB_ID(vehicle_attitude_setpoint)};
uORB::SubscriptionInterval _parameter_update_sub{ORB_ID(parameter_update), 1_s};
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)}; /**< current vehicle attitude */
uORB::Subscription _manual_control_setpoint_sub{ORB_ID(manual_control_setpoint)}; /**< notification of manual control updates */
uORB::Subscription _vcontrol_mode_sub{ORB_ID(vehicle_control_mode)}; /**< vehicle status subscription */
uORB::Subscription _pos_sp_triplet_sub{ORB_ID(position_setpoint_triplet)}; /**< position setpoint */
uORB::SubscriptionCallbackWorkItem _vehicle_local_position_sub{this, ORB_ID(vehicle_local_position)};
//actuator_controls_s _actuators {}; /**< actuator control inputs */
manual_control_setpoint_s _manual_control_setpoint {}; /**< r/c channel data */
vehicle_attitude_s _vehicle_attitude {}; /**< vehicle attitude */
position_setpoint_triplet_s _pos_setpoint {}; /**< vehicle position setpoint */
vehicle_control_mode_s _vcontrol_mode {}; /**< vehicle control mode */
perf_counter_t _loop_perf; /**< loop performance counter */
DEFINE_PARAMETERS(
(ParamFloat<px4::params::UUV_GAIN_X_P>) _param_pose_gain_x,
(ParamFloat<px4::params::UUV_GAIN_Y_P>) _param_pose_gain_y,
(ParamFloat<px4::params::UUV_GAIN_Z_P>) _param_pose_gain_z,
(ParamFloat<px4::params::UUV_GAIN_X_D>) _param_pose_gain_d_x,
(ParamFloat<px4::params::UUV_GAIN_Y_D>) _param_pose_gain_d_y,
(ParamFloat<px4::params::UUV_GAIN_Z_D>) _param_pose_gain_d_z,
(ParamInt<px4::params::UUV_INPUT_MODE>) _param_input_mode,
(ParamInt<px4::params::UUV_STAB_MODE>) _param_stabilization,
(ParamInt<px4::params::UUV_SKIP_CTRL>) _param_skip_ctrl
)
void Run() override;
/**
* Update our local parameter cache.
*/
void parameters_update(bool force = false);
/**
* Control Attitude
*/
void publish_attitude_setpoint(const float thrust_x, const float thrust_y, const float thrust_z,
const float roll_des, const float pitch_des, const float yaw_des);
void pose_controller_6dof(const float x_pos_des, const float y_pos_des, const float z_pos_des,
const float roll_des, const float pitch_des, const float yaw_des,
vehicle_attitude_s &vehicle_attitude, vehicle_local_position_s &vlocal_pos);
void stabilization_controller_6dof(const float x_pos_des, const float y_pos_des, const float z_pos_des,
const float roll_des, const float pitch_des, const float yaw_des,
vehicle_attitude_s &vehicle_attitude, vehicle_local_position_s &vlocal_pos);
};
@@ -0,0 +1,97 @@
/****************************************************************************
*
* Copyright (c) 2013-2020 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 uuv_pos_control_params.c
*
* Parameters defined by the position control task for unmanned underwater vehicles (UUVs)
*
* This is a modification of the fixed wing/ground rover params and it is designed for ground rovers.
* It has been developed starting from the fw module, simplified and improved with dedicated items.
*
* All the ackowledgments and credits for the fw wing/rover app are reported in those files.
*
* @author Tim Hansen <t.hansen@jacobs-university.de>
* @author Daniel Duecker <daniel.duecker@tuhh.de>
*/
/*
* Controller parameters, accessible via MAVLink
*
*/
/**
* Gain of P controller X
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_X_P, 1.0f);
/**
* Gain of P controller Y
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_Y_P, 1.0f);
/**
* Gain of P controller Z
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_Z_P, 1.0f);
/**
* Gain of D controller X
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_X_D, 0.2f);
/**
* Gain of D controller Y
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_Y_D, 0.2f);
/**
* Gain of D controller Z
*
* @group UUV Position Control
*/
PARAM_DEFINE_FLOAT(UUV_GAIN_Z_D, 0.2f);
/**
* Stabilization mode(1) or Position Control(0)
*
* @value 0 Position Control
* @value 1 Stabilization Mode
* @group UUV Position Control
*/
PARAM_DEFINE_INT32(UUV_STAB_MODE, 1);