mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 05:23:33 +08:00
Merge pull request #1600 from anton-matosov/SK450DeadCat.v2
Implemented SK450 DeadCat frame support
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
#!nsh
|
||||||
|
#
|
||||||
|
# HobbyKing SK450 DeadCat modification
|
||||||
|
#
|
||||||
|
# Anton Matosov <anton.matosov@gmail.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
sh /etc/init.d/rc.mc_defaults
|
||||||
|
|
||||||
|
if [ $AUTOCNF == yes ]
|
||||||
|
then
|
||||||
|
param set MC_ROLL_P 6.0
|
||||||
|
param set MC_ROLLRATE_P 0.04
|
||||||
|
param set MC_ROLLRATE_I 0.1
|
||||||
|
param set MC_ROLLRATE_D 0.0015
|
||||||
|
|
||||||
|
param set MC_PITCH_P 6.0
|
||||||
|
param set MC_PITCHRATE_P 0.08
|
||||||
|
param set MC_PITCHRATE_I 0.2
|
||||||
|
param set MC_PITCHRATE_D 0.0015
|
||||||
|
|
||||||
|
param set MC_YAW_P 2.8
|
||||||
|
param set MC_YAWRATE_P 0.1
|
||||||
|
param set MC_YAWRATE_I 0.07
|
||||||
|
param set MC_YAWRATE_D 0.0
|
||||||
|
fi
|
||||||
|
|
||||||
|
set MIXER sk450_deadcat
|
||||||
|
|
||||||
|
set PWM_OUT 1234
|
||||||
|
set PWM_MIN 1050
|
||||||
@@ -226,6 +226,11 @@ then
|
|||||||
sh /etc/init.d/10018_tbs_endurance
|
sh /etc/init.d/10018_tbs_endurance
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if param compare SYS_AUTOSTART 10019
|
||||||
|
then
|
||||||
|
sh /etc/init.d/10019_sk450_deadcat
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# Hexa Coaxial
|
# Hexa Coaxial
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ then
|
|||||||
then
|
then
|
||||||
set MAV_TYPE 2
|
set MAV_TYPE 2
|
||||||
fi
|
fi
|
||||||
if [ $MIXER == quad_w ]
|
if [ $MIXER == quad_w -o $MIXER == sk450_deadcat ]
|
||||||
then
|
then
|
||||||
set MAV_TYPE 2
|
set MAV_TYPE 2
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
Multirotor mixer for PX4FMU
|
||||||
|
===========================
|
||||||
|
|
||||||
|
This file defines a single mixer for a quadrotor in SK450 DeadCat configuration. All controls are mixed 100%.
|
||||||
|
|
||||||
|
R: 4dc 10000 10000 10000 0
|
||||||
|
|
||||||
|
Gimbal / payload mixer for last four channels
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 4 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 5 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 6 10000 10000 0 -10000 10000
|
||||||
|
|
||||||
|
M: 1
|
||||||
|
O: 10000 10000 0 -10000 10000
|
||||||
|
S: 0 7 10000 10000 0 -10000 10000
|
||||||
@@ -441,7 +441,6 @@ private:
|
|||||||
SimpleMixer operator=(const SimpleMixer&);
|
SimpleMixer operator=(const SimpleMixer&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supported multirotor geometries.
|
* Supported multirotor geometries.
|
||||||
*
|
*
|
||||||
@@ -460,12 +459,14 @@ class __EXPORT MultirotorMixer : public Mixer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
||||||
* Precalculated rotor mix.
|
* Precalculated rotor mix.
|
||||||
*/
|
*/
|
||||||
struct Rotor {
|
struct Rotor {
|
||||||
float roll_scale; /**< scales roll for this rotor */
|
float roll_scale; /**< scales roll for this rotor */
|
||||||
float pitch_scale; /**< scales pitch for this rotor */
|
float pitch_scale; /**< scales pitch for this rotor */
|
||||||
float yaw_scale; /**< scales yaw for this rotor */
|
float yaw_scale; /**< scales yaw for this rotor */
|
||||||
|
float out_scale; /**< scales total out for this rotor */
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ float constrain(float val, float min, float max)
|
|||||||
{
|
{
|
||||||
return (val < min) ? min : ((val > max) ? max : val);
|
return (val < min) ? min : ((val > max) ? max : val);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
|
MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
|
||||||
uintptr_t cb_handle,
|
uintptr_t cb_handle,
|
||||||
@@ -89,6 +90,7 @@ MultirotorMixer::MultirotorMixer(ControlCallback control_cb,
|
|||||||
_pitch_scale(pitch_scale),
|
_pitch_scale(pitch_scale),
|
||||||
_yaw_scale(yaw_scale),
|
_yaw_scale(yaw_scale),
|
||||||
_idle_speed(-1.0f + idle_speed * 2.0f), /* shift to output range here to avoid runtime calculation */
|
_idle_speed(-1.0f + idle_speed * 2.0f), /* shift to output range here to avoid runtime calculation */
|
||||||
|
_limits_pub(),
|
||||||
_rotor_count(_config_rotor_count[(MultirotorGeometryUnderlyingType)geometry]),
|
_rotor_count(_config_rotor_count[(MultirotorGeometryUnderlyingType)geometry]),
|
||||||
_rotors(_config_index[(MultirotorGeometryUnderlyingType)geometry])
|
_rotors(_config_index[(MultirotorGeometryUnderlyingType)geometry])
|
||||||
{
|
{
|
||||||
@@ -152,6 +154,9 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
|
|||||||
} else if (!strcmp(geomname, "4w")) {
|
} else if (!strcmp(geomname, "4w")) {
|
||||||
geometry = MultirotorGeometry::QUAD_WIDE;
|
geometry = MultirotorGeometry::QUAD_WIDE;
|
||||||
|
|
||||||
|
} else if (!strcmp(geomname, "4dc")) {
|
||||||
|
geometry = MultirotorGeometry::QUAD_DEADCAT;
|
||||||
|
|
||||||
} else if (!strcmp(geomname, "6+")) {
|
} else if (!strcmp(geomname, "6+")) {
|
||||||
geometry = MultirotorGeometry::HEX_PLUS;
|
geometry = MultirotorGeometry::HEX_PLUS;
|
||||||
|
|
||||||
@@ -212,6 +217,8 @@ MultirotorMixer::mix(float *outputs, unsigned space)
|
|||||||
pitch * _rotors[i].pitch_scale +
|
pitch * _rotors[i].pitch_scale +
|
||||||
thrust;
|
thrust;
|
||||||
|
|
||||||
|
out *= _rotors[i].out_scale;
|
||||||
|
|
||||||
/* limit yaw if it causes outputs clipping */
|
/* limit yaw if it causes outputs clipping */
|
||||||
if (out >= 0.0f && out < -yaw * _rotors[i].yaw_scale) {
|
if (out >= 0.0f && out < -yaw * _rotors[i].yaw_scale) {
|
||||||
yaw = -out / _rotors[i].yaw_scale;
|
yaw = -out / _rotors[i].yaw_scale;
|
||||||
|
|||||||
@@ -69,6 +69,13 @@ quad_plus = [
|
|||||||
[ 180, CW],
|
[ 180, CW],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
quad_deadcat = [
|
||||||
|
[ 63, CCW, 1.0],
|
||||||
|
[-135, CCW, 0.964],
|
||||||
|
[ -63, CW, 1.0],
|
||||||
|
[ 135, CW, 0.964],
|
||||||
|
]
|
||||||
|
|
||||||
quad_v = [
|
quad_v = [
|
||||||
[ 18.8, 0.4242],
|
[ 18.8, 0.4242],
|
||||||
[ -18.8, 1.0],
|
[ -18.8, 1.0],
|
||||||
@@ -148,13 +155,18 @@ twin_engine = [
|
|||||||
[-90, 0.0],
|
[-90, 0.0],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
tables = [quad_x, quad_plus, quad_v, quad_wide, quad_deadcat, hex_x, hex_plus, hex_cox, octa_x, octa_plus, octa_cox, twin_engine]
|
||||||
|
|
||||||
def variableName(variable):
|
def variableName(variable):
|
||||||
for variableName, value in list(globals().items()):
|
for variableName, value in list(globals().items()):
|
||||||
if value is variable:
|
if value is variable:
|
||||||
return variableName
|
return variableName
|
||||||
|
|
||||||
tables = [quad_x, quad_plus, quad_v, quad_wide, hex_x, hex_plus, hex_cox, octa_x, octa_plus, octa_cox, twin_engine]
|
def unpackScales(scalesList):
|
||||||
|
if len(scalesList) == 2:
|
||||||
|
scalesList += [1.0] #Add thrust scale
|
||||||
|
return scalesList
|
||||||
|
|
||||||
def printEnum():
|
def printEnum():
|
||||||
print("enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {")
|
print("enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {")
|
||||||
@@ -167,10 +179,11 @@ def printEnum():
|
|||||||
def printScaleTables():
|
def printScaleTables():
|
||||||
for table in tables:
|
for table in tables:
|
||||||
print("const MultirotorMixer::Rotor _config_{}[] = {{".format(variableName(table)))
|
print("const MultirotorMixer::Rotor _config_{}[] = {{".format(variableName(table)))
|
||||||
for (angle, yawScale) in table:
|
for row in table:
|
||||||
|
angle, yawScale, thrustScale = unpackScales(row)
|
||||||
rollScale = rcos(angle + 90)
|
rollScale = rcos(angle + 90)
|
||||||
pitchScale = rcos(angle)
|
pitchScale = rcos(angle)
|
||||||
print("\t{{ {:9f}, {:9f}, {:9f} }},".format(rollScale, pitchScale, yawScale))
|
print("\t{{ {:9f}, {:9f}, {:9f}, {:9f} }},".format(rollScale, pitchScale, yawScale, thrustScale))
|
||||||
print("};\n")
|
print("};\n")
|
||||||
|
|
||||||
def printScaleTablesIndex():
|
def printScaleTablesIndex():
|
||||||
|
|||||||
Reference in New Issue
Block a user