px4_v1.12.1_13070.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 
19 #include "px4_v1.12.1_13070.hpp"
20 
22  actuatorsPub = _node.advertise<sensor_msgs::Joy>(MAPPED_ACTUATOR_TOPIC, 5);
24 
25  sp_to_dynamics.axes.resize(8, 0.0f);
26 
27  return 0;
28 }
29 void PX4_V_1_12_1_Airframe_13070_to_VTOL::motorsCallback(sensor_msgs::Joy sp_from_px4) {
30  if (sp_from_px4.axes.size() != 4 && sp_from_px4.axes.size() != 8) {
31  return;
32  }
33 
34  auto& axes = sp_to_dynamics.axes;
35 
36  axes[VTOL_MOTOR_0_FRONT_RIGHT] = sp_from_px4.axes[0];
37  axes[VTOL_MOTOR_1_REAR_LEFT] = sp_from_px4.axes[1];
38  axes[VTOL_MOTOR_2_FRONT_LEFT] = sp_from_px4.axes[2];
39  axes[VTOL_MOTOR_3_REAR_RIGHT] = sp_from_px4.axes[3];
40 
41  if (sp_from_px4.axes.size() == 8) {
42  axes[VTOL_AILERONS] = clamp_float(sp_from_px4.axes[INPUT_AILERONS], 0.0f, 1.0f) * 2.0f - 1.0f;
43  axes[VTOL_ELEVATORS] = 1.0f - clamp_float(sp_from_px4.axes[INPUT_ELEVATORS], 0.0f, 1.0f) * 2.0f;
44  axes[VTOL_RUDDERS] = clamp_float(sp_from_px4.axes[INPUT_RUDDERS], 0.0f, 1.0f) * 2.0f - 1.0f;
45  axes[VTOL_THROTLE] = sp_from_px4.axes[INPUT_THROTLE] / 0.75f;
46  } else if (sp_from_px4.axes.size() == 4) {
47  axes[VTOL_AILERONS] = 0.0f;
48  axes[VTOL_ELEVATORS] = 0.0f;
49  axes[VTOL_RUDDERS] = 0.0f;
50  axes[VTOL_THROTLE] = 0.0f;
51  }
52 
54 }
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
PX4_V_1_12_1_Airframe_13070_to_VTOL::INPUT_ELEVATORS
@ INPUT_ELEVATORS
[1.0; +1.0]
Definition: px4_v1.12.1_13070.hpp:32
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
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_V_1_12_1_Airframe_13070_to_VTOL::INPUT_RUDDERS
@ INPUT_RUDDERS
[1.0; +1.0]
Definition: px4_v1.12.1_13070.hpp:33
PX4_V_1_12_1_Airframe_13070_to_VTOL::motorsCallback
void motorsCallback(sensor_msgs::Joy sp_from_px4) override
Definition: px4_v1.12.1_13070.cpp:29
BaseReverseMixer::sp_to_dynamics
sensor_msgs::Joy sp_to_dynamics
Definition: base_mixer.hpp:58
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_v1.12.1_13070.hpp
BaseReverseMixer::MAPPED_ACTUATOR_TOPIC
static constexpr char MAPPED_ACTUATOR_TOPIC[]
Definition: base_mixer.hpp:62
PX4_V_1_12_1_Airframe_13070_to_VTOL::INPUT_AILERONS
@ INPUT_AILERONS
[1.0; +1.0]
Definition: px4_v1.12.1_13070.hpp:31
f
static const double f
Definition: geodetic.cpp:22
PX4_V_1_12_1_Airframe_13070_to_VTOL::INPUT_THROTLE
@ INPUT_THROTLE
[0.0; +1.0]
Definition: px4_v1.12.1_13070.hpp:34
PX4_V_1_12_1_Airframe_13070_to_VTOL::init
int8_t init() override
Definition: px4_v1.12.1_13070.cpp:21


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