I am working with the vtol flight stack and I would like to have some unit tests and sitl tests for my CI. I followed the instructions in the docs to set up the files but I am getting stuck with initializing a simple tiltrotor so I could test the functions, e.g. update_transiton_state(). I started with a real simple Test:
The thing is, that the terminal spits out a lot of undefined refrences like ‘PX4_TICKS_PER_SEC’. Is it even possible to write a unit test for vtol_att_control? Or do I have to use sitl tests because it highly depends on other modules?
Sorry in case its a real dumb question I am trying to dive into the depths of PX4 and try to learn as much as I can.
@JulianOes Thanks for pointing out these tests. I already looked at the Test for the Commander and for the MC PositionControl before. I think the Tiltrotor class is somehow similar to the ObstacleAvoidance class, but I can still not manage to initiate my class I can not see why
Here is the simple vtol_att_control_test.cpp:
Also tried to replace nullptr with a pointer to an instance of VtolAttitudeControl, but it didn’t work either. Do I need to include some dependencies in order for the tiltrotor instance to work?
I was still using px4_add_unit_gtest() instead of the functional version… Thanks for your help to find my stupid errors
But there is still one issue left: If the module, which I would like to write a test for, is out-of-tree, the function px4_add_functional_gtest() is not found. Do you also know how to configure those tests if they are out of tree? Maybe I have to adjust the px4_add_functional_gtest() function?
I tried it but sadly it doesn’t work. The function px4_add_functional_gtest() is found, but the test is not added to the test cases when running make tests.
I also checked how the EXTERNAL parameter works in the px4_add_module() function, but I didn’t get much smarter out of it either.