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

[WIP] added control modes concept #13097

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 6 additions & 0 deletions boards/px4/fmu-v5/critmonitor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ px4_add_board(
TESTING
UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v5/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ px4_add_board(
TESTING
UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
3 changes: 3 additions & 0 deletions boards/px4/fmu-v5/fixedwing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ px4_add_board(
IO px4_io-v2_default
UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v5/irqmonitor.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ px4_add_board(
TESTING
UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
3 changes: 3 additions & 0 deletions boards/px4/fmu-v5/multicopter.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ px4_add_board(
TESTING
UAVCAN_INTERFACES 2

CONTROL_MODES
multicopter

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
3 changes: 3 additions & 0 deletions boards/px4/fmu-v5/rover.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ px4_add_board(
IO px4_io-v2_default
UAVCAN_INTERFACES 2

CONTROL_MODES
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v5/rtps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ px4_add_board(
TESTING
UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/fmu-v5/stackcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ px4_add_board(
TESTING
#UAVCAN_INTERFACES 2

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

SERIAL_PORTS
GPS1:/dev/ttyS0
TEL1:/dev/ttyS1
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/sitl/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ px4_add_board(
LABEL default
TESTING

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

DRIVERS
#barometer # all available barometer drivers
#batt_smbus
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/sitl/rtps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ px4_add_board(
LABEL rtps
TESTING

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

DRIVERS
#barometer # all available barometer drivers
#batt_smbus
Expand Down
6 changes: 6 additions & 0 deletions boards/px4/sitl/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ px4_add_board(
LABEL test
TESTING

CONTROL_MODES
fixed_wing
vtol
multicopter
rover

DRIVERS
#barometer # all available barometer drivers
#batt_smbus
Expand Down
5 changes: 5 additions & 0 deletions cmake/px4_add_board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ function(px4_add_board)
SYSTEMCMDS
EXAMPLES
SERIAL_PORTS
CONTROL_MODES
DF_DRIVERS
OPTIONS
CONSTRAINED_FLASH
Expand Down Expand Up @@ -200,6 +201,10 @@ function(px4_add_board)
set(board_serial_ports ${SERIAL_PORTS} PARENT_SCOPE)
endif()

if(CONTROL_MODES)
set(control_modes ${CONTROL_MODES} PARENT_SCOPE)
endif()

# ROMFS
if(ROMFSROOT)
set(config_romfs_root ${ROMFSROOT} CACHE INTERNAL "ROMFS root" FORCE)
Expand Down
29 changes: 29 additions & 0 deletions cmake/px4_add_common_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,33 @@ function(px4_add_common_flags)
-D__STDC_FORMAT_MACROS
)

list(FIND control_modes "fixed_wing" control_mode_index)
if(${control_mode_index} GREATER -1)
add_definitions(
-DCONTROL_MODES_FW
)
endif()

list(FIND control_modes "multicopter" control_mode_index)
if(${control_mode_index} GREATER -1)
add_definitions(
-DCONTROL_MODES_MC
)
endif()

list(FIND control_modes "vtol" control_mode_index)
if(${control_mode_index} GREATER -1)
add_definitions(
-DCONTROL_MODES_VTOL
)
endif()

list(FIND control_modes "rover" control_mode_index)
if(${control_mode_index} GREATER -1)
add_definitions(
-DCONTROL_MODES_ROVER
)
endif()


endfunction()
28 changes: 24 additions & 4 deletions src/modules/land_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,37 @@
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################

set(CONTROL_MODES_SRCS)
list(FIND control_modes "fixed_wing" control_mode_index)
if(${control_mode_index} GREATER -1)
list(APPEND CONTROL_MODES_SRCS FixedwingLandDetector.cpp)
endif()

list(FIND control_modes "multicopter" control_mode_index)
if(${control_mode_index} GREATER -1)
list(APPEND CONTROL_MODES_SRCS MulticopterLandDetector.cpp)
endif()

list(FIND control_modes "vtol" control_mode_index)
if(${control_mode_index} GREATER -1)
list(APPEND CONTROL_MODES_SRCS VtolLandDetector.cpp)
endif()

list(FIND control_modes "rover" control_mode_index)
if(${control_mode_index} GREATER -1)
list(APPEND CONTROL_MODES_SRCS RoverLandDetector.cpp)
endif()

px4_add_module(
MODULE modules__land_detector
MAIN land_detector
COMPILE_FLAGS
SRCS
land_detector_main.cpp
LandDetector.cpp
MulticopterLandDetector.cpp
FixedwingLandDetector.cpp
VtolLandDetector.cpp
RoverLandDetector.cpp
${CONTROL_MODES_SRCS}

DEPENDS
hysteresis
)
Expand Down
39 changes: 26 additions & 13 deletions src/modules/land_detector/land_detector_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,35 @@ int LandDetector::task_spawn(int argc, char *argv[])

LandDetector *obj = nullptr;

#ifdef CONTROL_MODE_FW

if (strcmp(argv[1], "fixedwing") == 0) {
obj = new FixedwingLandDetector();

} else if (strcmp(argv[1], "multicopter") == 0) {
obj = new MulticopterLandDetector();

} else if (strcmp(argv[1], "vtol") == 0) {
obj = new VtolLandDetector();

} else if (strcmp(argv[1], "rover") == 0) {
obj = new RoverLandDetector();

} else {
print_usage("unknown mode");
return PX4_ERROR;
}
} else
#endif
#ifdef CONTROL_MODE_MC
if (strcmp(argv[1], "multicopter") == 0) {
obj = new MulticopterLandDetector();

} else
#endif
#ifdef CONTROL_MODE_VT
if (strcmp(argv[1], "vtol") == 0) {
obj = new VtolLandDetector();

} else
#endif
#ifdef CONTROL_MODE_ROVER
if (strcmp(argv[1], "rover") == 0) {
obj = new RoverLandDetector();

} else
#endif
{
print_usage("unknown mode");
return PX4_ERROR;
}
Comment on lines +78 to +98
Copy link
Member Author

@BazookaJoe1900 BazookaJoe1900 Oct 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the extra tabs are due to the formating hook. I couldn't do commit without that.


if (obj == nullptr) {
PX4_ERR("alloc failed");
Expand Down
5 changes: 5 additions & 0 deletions src/modules/mc_att_control/mc_att_control_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,17 @@ MulticopterAttitudeControl::vehicle_status_poll()
_actuators_id = ORB_ID(actuator_controls_virtual_mc);
_attitude_sp_id = ORB_ID(mc_virtual_attitude_setpoint);

#ifdef CONTROL_MODE_VTOL
int32_t vt_type = -1;

if (param_get(param_find("VT_TYPE"), &vt_type) == PX4_OK) {
_is_tailsitter = (static_cast<vtol_type>(vt_type) == vtol_type::TAILSITTER);
}

#else
_is_tailsitter = false;
#endif

} else {
_actuators_id = ORB_ID(actuator_controls_0);
_attitude_sp_id = ORB_ID(vehicle_attitude_setpoint);
Expand Down