PX4 Firmware
PX4 Autopilot Software http://px4.io
VehicleAcceleration.hpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2019 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 #pragma once
35 
39 #include <px4_platform_common/px4_config.h>
40 #include <px4_platform_common/log.h>
41 #include <px4_platform_common/module_params.h>
42 #include <px4_platform_common/px4_work_queue/WorkItem.hpp>
43 #include <uORB/Publication.hpp>
44 #include <uORB/Subscription.hpp>
50 
53 
54 class VehicleAcceleration : public ModuleParams, public px4::WorkItem
55 {
56 public:
57 
59  virtual ~VehicleAcceleration();
60 
61  void Run() override;
62 
63  bool Start();
64  void Stop();
65 
66  void PrintStatus();
67 
68 private:
69 
70  void ParametersUpdate(bool force = false);
71  void SensorBiasUpdate(bool force = false);
72  bool SensorCorrectionsUpdate(bool force = false);
73 
74  static constexpr int MAX_SENSOR_COUNT = 3;
75 
76  DEFINE_PARAMETERS(
77  (ParamInt<px4::params::SENS_BOARD_ROT>) _param_sens_board_rot,
78 
79  (ParamFloat<px4::params::SENS_BOARD_X_OFF>) _param_sens_board_x_off,
80  (ParamFloat<px4::params::SENS_BOARD_Y_OFF>) _param_sens_board_y_off,
81  (ParamFloat<px4::params::SENS_BOARD_Z_OFF>) _param_sens_board_z_off
82  )
83 
84  uORB::Publication<vehicle_acceleration_s> _vehicle_acceleration_pub{ORB_ID(vehicle_acceleration)};
85 
86  uORB::Subscription _params_sub{ORB_ID(parameter_update)}; /**< parameter updates subscription */
87  uORB::Subscription _sensor_bias_sub{ORB_ID(sensor_bias)}; /**< sensor in-run bias correction subscription */
88  uORB::Subscription _sensor_correction_sub{ORB_ID(sensor_correction)}; /**< sensor thermal correction subscription */
89 
90  uORB::SubscriptionCallbackWorkItem _sensor_selection_sub{this, ORB_ID(sensor_selection)}; /**< selected primary sensor subscription */
92  {this, ORB_ID(sensor_accel), 0},
93  {this, ORB_ID(sensor_accel), 1},
94  {this, ORB_ID(sensor_accel), 2}
95  };
96 
97  matrix::Dcmf _board_rotation; /**< rotation matrix for the orientation that the board is mounted */
98 
102 
103  uint8_t _selected_sensor{0};
104 
105 };
void ParametersUpdate(bool force=false)
bool SensorCorrectionsUpdate(bool force=false)
Limiting / constrain helper functions.
Vector rotation library.
Base publication wrapper class.
Definition: Publication.hpp:52
uORB::Subscription _sensor_correction_sub
sensor thermal correction subscription
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
uORB::SubscriptionCallbackWorkItem _sensor_sub[MAX_SENSOR_COUNT]
sensor data subscription
uORB::Subscription _sensor_bias_sub
sensor in-run bias correction subscription
matrix::Dcmf _board_rotation
rotation matrix for the orientation that the board is mounted
void SensorBiasUpdate(bool force=false)
static constexpr int MAX_SENSOR_COUNT
DEFINE_PARAMETERS((ParamInt< px4::params::SENS_BOARD_ROT >) _param_sens_board_rot,(ParamFloat< px4::params::SENS_BOARD_X_OFF >) _param_sens_board_x_off,(ParamFloat< px4::params::SENS_BOARD_Y_OFF >) _param_sens_board_y_off,(ParamFloat< px4::params::SENS_BOARD_Z_OFF >) _param_sens_board_z_off) uORB uORB::Subscription _params_sub
parameter updates subscription
matrix::Vector3f _offset
uORB::SubscriptionCallbackWorkItem _sensor_selection_sub
selected primary sensor subscription