forked from Archive/PX4-Autopilot
mixer move test_mixer_multirotor into cmake
This commit is contained in:
parent
d21314c74c
commit
b9516d7e38
7
Makefile
7
Makefile
|
@ -338,12 +338,9 @@ format:
|
|||
# Testing
|
||||
# --------------------------------------------------------------------
|
||||
.PHONY: tests tests_coverage tests_mission tests_mission_coverage tests_offboard tests_avoidance
|
||||
.PHONY: rostest python_coverage test_mixer_multirotor
|
||||
.PHONY: rostest python_coverage
|
||||
|
||||
test_mixer_multirotor:
|
||||
@$(MAKE) -C "$(SRC_DIR)"/src/lib/mixer --no-print-directory tests
|
||||
|
||||
tests: test_mixer_multirotor
|
||||
tests:
|
||||
@$(MAKE) --no-print-directory px4_sitl_test test_results \
|
||||
ASAN_OPTIONS="color=always:check_initialization_order=1:detect_stack_use_after_return=1" \
|
||||
UBSAN_OPTIONS="color=always"
|
||||
|
|
|
@ -150,6 +150,7 @@ add_custom_target(test_results
|
|||
DEPENDS
|
||||
px4
|
||||
examples__dyn_hello
|
||||
test_mixer_multirotor
|
||||
USES_TERMINAL
|
||||
COMMENT "Running tests in sitl"
|
||||
WORKING_DIRECTORY ${PX4_BINARY_DIR})
|
||||
|
|
|
@ -94,3 +94,21 @@ add_library(mixer
|
|||
target_include_directories(mixer PRIVATE ${PX4_BINARY_DIR}/src/lib/mixer)
|
||||
|
||||
add_dependencies(mixer mixer_gen mixer_gen_6dof prebuild_targets)
|
||||
|
||||
|
||||
if(BUILD_TESTING)
|
||||
|
||||
add_executable(test_mixer_multirotor
|
||||
test_mixer_multirotor.cpp
|
||||
mixer_multirotor.cpp
|
||||
mixer.cpp
|
||||
)
|
||||
target_compile_definitions(test_mixer_multirotor PRIVATE MIXER_MULTIROTOR_USE_MOCK_GEOMETRY)
|
||||
target_compile_options(test_mixer_multirotor PRIVATE -Wno-unused-result)
|
||||
|
||||
add_test(NAME mixer_multirotor
|
||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/mixer_multirotor.py --test --mixer-multirotor-binary $<TARGET_FILE:test_mixer_multirotor>
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
endif()
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
.PHONY: all tests clean
|
||||
all: test_mixer_multirotor
|
||||
|
||||
test_mixer_multirotor: test_mixer_multirotor.cpp mixer_multirotor.cpp mixer.cpp
|
||||
@g++ $^ -std=c++11 -I .. -DMIXER_MULTIROTOR_USE_MOCK_GEOMETRY -o $@
|
||||
|
||||
tests: test_mixer_multirotor
|
||||
@echo "Testing Mixer Multirotor"
|
||||
@python mixer_multirotor.py --test --mixer-multirotor-binary ./$^
|
||||
|
||||
clean:
|
||||
@rm test_mixer_multirotor
|
|
@ -58,7 +58,6 @@ mixer_callback(uintptr_t handle, uint8_t control_group, uint8_t control_index, f
|
|||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *file_in = stdin;
|
||||
FILE *file_out = stdout;
|
||||
|
||||
if (argc > 1) {
|
||||
file_in = fopen(argv[1], "r");
|
||||
|
@ -79,7 +78,7 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < rotor_count; ++i) {
|
||||
for (unsigned i = 0; i < rotor_count; ++i) {
|
||||
fscanf(file_in, "%f %f %f %f", &rotors[i].roll_scale, &rotors[i].pitch_scale,
|
||||
&rotors[i].yaw_scale, &rotors[i].thrust_scale);
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ int main(int argc, char *argv[])
|
|||
while (!feof(file_in)) {
|
||||
|
||||
// read actuator controls
|
||||
int count = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
while (count < 4 && fscanf(file_in, "%f", &actuator_controls[count]) == 1) {
|
||||
++count;
|
||||
|
@ -127,26 +126,26 @@ int main(int argc, char *argv[])
|
|||
|
||||
if (failed) {
|
||||
printf("test %i failed:\n", test_counter + 1);
|
||||
printf("control input : %.3f %.3f %.3f %.3f\n", actuator_controls[0], actuator_controls[1],
|
||||
actuator_controls[2], actuator_controls[3]);
|
||||
printf("control input : %.3f %.3f %.3f %.3f\n", (double)actuator_controls[0], (double)actuator_controls[1],
|
||||
(double)actuator_controls[2], (double)actuator_controls[3]);
|
||||
printf("mixer output : ");
|
||||
|
||||
for (int i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", actuator_outputs[i]);
|
||||
for (unsigned i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", (double)actuator_outputs[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("expected output: ");
|
||||
|
||||
for (int i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", expected_output[i]);
|
||||
for (unsigned i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", (double)expected_output[i]);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
printf("diff : ");
|
||||
|
||||
for (int i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", expected_output[i] - actuator_outputs[i]);
|
||||
for (unsigned i = 0; i < rotor_count; ++i) {
|
||||
printf("%.3f ", (double)(expected_output[i] - actuator_outputs[i]));
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
|
Loading…
Reference in New Issue