Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

By design, the sensor fusion modules of path manager and attitude manager are the only consumers of sensor data. No other module should be accessing the sensor instances.

Within the sensor fusion modules, instances of each required sensor class are created and data is pulled from them by using the getResult() method. Here is an example:

#include "IMU.hpp"
#include "gps.hpp"

/***********************************************************************************************************************
 * Variables
 **********************************************************************************************************************/

static ICM20602 imuObj;
static NEOM8 gpsObj;

/***********************************************************************************************************************
 * Code
 **********************************************************************************************************************/


void SensorFusion_Execute(SensorResult *sensResult)
{

    IMUData_t imuData = imuObj.getResult();
    GpsData_t GpsData = gpsObj.getResult();

    sensResult.result = DoCrazyMath(&imuData, &GpsData);

}

Testing Sensor fusion algorithms

Developers of sensor fusion modules need a good way to test their algorithms. That means they need a way to decouple themselves from the hardware when they’re testing with banks of data. The way to do that is to write a derived sensor class that inherits from the abstract base class that exists at every sensor’s interface. The derived class can pull data from a file, matlab model, or wherever the bank of test data exists instead of from hardware.

That derived class can be placed inside the sensor interface file along with all the other derived classed.

I’ve modified the example above to show how this should be done.

#include "IMU.hpp"
#include "gps.hpp"

/***********************************************************************************************************************
 * Variables
 **********************************************************************************************************************/
#ifdef TARGET_BUILD

static ICM20602 imuObj;
static NEOM8 gpsObj;

#elif defined(TEST_BUILD)

static matlabIMU imuObj;
static matlabGps gpsObj;

#endif

/***********************************************************************************************************************
 * Code
 **********************************************************************************************************************/


void SensorFusion_Execute(SensorResult *sensResult)
{

    IMUData_t imuData = imuObj.getResult();
    GpsData_t GpsData = gpsObj.getResult();

    sensResult.result = DoCrazyMath(&imuData, &GpsData);

}
  • No labels