add macros for easy 2d array support, builds on px4 test build

This commit is contained in:
Thomas Gubler
2014-12-02 10:46:29 +01:00
parent dfb266565a
commit 4d91c61f8f
3 changed files with 9 additions and 3 deletions
@@ -67,6 +67,7 @@
#include <systemlib/perf_counter.h>
#include <systemlib/systemlib.h>
#include <poll.h>
#include <px4_defines.h>
#include "flow_position_estimator_params.h"
@@ -337,7 +338,7 @@ int flow_position_estimator_thread_main(int argc, char *argv[])
{
float sum = 0.0f;
for(uint8_t j = 0; j < 3; j++)
sum = sum + speed[j] * att.R[i][j];
sum = sum + speed[j] * PX4_R(att.R, i, j);
global_speed[i] = sum;
}
+1 -1
View File
@@ -59,7 +59,7 @@
#endif
#include "../platforms/px4_defines.h"
#include <px4_defines.h>
#include "../platforms/px4_middleware.h"
#include "../platforms/px4_nodehandle.h"
#include "../platforms/px4_subscriber.h"
@@ -51,7 +51,6 @@
#define PX4_TOPIC_T(_name) _name
#define PX4_SUBSCRIBE_CBMETH(_nodehandle, _name, _cbf, _obj, _interval) _nodehandle.subscribe(PX4_TOPIC(_name), &_cbf, &_obj);
#define PX4_SUBSCRIBE_CBFUNC(_nodehandle, _name, _cbf, _interval) _nodehandle.subscribe(PX4_TOPIC(_name), _cbf);
#else
/*
* Building for NuttX
@@ -70,3 +69,9 @@
#define PX4_GET_SUBSCRIBE(_1, _2, _3, _4, _5, NAME, ...) NAME
#define PX4_SUBSCRIBE(...) PX4_GET_SUBSCRIBE(__VA_ARGS__, PX4_SUBSCRIBE_CBMETH, PX4_SUBSCRIBE_CBFUNC)(__VA_ARGS__)
#define PX4_ADVERTISE(_nodehandle, _name) _nodehandle.advertise<PX4_TOPIC_T(_name)>(PX4_TOPIC(_name))
/* wrapper for 2d matrices */
#define PX4_ARRAY2D(_array, _ncols, _x, _y) (_array[_x * _ncols + _y])
/* wrapper for rotation matrices stored in arrays */
#define PX4_R(_array, _x, _y) PX4_ARRAY2D(_array, 3, _x, _y)