Compilation errors when making unit test for Control Allocation Sequential Desaturation

Hi,

I am trying to make a unit test that is a straight-forward copy of the ControlAllocationPseudoInverseTest.cpp, but for ControlAllocationSequentialDesaturation.

I am getting the following compiler errors:

/home/robert/PX4-Autopilot/platforms/common/include/px4_platform_common/param.h:223: error: undefined reference to ‘param_set_used’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:494: error: undefined reference to ‘param_type’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:495: error: undefined reference to ‘param_get’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:494: error: undefined reference to ‘param_name’
libControlAllocation.a(ControlAllocationSequentialDesaturation.cpp.o):ControlAllocationSequentialDesaturation.cpp:function non-virtual thunk to ControlAllocationSequentialDesaturation::updateParamsImpl(): error: undefined reference to ‘param_type’
libControlAllocation.a(ControlAllocationSequentialDesaturation.cpp.o):ControlAllocationSequentialDesaturation.cpp:function non-virtual thunk to ControlAllocationSequentialDesaturation::updateParamsImpl(): error: undefined reference to ‘param_name’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:494: error: undefined reference to ‘param_type’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:494: error: undefined reference to ‘param_name’
libControlAllocation.a(ControlAllocationSequentialDesaturation.cpp.o):ControlAllocationSequentialDesaturation.cpp:function non-virtual thunk to ControlAllocationSequentialDesaturation::updateParamsImpl(): error: undefined reference to ‘param_get’
/home/robert/PX4-Autopilot/src/lib/parameters/param.h:495: error: undefined reference to ‘param_get’
/home/robert/PX4-Autopilot/platforms/common/px4_log.cpp:77: error: undefined reference to ‘__orb_log_message’
/home/robert/PX4-Autopilot/platforms/common/px4_log.cpp:77: error: undefined reference to ‘orb_advertise_queue’
/home/robert/PX4-Autopilot/platforms/common/px4_log.cpp:202: error: undefined reference to ‘__orb_log_message’
/home/robert/PX4-Autopilot/platforms/common/px4_log.cpp:202: error: undefined reference to ‘orb_publish’
/home/robert/PX4-Autopilot/platforms/posix/src/px4/common/px4_daemon/pxh.cpp:82: error: undefined reference to ‘init_app_map(std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, int ()(int, char**), std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, int ()(int, char**)> > >&)’
/home/robert/PX4-Autopilot/platforms/posix/src/px4/common/px4_daemon/pxh.cpp:124: error: undefined reference to ‘list_builtins(std::map<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, int ()(int, char**), std::less<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, int ()(int, char**)> > >&)’
/home/robert/PX4-Autopilot/platforms/common/work_queue/hrt_queue.c:128: error: undefined reference to ‘px4_getpid’
/home/robert/PX4-Autopilot/platforms/common/work_queue/hrt_queue.c:130: error: undefined reference to ‘px4_task_kill’
/home/robert/PX4-Autopilot/platforms/common/work_queue/hrt_thread.c:292: error: undefined reference to ‘px4_task_spawn_cmd’

I can provide more details if needed, but since the desaturation class inherits from ModuleParams, is there additional libs I need to explicitly link?

an attempt at a simpler question:

ControlAllocationSequentialDesaturation.cpp references ModuleParams, but this is not linked in the CMakeLists.txt file for src/modules/control_allocator/control_allocation.

Does this mean the CMakeLists.txt file is deficient in some way? Note I am a regular user of bazel, but new to cmake.

AHA!

The answer is to add the test using px4_add_functional_gtest instead of px4_add_unit_gtest.