mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
Rename DfImu to DfMpu9250Wrapper
This commit is contained in:
@@ -37,7 +37,7 @@ set(config_module_list
|
|||||||
# $(EAGLE_DRIVERS_SRC)/uart_esc
|
# $(EAGLE_DRIVERS_SRC)/uart_esc
|
||||||
# $(EAGLE_DRIVERS_SRC)/rc_receiver
|
# $(EAGLE_DRIVERS_SRC)/rc_receiver
|
||||||
# $(EAGLE_DRIVERS_SRC)/csr_gps
|
# $(EAGLE_DRIVERS_SRC)/csr_gps
|
||||||
platforms/posix/drivers/df_imu
|
platforms/posix/drivers/df_mpu9250_wrapper
|
||||||
|
|
||||||
#
|
#
|
||||||
# System commands
|
# System commands
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
uorb start
|
uorb start
|
||||||
sleep 1
|
sleep 1
|
||||||
df_imu start
|
df_mpu9250_wrapper start
|
||||||
sensors start
|
sensors start
|
||||||
commander start
|
commander start
|
||||||
attitude_estimator_q start
|
attitude_estimator_q start
|
||||||
|
|||||||
+3
-3
@@ -34,10 +34,10 @@
|
|||||||
include_directories(../../../../lib/DriverFramework/drivers)
|
include_directories(../../../../lib/DriverFramework/drivers)
|
||||||
|
|
||||||
px4_add_module(
|
px4_add_module(
|
||||||
MODULE platforms__posix__drivers__df_imu
|
MODULE platforms__posix__drivers__df_mpu9250_wrapper
|
||||||
MAIN df_imu
|
MAIN df_mpu9250_wrapper
|
||||||
SRCS
|
SRCS
|
||||||
df_imu.cpp
|
df_mpu9250_wrapper.cpp
|
||||||
DEPENDS
|
DEPENDS
|
||||||
platforms__common
|
platforms__common
|
||||||
df_driver_framework
|
df_driver_framework
|
||||||
+25
-25
@@ -32,8 +32,8 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file df_imu.cpp
|
* @file DfMpu9250Wrapper.cpp
|
||||||
* Lightweight driver to access an IMU driver of the DriverFramework.
|
* Lightweight driver to access the MPU9250 of the DriverFramework.
|
||||||
*
|
*
|
||||||
* @author Julian Oes <julian@oes.ch>
|
* @author Julian Oes <julian@oes.ch>
|
||||||
*/
|
*/
|
||||||
@@ -65,16 +65,16 @@
|
|||||||
#include <DevMgr.hpp>
|
#include <DevMgr.hpp>
|
||||||
|
|
||||||
|
|
||||||
extern "C" { __EXPORT int df_imu_main(int argc, char *argv[]); }
|
extern "C" { __EXPORT int df_mpu9250_wrapper_main(int argc, char *argv[]); }
|
||||||
|
|
||||||
using namespace DriverFramework;
|
using namespace DriverFramework;
|
||||||
|
|
||||||
|
|
||||||
class DfImu : public MPU9250
|
class DfMpu9250Wrapper : public MPU9250
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DfImu(/*enum Rotation rotation*/);
|
DfMpu9250Wrapper(/*enum Rotation rotation*/);
|
||||||
~DfImu();
|
~DfMpu9250Wrapper();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -107,7 +107,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DfImu::DfImu(/*enum Rotation rotation*/) :
|
DfMpu9250Wrapper::DfMpu9250Wrapper(/*enum Rotation rotation*/) :
|
||||||
MPU9250(IMU_DEVICE_PATH),
|
MPU9250(IMU_DEVICE_PATH),
|
||||||
_accel_topic(nullptr),
|
_accel_topic(nullptr),
|
||||||
_gyro_topic(nullptr),
|
_gyro_topic(nullptr),
|
||||||
@@ -119,13 +119,13 @@ DfImu::DfImu(/*enum Rotation rotation*/) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DfImu::~DfImu()
|
DfMpu9250Wrapper::~DfMpu9250Wrapper()
|
||||||
{
|
{
|
||||||
perf_free(_accel_sample_perf);
|
perf_free(_accel_sample_perf);
|
||||||
perf_free(_gyro_sample_perf);
|
perf_free(_gyro_sample_perf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int DfImu::start()
|
int DfMpu9250Wrapper::start()
|
||||||
{
|
{
|
||||||
// TODO: don't publish garbage here
|
// TODO: don't publish garbage here
|
||||||
accel_report accel_report = {};
|
accel_report accel_report = {};
|
||||||
@@ -163,7 +163,7 @@ int DfImu::start()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DfImu::stop()
|
int DfMpu9250Wrapper::stop()
|
||||||
{
|
{
|
||||||
/* Stop sensor. */
|
/* Stop sensor. */
|
||||||
int ret = MPU9250::stop();
|
int ret = MPU9250::stop();
|
||||||
@@ -176,7 +176,7 @@ int DfImu::stop()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DfImu::_publish(struct imu_sensor_data &data)
|
int DfMpu9250Wrapper::_publish(struct imu_sensor_data &data)
|
||||||
{
|
{
|
||||||
/* Publish accel first. */
|
/* Publish accel first. */
|
||||||
perf_begin(_accel_sample_perf);
|
perf_begin(_accel_sample_perf);
|
||||||
@@ -239,10 +239,10 @@ int DfImu::_publish(struct imu_sensor_data &data)
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace df_imu
|
namespace df_mpu9250_wrapper
|
||||||
{
|
{
|
||||||
|
|
||||||
DfImu *g_dev = nullptr;
|
DfMpu9250Wrapper *g_dev = nullptr;
|
||||||
|
|
||||||
int start(/* enum Rotation rotation */);
|
int start(/* enum Rotation rotation */);
|
||||||
int stop();
|
int stop();
|
||||||
@@ -251,16 +251,16 @@ void usage();
|
|||||||
|
|
||||||
int start(/*enum Rotation rotation*/)
|
int start(/*enum Rotation rotation*/)
|
||||||
{
|
{
|
||||||
g_dev = new DfImu(/*rotation*/);
|
g_dev = new DfMpu9250Wrapper(/*rotation*/);
|
||||||
|
|
||||||
if (g_dev == nullptr) {
|
if (g_dev == nullptr) {
|
||||||
PX4_ERR("failed instantiating DfImu object");
|
PX4_ERR("failed instantiating DfMpu9250Wrapper object");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = g_dev->start();
|
int ret = g_dev->start();
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
PX4_ERR("DfImu start failed");
|
PX4_ERR("DfMpu9250Wrapper start failed");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,16 +317,16 @@ info()
|
|||||||
void
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
PX4_WARN("Usage: df_imu 'start', 'info', 'stop'");
|
PX4_WARN("Usage: df_mpu9250_wrapper 'start', 'info', 'stop'");
|
||||||
PX4_WARN("options:");
|
PX4_WARN("options:");
|
||||||
//PX4_WARN(" -R rotation");
|
//PX4_WARN(" -R rotation");
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace df_imu
|
} // namespace df_mpu9250_wrapper
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
df_imu_main(int argc, char *argv[])
|
df_mpu9250_wrapper_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
// enum Rotation rotation = ROTATION_NONE;
|
// enum Rotation rotation = ROTATION_NONE;
|
||||||
@@ -342,13 +342,13 @@ df_imu_main(int argc, char *argv[])
|
|||||||
// break;
|
// break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
df_imu::usage();
|
df_mpu9250_wrapper::usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
df_imu::usage();
|
df_mpu9250_wrapper::usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,19 +356,19 @@ df_imu_main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
if (!strcmp(verb, "start")) {
|
if (!strcmp(verb, "start")) {
|
||||||
ret = df_imu::start(/*rotation*/);
|
ret = df_mpu9250_wrapper::start(/*rotation*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(verb, "stop")) {
|
else if (!strcmp(verb, "stop")) {
|
||||||
ret = df_imu::stop();
|
ret = df_mpu9250_wrapper::stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (!strcmp(verb, "info")) {
|
else if (!strcmp(verb, "info")) {
|
||||||
ret = df_imu::info();
|
ret = df_mpu9250_wrapper::info();
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
df_imu::usage();
|
df_mpu9250_wrapper::usage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user