px4_v1.14.0_13000_vtol_4_motors.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Dmitry Ponomarev <ponomarevda96@gmail.com>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Author: Dmitry Ponomarev <ponomarevda96@gmail.com>
17  */
18 
20 
22  actuatorsPub = _node.advertise<sensor_msgs::Joy>(MAPPED_ACTUATOR_TOPIC, 5);
23 
26 
27  for (uint_fast8_t idx = 0; idx < 8; idx++) {
28  actuatorsMsg.axes.push_back(0);
29  }
30 
31  return 0;
32 }
34  auto& axes = actuatorsMsg.axes;
35  if (msg.axes.size() >= 4) {
36  axes[VTOL_MOTOR_0_FRONT_RIGHT] = clamp_float(msg.axes[0], 0.0, 1.0);
37  axes[VTOL_MOTOR_1_REAR_LEFT] = clamp_float(msg.axes[1], 0.0, 1.0);
38  axes[VTOL_MOTOR_2_FRONT_LEFT] = clamp_float(msg.axes[2], 0.0, 1.0);
39  axes[VTOL_MOTOR_3_REAR_RIGHT] = clamp_float(msg.axes[3], 0.0, 1.0);
40  }
41  if (msg.axes.size() >= 5) {
42  axes[VTOL_THROTLE] = clamp_float(msg.axes[INPUT_THROTLE], 0.0, 1.0);
43  }
44  if (msg.axes.size() >= 9) {
45  if (abs(msg.axes[INPUT_AILERON_2]) < 0.001 &&
46  abs(msg.axes[INPUT_ELEVATORS]) < 0.001 &&
47  abs(msg.axes[INPUT_RUDDERS]) < 0.001) {
48  axes[VTOL_AILERONS] = 0.0;
49  axes[VTOL_ELEVATORS] = 0.0;
50  axes[VTOL_RUDDERS] = 0.0;
51  } else {
52  axes[VTOL_AILERONS] = 2.0 * clamp_float(msg.axes[INPUT_AILERON_2], 0.0, 1.0) - 1.0;
53  axes[VTOL_ELEVATORS] = 2.0 * clamp_float(msg.axes[INPUT_ELEVATORS], 0.0, 1.0) - 1.0;
54  axes[VTOL_RUDDERS] = 2.0 * clamp_float(msg.axes[INPUT_RUDDERS], 0.0, 1.0) - 1.0;
55  }
56  } else if (msg.axes.size() >= 8) {
57  axes[VTOL_AILERONS] = msg.axes[5];
58  axes[VTOL_ELEVATORS] = msg.axes[6];
59  axes[VTOL_RUDDERS] = msg.axes[7];
60  }
61 
63 }
66  actuatorsMsg.axes[VTOL_AILERONS] = clamp_float(msg.axes[1], -1.0, 1.0);
67  actuatorsMsg.axes[VTOL_ELEVATORS] = clamp_float(msg.axes[2], -1.0, 1.0);
68  actuatorsMsg.axes[VTOL_RUDDERS] = clamp_float(msg.axes[3], -1.0, 1.0);
69 }
BaseReverseMixer::_node
ros::NodeHandle _node
Definition: base_mixer.hpp:59
VTOL_MOTOR_0_FRONT_RIGHT
@ VTOL_MOTOR_0_FRONT_RIGHT
[ 0.0; +1.0]
Definition: base_mixer.hpp:34
VTOL_AILERONS
@ VTOL_AILERONS
[-1.0; +1.0]
Definition: base_mixer.hpp:39
BaseReverseMixer::motorsSub
ros::Subscriber motorsSub
Definition: base_mixer.hpp:60
VTOL_MOTOR_2_FRONT_LEFT
@ VTOL_MOTOR_2_FRONT_LEFT
[ 0.0; +1.0]
Definition: base_mixer.hpp:36
VTOL_THROTLE
@ VTOL_THROTLE
[ 0.0; +1.0]
Definition: base_mixer.hpp:38
PX4_V_1_14_0_Airframe_13000_4_motors::INPUT_ELEVATORS
@ INPUT_ELEVATORS
[-1.0; +1.0]
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:35
PX4_V_1_14_0_Airframe_13000_4_motors::INPUT_AILERON_2
@ INPUT_AILERON_2
[-1.0; +1.0]
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:34
PX4_V_1_14_0_Airframe_13000_4_motors::servosCallback
void servosCallback(sensor_msgs::Joy msg)
Definition: px4_v1.14.0_13000_vtol_4_motors.cpp:64
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
clamp_float
float clamp_float(float value, float min, float max)
Definition: base_mixer.cpp:27
VTOL_ELEVATORS
@ VTOL_ELEVATORS
[-1.0; +1.0]
Definition: base_mixer.hpp:40
px4_v1.14.0_13000_vtol_4_motors.hpp
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
BaseReverseMixer::actuatorsPub
ros::Publisher actuatorsPub
Definition: base_mixer.hpp:57
VTOL_MOTOR_3_REAR_RIGHT
@ VTOL_MOTOR_3_REAR_RIGHT
[ 0.0; +1.0]
Definition: base_mixer.hpp:37
BaseReverseMixer::MOTORS_TOPIC
static constexpr char MOTORS_TOPIC[]
Definition: base_mixer.hpp:63
VTOL_MOTOR_1_REAR_LEFT
@ VTOL_MOTOR_1_REAR_LEFT
[ 0.0; +1.0]
Definition: base_mixer.hpp:35
VTOL_RUDDERS
@ VTOL_RUDDERS
[-1.0; +1.0]
Definition: base_mixer.hpp:41
PX4_V_1_14_0_Airframe_13000_4_motors::INPUT_THROTLE
@ INPUT_THROTLE
[ 0.0; +1.0]
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:32
PX4_V_1_14_0_Airframe_13000_4_motors::init
int8_t init() override
Definition: px4_v1.14.0_13000_vtol_4_motors.cpp:21
PX4_V_1_14_0_Airframe_13000_4_motors::servosSub
ros::Subscriber servosSub
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:29
BaseReverseMixer::MAPPED_ACTUATOR_TOPIC
static constexpr char MAPPED_ACTUATOR_TOPIC[]
Definition: base_mixer.hpp:62
PX4_V_1_14_0_Airframe_13000_4_motors::INPUT_RUDDERS
@ INPUT_RUDDERS
[-1.0; +1.0]
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:36
BaseReverseMixer::SERVOS_TOPIC
static constexpr char SERVOS_TOPIC[]
Definition: base_mixer.hpp:64
PX4_V_1_14_0_Airframe_13000_4_motors::motorsCallback
void motorsCallback(sensor_msgs::Joy msg) override
Definition: px4_v1.14.0_13000_vtol_4_motors.cpp:33
PX4_V_1_14_0_Airframe_13000_4_motors::actuatorsMsg
sensor_msgs::Joy actuatorsMsg
Definition: px4_v1.14.0_13000_vtol_4_motors.hpp:41


inno_vtol_dynamics
Author(s): Roman Fedorenko, Dmitry Ponomarev, Ezra Tal, Winter Guerra
autogenerated on Mon Dec 9 2024 03:13:35