Working off of PX4 v1.10.2, I attempted to subscribe to a uORB topic from mixer_multirotor.cpp by including the uORB::Subscription class in mixer.h, but I got an “undefined reference to function” when trying to create a Subscription object.
My Changes
I added these headers to mixer.h:
#include <uORB/Subscription.hpp>
#include <uORB/topics/topic_name.h>
…and added this private field to the MultirotorMixer class description in mixer.h:
uORB::Subscription _topic_name_sub{ORB_ID(topic_name)};
This is the same way CollisionPrevention.hpp retrieves various uORB topic data.
Expected behaviour
I expected the code to compile with these additions so I could then use Subscription::updated() and Subscription::copy() to retrieve the data. This works in CollisionPrevention.cpp.
Compile Error
/…/src/modules/uORB/Subscription.hpp:66: undefined reference to `uORB::Subscription::subscribe()’
/…/src/modules/uORB/Subscription.hpp:71: undefined reference to `uORB::Subscription::unsubscribe()’
Any help would be great. Also, if you know a more elegant way to add this uORB data, feel free to let me know in detail.
Thanks!