Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC 4.7 Template Use Fix #748

Merged
merged 7 commits into from
Mar 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/drivers/md25/md25.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include <arch/board/board.h>
#include <mavlink/mavlink_log.h>

#include <controllib/uorb/UOrbPublication.hpp>
#include <uORB/Publication.hpp>
#include <uORB/topics/debug_key_value.h>
#include <drivers/drv_hrt.h>

Expand Down Expand Up @@ -587,7 +587,7 @@ int md25Sine(const char *deviceName, uint8_t bus, uint8_t address, float amplitu
float prev_revolution = md25.getRevolutions1();

// debug publication
control::UOrbPublication<debug_key_value_s> debug_msg(NULL,
uORB::Publication<debug_key_value_s> debug_msg(NULL,
ORB_ID(debug_key_value));

// sine wave for motor 1
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/md25/md25.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <poll.h>
#include <stdio.h>
#include <controllib/uorb/UOrbSubscription.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/topics/actuator_controls.h>
#include <drivers/device/i2c.h>

Expand Down Expand Up @@ -270,7 +270,7 @@ class MD25 : public device::I2C
struct pollfd _controlPoll;

/** actuator controls subscription */
control::UOrbSubscription<actuator_controls_s> _actuators;
uORB::Subscription<actuator_controls_s> _actuators;

// local copy of data from i2c device
uint8_t _version;
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/roboclaw/RoboClaw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <arch/board/board.h>
#include <mavlink/mavlink_log.h>

#include <controllib/uorb/UOrbPublication.hpp>
#include <uORB/Publication.hpp>
#include <uORB/topics/debug_key_value.h>
#include <drivers/drv_hrt.h>

Expand Down
4 changes: 2 additions & 2 deletions src/drivers/roboclaw/RoboClaw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

#include <poll.h>
#include <stdio.h>
#include <controllib/uorb/UOrbSubscription.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/topics/actuator_controls.h>
#include <drivers/device/i2c.h>

Expand Down Expand Up @@ -169,7 +169,7 @@ class RoboClaw
struct pollfd _controlPoll;

/** actuator controls subscription */
control::UOrbSubscription<actuator_controls_s> _actuators;
uORB::Subscription<actuator_controls_s> _actuators;

// private data
float _motor1Position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
****************************************************************************/

/**
* @file Node.h
* @file List.hpp
*
* A node of a linked list.
* A linked list.
*/

#pragma once
Expand All @@ -43,7 +43,7 @@ template<class T>
class __EXPORT ListNode
{
public:
ListNode() : _sibling(NULL) {
ListNode() : _sibling(nullptr) {
}
void setSibling(T sibling) { _sibling = sibling; }
T getSibling() { return _sibling; }
Expand Down
16 changes: 8 additions & 8 deletions src/modules/att_pos_estimator_ekf/KalmanNav.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
#include <mathlib/mathlib.h>
#include <controllib/blocks.hpp>
#include <controllib/block/BlockParam.hpp>
#include <controllib/uorb/UOrbSubscription.hpp>
#include <controllib/uorb/UOrbPublication.hpp>
#include <uORB/Subscription.hpp>
#include <uORB/Publication.hpp>

#include <uORB/topics/vehicle_attitude.h>
#include <uORB/topics/vehicle_global_position.h>
Expand Down Expand Up @@ -138,13 +138,13 @@ class KalmanNav : public control::SuperBlock
math::Matrix<3,3> C_nb; /**< direction cosine matrix from body to nav frame */
math::Quaternion q; /**< quaternion from body to nav frame */
// subscriptions
control::UOrbSubscription<sensor_combined_s> _sensors; /**< sensors sub. */
control::UOrbSubscription<vehicle_gps_position_s> _gps; /**< gps sub. */
control::UOrbSubscription<parameter_update_s> _param_update; /**< parameter update sub. */
uORB::Subscription<sensor_combined_s> _sensors; /**< sensors sub. */
uORB::Subscription<vehicle_gps_position_s> _gps; /**< gps sub. */
uORB::Subscription<parameter_update_s> _param_update; /**< parameter update sub. */
// publications
control::UOrbPublication<vehicle_global_position_s> _pos; /**< position pub. */
control::UOrbPublication<vehicle_local_position_s> _localPos; /**< local position pub. */
control::UOrbPublication<vehicle_attitude_s> _att; /**< attitude pub. */
uORB::Publication<vehicle_global_position_s> _pos; /**< position pub. */
uORB::Publication<vehicle_local_position_s> _localPos; /**< local position pub. */
uORB::Publication<vehicle_attitude_s> _att; /**< attitude pub. */
// time stamps
uint64_t _pubTimeStamp; /**< output data publication time stamp */
uint64_t _predictTimeStamp; /**< prediction time stamp */
Expand Down
9 changes: 5 additions & 4 deletions src/modules/controllib/block/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
#include <string.h>
#include <stdio.h>

#include <uORB/Subscription.hpp>
#include <uORB/Publication.hpp>

#include "Block.hpp"
#include "BlockParam.hpp"
#include "../uorb/UOrbSubscription.hpp"
#include "../uorb/UOrbPublication.hpp"

namespace control
{
Expand Down Expand Up @@ -100,7 +101,7 @@ void Block::updateParams()

void Block::updateSubscriptions()
{
UOrbSubscriptionBase *sub = getSubscriptions().getHead();
uORB::SubscriptionBase *sub = getSubscriptions().getHead();
int count = 0;

while (sub != NULL) {
Expand All @@ -118,7 +119,7 @@ void Block::updateSubscriptions()

void Block::updatePublications()
{
UOrbPublicationBase *pub = getPublications().getHead();
uORB::PublicationBase *pub = getPublications().getHead();
int count = 0;

while (pub != NULL) {
Expand Down
18 changes: 11 additions & 7 deletions src/modules/controllib/block/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
#include <stdint.h>
#include <inttypes.h>

#include "List.hpp"
#include <containers/List.hpp>

// forward declaration
namespace uORB {
class SubscriptionBase;
class PublicationBase;
}

namespace control
{
Expand All @@ -55,8 +61,6 @@ static const uint8_t blockNameLengthMax = 80;

// forward declaration
class BlockParamBase;
class UOrbSubscriptionBase;
class UOrbPublicationBase;
class SuperBlock;

/**
Expand All @@ -79,15 +83,15 @@ class __EXPORT Block :
protected:
// accessors
SuperBlock *getParent() { return _parent; }
List<UOrbSubscriptionBase *> & getSubscriptions() { return _subscriptions; }
List<UOrbPublicationBase *> & getPublications() { return _publications; }
List<uORB::SubscriptionBase *> & getSubscriptions() { return _subscriptions; }
List<uORB::PublicationBase *> & getPublications() { return _publications; }
List<BlockParamBase *> & getParams() { return _params; }
// attributes
const char *_name;
SuperBlock *_parent;
float _dt;
List<UOrbSubscriptionBase *> _subscriptions;
List<UOrbPublicationBase *> _publications;
List<uORB::SubscriptionBase *> _subscriptions;
List<uORB::PublicationBase *> _publications;
List<BlockParamBase *> _params;
};

Expand Down
25 changes: 25 additions & 0 deletions src/modules/controllib/block/BlockParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,29 @@ BlockParamBase::BlockParamBase(Block *parent, const char *name, bool parent_pref
printf("error finding param: %s\n", fullname);
};

template <class T>
BlockParam<T>::BlockParam(Block *block, const char *name,
bool parent_prefix) :
BlockParamBase(block, name, parent_prefix),
_val() {
update();
}

template <class T>
T BlockParam<T>::get() { return _val; }

template <class T>
void BlockParam<T>::set(T val) { _val = val; }

template <class T>
void BlockParam<T>::update() {
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
}

template <class T>
BlockParam<T>::~BlockParam() {};

template class __EXPORT BlockParam<float>;
template class __EXPORT BlockParam<int>;

} // namespace control
41 changes: 12 additions & 29 deletions src/modules/controllib/block/BlockParam.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <systemlib/param/param.h>

#include "Block.hpp"
#include "List.hpp"
#include <containers/List.hpp>

namespace control
{
Expand Down Expand Up @@ -70,38 +70,21 @@ class __EXPORT BlockParamBase : public ListNode<BlockParamBase *>
* Parameters that are tied to blocks for updating and nameing.
*/

class __EXPORT BlockParamFloat : public BlockParamBase
template <class T>
class BlockParam : public BlockParamBase
{
public:
BlockParamFloat(Block *block, const char *name, bool parent_prefix=true) :
BlockParamBase(block, name, parent_prefix),
_val() {
update();
}
float get() { return _val; }
void set(float val) { _val = val; }
void update() {
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
}
BlockParam(Block *block, const char *name,
bool parent_prefix=true);
T get();
void set(T val);
void update();
virtual ~BlockParam();
protected:
float _val;
T _val;
};

class __EXPORT BlockParamInt : public BlockParamBase
{
public:
BlockParamInt(Block *block, const char *name, bool parent_prefix=true) :
BlockParamBase(block, name, parent_prefix),
_val() {
update();
}
int get() { return _val; }
void set(int val) { _val = val; }
void update() {
if (_handle != PARAM_INVALID) param_get(_handle, &_val);
}
protected:
int _val;
};
typedef BlockParam<float> BlockParamFloat;
typedef BlockParam<int> BlockParamInt;

} // namespace control
2 changes: 0 additions & 2 deletions src/modules/controllib/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@
SRCS = test_params.c \
block/Block.cpp \
block/BlockParam.cpp \
uorb/UOrbPublication.cpp \
uorb/UOrbSubscription.cpp \
uorb/blocks.cpp \
blocks.cpp
22 changes: 11 additions & 11 deletions src/modules/controllib/uorb/blocks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ extern "C" {
}

#include "../blocks.hpp"
#include "UOrbSubscription.hpp"
#include "UOrbPublication.hpp"
#include <uORB/Subscription.hpp>
#include <uORB/Publication.hpp>

namespace control
{
Expand Down Expand Up @@ -94,16 +94,16 @@ class __EXPORT BlockUorbEnabledAutopilot : public SuperBlock
{
protected:
// subscriptions
UOrbSubscription<vehicle_attitude_s> _att;
UOrbSubscription<vehicle_attitude_setpoint_s> _attCmd;
UOrbSubscription<vehicle_rates_setpoint_s> _ratesCmd;
UOrbSubscription<vehicle_global_position_s> _pos;
UOrbSubscription<position_setpoint_triplet_s> _missionCmd;
UOrbSubscription<manual_control_setpoint_s> _manual;
UOrbSubscription<vehicle_status_s> _status;
UOrbSubscription<parameter_update_s> _param_update;
uORB::Subscription<vehicle_attitude_s> _att;
uORB::Subscription<vehicle_attitude_setpoint_s> _attCmd;
uORB::Subscription<vehicle_rates_setpoint_s> _ratesCmd;
uORB::Subscription<vehicle_global_position_s> _pos;
uORB::Subscription<position_setpoint_triplet_s> _missionCmd;
uORB::Subscription<manual_control_setpoint_s> _manual;
uORB::Subscription<vehicle_status_s> _status;
uORB::Subscription<parameter_update_s> _param_update;
// publications
UOrbPublication<actuator_controls_s> _actuators;
uORB::Publication<actuator_controls_s> _actuators;
public:
BlockUorbEnabledAutopilot(SuperBlock *parent, const char *name);
virtual ~BlockUorbEnabledAutopilot();
Expand Down
6 changes: 3 additions & 3 deletions src/modules/fixedwing_backside/fixedwing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ void BlockMultiModeBacksideAutopilot::update()
// the min/max velocity
float v = _vLimit.update(sqrtf(
_pos.vel_n * _pos.vel_n +
_pos.vy * _pos.vy +
_pos.vel_e * _pos.vel_e +
_pos.vel_d * _pos.vel_d));

// limit velocity command between min/max velocity
float vCmd = _vLimit.update(_vCmd.get());

// altitude hold
float dThrottle = _h2Thr.update(_missionCmd.current.altitude - _pos.alt);
float dThrottle = _h2Thr.update(_missionCmd.current.alt - _pos.alt);

// heading hold
float psiError = _wrap_pi(_guide.getPsiCmd() - _att.yaw);
Expand Down Expand Up @@ -237,7 +237,7 @@ void BlockMultiModeBacksideAutopilot::update()
// the min/max velocity
float v = _vLimit.update(sqrtf(
_pos.vel_n * _pos.vel_n +
_pos.vy * _pos.vy +
_pos.vel_e * _pos.vel_e +
_pos.vel_d * _pos.vel_d));

// pitch channel -> rate of climb
Expand Down
Loading