Skip to content

Commit

Permalink
Autogyro takeoff, squash and clean
Browse files Browse the repository at this point in the history
Squash and the removal of unrelated commits.
  • Loading branch information
roman-dvorak committed Jul 22, 2023
1 parent 1d96de5 commit 9bea4a5
Show file tree
Hide file tree
Showing 14 changed files with 992 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ param set-default NAV_ACC_RAD 20
param set-default NAV_DLL_ACT 2
param set-default NAV_LOITER_RAD 100

param set-default RWTO_TKOFF 1
param set-default RWTO_TKOFF 0
param set-default AG_TKOFF 1
param set-default AG_PROT_TYPE 1
# param set-default AG_PROT_MIN_RPM 10.0
# param set-default AG_PROT_TRG_RPM 300.0
# param set-defoult AG_ROTOR_RPM 300.0

param set-default FW_ARSP_SCALE_EN 0

Expand Down
120 changes: 80 additions & 40 deletions msg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
############################################################################
#
# Copyright (c) 2016-2022 PX4 Development Team. All rights reserved.
# Copyright (c) 2016 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand Down Expand Up @@ -50,6 +50,7 @@ set(msg_files
AirspeedValidated.msg
AirspeedWind.msg
AutotuneAttitudeControlStatus.msg
AutogyroTakeoffStatus.msg
BatteryStatus.msg
ButtonEvent.msg
CameraCapture.msg
Expand Down Expand Up @@ -226,8 +227,49 @@ set(msg_files
Wind.msg
YawEstimatorStatus.msg
)

if(NOT px4_constrained_flash_build)
list(APPEND msg_files
debug_array.msg
debug_key_value.msg
debug_value.msg
debug_vect.msg
)
endif()

if(PX4_TESTING)
list(APPEND msg_files
orb_test.msg
orb_test_large.msg
orb_test_medium.msg
)
endif()

list(SORT msg_files)

set(deprecated_msgs
ekf2_innovations.msg # 2019-11-22, Updated estimator interface and logging; replaced by 'estimator_innovations'.
)

foreach(msg IN LISTS deprecated_msgs)
if(msg IN_LIST msg_files)
get_filename_component(msg_we ${msg} NAME_WE)
list(APPEND invalid_msgs ${msg_we})
endif()
endforeach()
if(invalid_msgs)
list(LENGTH invalid_msgs invalid_msgs_size)
if(${invalid_msgs_size} GREATER 1)
foreach(msg IN LISTS invalid_msgs)
string(CONCAT invalid_msgs_cs ${invalid_msgs_cs} "'${msg}', ")
endforeach()
STRING(REGEX REPLACE ", +$" "" invalid_msgs_cs ${invalid_msgs_cs})
message(FATAL_ERROR "${invalid_msgs_cs} are listed as deprecated. Please use different names for the messages.")
else()
message(FATAL_ERROR "'${invalid_msgs}' is listed as deprecated. Please use a different name for the message.")
endif()
endif()

px4_list_make_absolute(msg_files ${CMAKE_CURRENT_SOURCE_DIR} ${msg_files})

if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
Expand All @@ -245,92 +287,90 @@ endif()
# headers
set(msg_out_path ${PX4_BINARY_DIR}/uORB/topics)
set(ucdr_out_path ${PX4_BINARY_DIR}/uORB/ucdr)
set(msg_source_out_path ${CMAKE_CURRENT_BINARY_DIR}/topics_sources)
set(msg_source_out_path ${CMAKE_CURRENT_BINARY_DIR}/topics_sources)

set(uorb_headers)
set(uorb_sources)
set(uorb_headers ${msg_out_path}/uORBTopics.hpp)
set(uorb_sources ${msg_source_out_path}/uORBTopics.cpp)
set(uorb_ucdr_headers)
foreach(msg_file ${msg_files})
get_filename_component(msg ${msg_file} NAME_WE)

# Pascal case to snake case (MsgFile -> msg_file)
string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" msg "${msg}")
string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" msg "${msg}")
string(TOLOWER "${msg}" msg)

list(APPEND uorb_headers ${msg_out_path}/${msg}.h)
list(APPEND uorb_sources ${msg_source_out_path}/${msg}.cpp)
list(APPEND uorb_ucdr_headers ${ucdr_out_path}/${msg}.h)
endforeach()

if (px4_constrained_flash_build)
set(added_arguments --constrained-flash)
endif()

# set parent scope msg_files for other modules to consume (eg topic_listener)
set(msg_files ${msg_files} PARENT_SCOPE)

# Generate uORB headers
add_custom_command(
OUTPUT
${uorb_headers}
${msg_out_path}/uORBTopics.hpp
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
add_custom_command(OUTPUT ${uorb_headers}
COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py
--headers
-f ${msg_files}
-i ${CMAKE_CURRENT_SOURCE_DIR}
-o ${msg_out_path}
-e ${PX4_SOURCE_DIR}/Tools/msg/templates/uorb
-e templates/uorb
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers
-q
${added_arguments}
DEPENDS
${msg_files}
${PX4_SOURCE_DIR}/Tools/msg/templates/uorb/msg.h.em
${PX4_SOURCE_DIR}/Tools/msg/templates/uorb/uORBTopics.hpp.em
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_helper.py
templates/uorb/msg.h.em
templates/uorb/uORBTopics.hpp.em
tools/px_generate_uorb_topic_files.py
tools/px_generate_uorb_topic_helper.py
COMMENT "Generating uORB topic headers"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_custom_target(uorb_headers DEPENDS ${uorb_headers})

# Generate microcdr headers
add_custom_command(
OUTPUT ${uorb_ucdr_headers}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
add_custom_command(OUTPUT ${uorb_ucdr_headers}
COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py
--headers
-f ${msg_files}
-i ${CMAKE_CURRENT_SOURCE_DIR}
-o ${ucdr_out_path}
-e ${PX4_SOURCE_DIR}/Tools/msg/templates/ucdr
-e templates/ucdr
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/ucdr_headers
-q
${added_arguments}
DEPENDS
${msg_files}
${PX4_SOURCE_DIR}/Tools/msg/templates/ucdr/msg.h.em
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_helper.py
templates/ucdr/msg.h.em
tools/px_generate_uorb_topic_files.py
tools/px_generate_uorb_topic_helper.py
COMMENT "Generating uORB topic ucdr headers"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_custom_target(uorb_ucdr_headers DEPENDS ${uorb_ucdr_headers})

# Generate uORB sources
add_custom_command(
OUTPUT
${uorb_sources}
${msg_source_out_path}/uORBTopics.cpp
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
add_custom_command(OUTPUT ${uorb_sources}
COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py
--sources
-f ${msg_files}
-i ${CMAKE_CURRENT_SOURCE_DIR}
-o ${msg_source_out_path}
-e ${PX4_SOURCE_DIR}/Tools/msg/templates/uorb
-e templates/uorb
-t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources
-q
${added_arguments}
DEPENDS
${msg_files}
${PX4_SOURCE_DIR}/Tools/msg/templates/uorb/msg.cpp.em
${PX4_SOURCE_DIR}/Tools/msg/templates/uorb/uORBTopics.cpp.em
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_helper.py
templates/uorb/msg.cpp.em
templates/uorb/uORBTopics.cpp.em
tools/px_generate_uorb_topic_files.py
tools/px_generate_uorb_topic_helper.py
COMMENT "Generating uORB topic sources"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)

add_library(uorb_msgs ${uorb_headers} ${msg_out_path}/uORBTopics.hpp ${uorb_sources} ${msg_source_out_path}/uORBTopics.cpp)
target_link_libraries(uorb_msgs PRIVATE m)
add_library(uorb_msgs ${uorb_sources})
add_dependencies(uorb_msgs prebuild_targets uorb_headers)
5 changes: 4 additions & 1 deletion msg/TuneControl.msg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ uint8 TUNE_ID_PROG_PX4IO = 16
uint8 TUNE_ID_PROG_PX4IO_OK = 17
uint8 TUNE_ID_PROG_PX4IO_ERR = 18
uint8 TUNE_ID_POWER_OFF = 19
uint8 NUMBER_OF_TUNES = 20
uint8 TUNE_ID_TAKEOFF_NEXT_STEP = 20
uint8 TUNE_ID_TAKEOFF_RELEASE = 21
uint8 TUNE_ID_TAKEOFF_ERROR = 22
uint8 NUMBER_OF_TUNES = 23

uint8 tune_id # tune_id corresponding to TuneID::* from the tune_defaults.h in the tunes library
bool tune_override # if true the tune which is playing will be stopped and the new started
Expand Down
7 changes: 7 additions & 0 deletions msg/autogyro_takeoff_status.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
uint64 timestamp # time since system start (microseconds)
uint32 time_in_state
uint32 state # Autogyro start status
bool rpm
bool airspeed
bool landed
bool climbout
12 changes: 12 additions & 0 deletions src/drivers/tone_alarm/ToneAlarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ void ToneAlarm::Run()
case tune_control_s::TUNE_ID_HOME_SET:
PX4_INFO("home set");
break;

case tune_control_s::TUNE_ID_TAKEOFF_NEXT_STEP:
PX4_INFO("TAKEOFF: Next step");
break;

case tune_control_s::TUNE_ID_TAKEOFF_ERROR:
PX4_INFO("TAKEOFF: error");
break;

case tune_control_s::TUNE_ID_TAKEOFF_RELEASE:
PX4_INFO("TAKEOFF: Release me");
break;
}

#endif // (!TONE_ALARM_TIMER && !GPIO_TONE_ALARM_GPIO) || DEBUG_BUILD
Expand Down
6 changes: 5 additions & 1 deletion src/lib/tunes/tune_definition.desc
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@ PX4_DEFINE_TUNE(15, SD_ERROR, "MNBG",
PX4_DEFINE_TUNE(16, PROG_PX4IO, "MLL32CP8MB", false /* Program PX4IO */)
PX4_DEFINE_TUNE(17, PROG_PX4IO_OK, "MLL8CDE", false /* Program PX4IO success */)
PX4_DEFINE_TUNE(18, PROG_PX4IO_ERR, "ML<<CP4CP4CP4CP4CP4", true /* Program PX4IO fail */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", false /* When pressing off button */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", true /* When pressing off button */)
PX4_DEFINE_TUNE(20, TAKEOFF_NEXT_STEP, "MFc10e10g10", true /* Next step of takeoff */)
PX4_DEFINE_TUNE(21, TAKEOFF_RELEASE, "MB<c10d10e10", true /* Takeoff release from moving platform */)
PX4_DEFINE_TUNE(22, TAKEOFF_ERROR, "MFe10e10c5", true /* Error in takeoff process */)

2 changes: 2 additions & 0 deletions src/modules/fw_pos_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

add_subdirectory(launchdetection)
add_subdirectory(runway_takeoff)
add_subdirectory(autogyro_takeoff)

px4_add_module(
MODULE modules__fw_pos_control
Expand All @@ -44,6 +45,7 @@ px4_add_module(
launchdetection
npfg
runway_takeoff
autogyro_takeoff
SlewRate
tecs
motion_planning
Expand Down
29 changes: 28 additions & 1 deletion src/modules/fw_pos_control/FixedwingPositionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ FixedwingPositionControl::FixedwingPositionControl(bool vtol) :
_attitude_sp_pub(vtol ? ORB_ID(fw_virtual_attitude_setpoint) : ORB_ID(vehicle_attitude_setpoint)),
_loop_perf(perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")),
_launchDetector(this),
_runway_takeoff(this)
_runway_takeoff(this),
_autogyro_takeoff(this)
{
if (vtol) {
_param_handle_airspeed_trans = param_find("VT_ARSP_TRANS");
Expand Down Expand Up @@ -338,6 +339,14 @@ FixedwingPositionControl::manual_control_setpoint_poll()
}
}

void
FixedwingPositionControl::rpm_poll()
{
if (_rpm_sub.update(&_rpm)) {
_rpm_sub.copy(&_rpm);
_rpm_frequency = _rpm.indicated_frequency_rpm;
}
}

void
FixedwingPositionControl::vehicle_attitude_poll()
Expand Down Expand Up @@ -689,13 +698,29 @@ FixedwingPositionControl::getManualHeightRateSetpoint()
void
FixedwingPositionControl::updateManualTakeoffStatus()
{

//TF CHECK
// a VTOL does not need special takeoff handling
if (_vehicle_status.is_vtol) {
return false;
}

if (_autogyro_takeoff.autogyroTakeoffEnabled()) {
return (!_autogyro_takeoff.isInitialized() || _autogyro_takeoff.climbout());
}
//TF CHECK
if (!_completed_manual_takeoff) {
const bool at_controllable_airspeed = _airspeed > _param_fw_airspd_min.get()
|| !_airspeed_valid;
const bool is_hovering = _vehicle_status.vehicle_type == vehicle_status_s::VEHICLE_TYPE_ROTARY_WING
&& _control_mode.flag_armed;
_completed_manual_takeoff = (!_landed && at_controllable_airspeed) || is_hovering;
}

// in air for < 10s
return (hrt_elapsed_time(&_time_went_in_air) < 10_s)
&& (_current_altitude <= _takeoff_ground_alt + _param_fw_clmbout_diff.get());

}

void
Expand Down Expand Up @@ -2435,6 +2460,8 @@ FixedwingPositionControl::reset_takeoff_state()
{
_runway_takeoff.reset();

_autogyro_takeoff.reset();

_launchDetector.reset();

_launch_detected = false;
Expand Down
Loading

0 comments on commit 9bea4a5

Please sign in to comment.