Skip to content

Commit 8548f18

Browse files
authored
Merge branch 'master' into pr-taker-h743
2 parents decd489 + 3a1faf6 commit 8548f18

File tree

253 files changed

+6668
-1433
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+6668
-1433
lines changed

.github/workflows/test_environment.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
name: focal
3333
- os: ubuntu
3434
name: jammy
35-
- os: ubuntu
36-
name: mantic
3735
- os: ubuntu
3836
name: noble
3937
- os: archlinux

.github/workflows/test_sitl_blimp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ jobs:
229229
NOW=$(date -u +"%F-%T")
230230
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
231231
- name: ccache cache files
232-
uses: actions/cache/restore@v3
232+
uses: actions/cache/restore@v4
233233
with:
234234
path: ~/.ccache
235235
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_sitl_copter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ jobs:
247247
NOW=$(date -u +"%F-%T")
248248
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
249249
- name: ccache cache files
250-
uses: actions/cache/restore@v3
250+
uses: actions/cache/restore@v4
251251
with:
252252
path: ~/.ccache
253253
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}
@@ -343,7 +343,7 @@ jobs:
343343
NOW=$(date -u +"%F-%T")
344344
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
345345
- name: ccache cache files
346-
uses: actions/cache/restore@v3
346+
uses: actions/cache/restore@v4
347347
with:
348348
path: ~/.ccache
349349
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_sitl_plane.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
NOW=$(date -u +"%F-%T")
231231
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
232232
- name: ccache cache files
233-
uses: actions/cache/restore@v3
233+
uses: actions/cache/restore@v4
234234
with:
235235
path: ~/.ccache
236236
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_sitl_rover.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ jobs:
244244
NOW=$(date -u +"%F-%T")
245245
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
246246
- name: ccache cache files
247-
uses: actions/cache/restore@v3
247+
uses: actions/cache/restore@v4
248248
with:
249249
path: ~/.ccache
250250
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_sitl_sub.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ jobs:
244244
NOW=$(date -u +"%F-%T")
245245
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
246246
- name: ccache cache files
247-
uses: actions/cache/restore@v3
247+
uses: actions/cache/restore@v4
248248
with:
249249
path: ~/.ccache
250250
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_sitl_tracker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ jobs:
230230
NOW=$(date -u +"%F-%T")
231231
echo "timestamp=${NOW}" >> $GITHUB_OUTPUT
232232
- name: ccache cache files
233-
uses: actions/cache/restore@v3
233+
uses: actions/cache/restore@v4
234234
with:
235235
path: ~/.ccache
236236
key: ${{github.workflow}}-ccache-base-${{steps.ccache_cache_timestamp.outputs.timestamp}}

.github/workflows/test_size.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ jobs:
268268
shell: bash
269269
run: |
270270
cd pr/
271-
Tools/scripts/pretty_diff_size.py -m $GITHUB_WORKSPACE/base_branch_bin -s $GITHUB_WORKSPACE/pr_bin
271+
Tools/scripts/build_tests/pretty_diff_size.py -m $GITHUB_WORKSPACE/base_branch_bin -s $GITHUB_WORKSPACE/pr_bin
272272
273273
- name: Feature compare with ${{ github.event.pull_request.base.ref }}
274274
shell: bash
@@ -301,8 +301,26 @@ jobs:
301301
Tools/scripts/extract_features.py "$EF_BASE_BRANCH_BINARY" -nm "${BIN_PREFIX}nm" >features-base_branch.txt
302302
Tools/scripts/extract_features.py "$EF_PR_BRANCH_BINARY" -nm "${BIN_PREFIX}nm" >features-pr.txt
303303
diff -u features-base_branch.txt features-pr.txt || true
304+
diff_output=$(diff -u features-base_branch.txt features-pr.txt || true)
305+
echo "### Features Diff Output" >> $GITHUB_STEP_SUMMARY
306+
if [ -n "$diff_output" ]; then
307+
echo '```diff' >> $GITHUB_STEP_SUMMARY
308+
echo "$diff_output" >> $GITHUB_STEP_SUMMARY
309+
echo '```' >> $GITHUB_STEP_SUMMARY
310+
else
311+
echo "No differences found." >> $GITHUB_STEP_SUMMARY
312+
fi
304313
305314
- name: Checksum compare with ${{ github.event.pull_request.base.ref }}
306315
shell: bash
307316
run: |
308317
diff -r $GITHUB_WORKSPACE/base_branch_bin_no_versions $GITHUB_WORKSPACE/pr_bin_no_versions --exclude=*.elf --exclude=*.apj || true
318+
diff_output=$(diff -r $GITHUB_WORKSPACE/base_branch_bin_no_versions $GITHUB_WORKSPACE/pr_bin_no_versions --exclude=*.elf --exclude=*.apj || true || true)
319+
echo "### Checksum Diff Output" >> $GITHUB_STEP_SUMMARY
320+
if [ -n "$diff_output" ]; then
321+
echo '```diff' >> $GITHUB_STEP_SUMMARY
322+
echo "$diff_output" >> $GITHUB_STEP_SUMMARY
323+
echo '```' >> $GITHUB_STEP_SUMMARY
324+
else
325+
echo "No differences found." >> $GITHUB_STEP_SUMMARY
326+
fi

ArduCopter/Copter.cpp

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,9 @@ bool Copter::set_target_location(const Location& target_loc)
285285

286286
return mode_guided.set_destination(target_loc);
287287
}
288-
#endif //MODE_GUIDED_ENABLED
289-
#endif //AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
290288

291-
#if AP_SCRIPTING_ENABLED
292-
#if MODE_GUIDED_ENABLED
293289
// start takeoff to given altitude (for use by scripting)
294-
bool Copter::start_takeoff(float alt)
290+
bool Copter::start_takeoff(const float alt)
295291
{
296292
// exit if vehicle is not in Guided mode or Auto-Guided mode
297293
if (!flightmode->in_guided_mode()) {
@@ -304,7 +300,11 @@ bool Copter::start_takeoff(float alt)
304300
}
305301
return false;
306302
}
303+
#endif //MODE_GUIDED_ENABLED
304+
#endif //AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
307305

306+
#if AP_SCRIPTING_ENABLED
307+
#if MODE_GUIDED_ENABLED
308308
// set target position (for use by scripting)
309309
bool Copter::set_target_pos_NED(const Vector3f& target_pos, bool use_yaw, float yaw_deg, bool use_yaw_rate, float yaw_rate_degs, bool yaw_relative, bool terrain_alt)
310310
{
@@ -411,7 +411,55 @@ bool Copter::set_target_rate_and_throttle(float roll_rate_dps, float pitch_rate_
411411
mode_guided.set_angle(q, ang_vel_body, throttle, true);
412412
return true;
413413
}
414-
#endif
414+
415+
// Register a custom mode with given number and names
416+
AP_Vehicle::custom_mode_state* Copter::register_custom_mode(const uint8_t num, const char* full_name, const char* short_name)
417+
{
418+
const Mode::Number number = (Mode::Number)num;
419+
420+
// See if this mode has been registered already, if it has return the state for it
421+
// This allows scripting restarts
422+
for (uint8_t i = 0; i < ARRAY_SIZE(mode_guided_custom); i++) {
423+
if (mode_guided_custom[i] == nullptr) {
424+
break;
425+
}
426+
if ((mode_guided_custom[i]->mode_number() == number) &&
427+
(strcmp(mode_guided_custom[i]->name(), full_name) == 0) &&
428+
(strncmp(mode_guided_custom[i]->name4(), short_name, 4) == 0)) {
429+
return &mode_guided_custom[i]->state;
430+
}
431+
}
432+
433+
// Number already registered to existing mode
434+
if (mode_from_mode_num(number) != nullptr) {
435+
return nullptr;
436+
}
437+
438+
// Find free slot
439+
for (uint8_t i = 0; i < ARRAY_SIZE(mode_guided_custom); i++) {
440+
if (mode_guided_custom[i] == nullptr) {
441+
// Duplicate strings so were not pointing to unknown memory
442+
const char* full_name_copy = strdup(full_name);
443+
const char* short_name_copy = strndup(short_name, 4);
444+
if ((full_name_copy != nullptr) && (short_name_copy != nullptr)) {
445+
mode_guided_custom[i] = NEW_NOTHROW ModeGuidedCustom(number, full_name_copy, short_name_copy);
446+
}
447+
if (mode_guided_custom[i] == nullptr) {
448+
// Allocation failure
449+
return nullptr;
450+
}
451+
452+
// Registration sucsessful, notify the GCS that it should re-request the avalable modes
453+
gcs().available_modes_changed();
454+
455+
return &mode_guided_custom[i]->state;
456+
}
457+
}
458+
459+
// No free slots
460+
return nullptr;
461+
}
462+
#endif // MODE_GUIDED_ENABLED
415463

416464
#if MODE_CIRCLE_ENABLED
417465
// circle mode controls

ArduCopter/Copter.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,12 +668,12 @@ class Copter : public AP_Vehicle {
668668
#if AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
669669
#if MODE_GUIDED_ENABLED
670670
bool set_target_location(const Location& target_loc) override;
671+
bool start_takeoff(const float alt) override;
671672
#endif // MODE_GUIDED_ENABLED
672673
#endif // AP_SCRIPTING_ENABLED || AP_EXTERNAL_CONTROL_ENABLED
673674

674675
#if AP_SCRIPTING_ENABLED
675676
#if MODE_GUIDED_ENABLED
676-
bool start_takeoff(float alt) override;
677677
bool get_target_location(Location& target_loc) override;
678678
bool update_target_location(const Location &old_loc, const Location &new_loc) override;
679679
bool set_target_pos_NED(const Vector3f& target_pos, bool use_yaw, float yaw_deg, bool use_yaw_rate, float yaw_rate_degs, bool yaw_relative, bool terrain_alt) override;
@@ -684,6 +684,8 @@ class Copter : public AP_Vehicle {
684684
bool set_target_angle_and_climbrate(float roll_deg, float pitch_deg, float yaw_deg, float climb_rate_ms, bool use_yaw_rate, float yaw_rate_degs) override;
685685
bool set_target_rate_and_throttle(float roll_rate_dps, float pitch_rate_dps, float yaw_rate_dps, float throttle) override;
686686

687+
// Register a custom mode with given number and names
688+
AP_Vehicle::custom_mode_state* register_custom_mode(const uint8_t number, const char* full_name, const char* short_name) override;
687689
#endif
688690
#if MODE_CIRCLE_ENABLED
689691
bool get_circle_radius(float &radius_m) override;
@@ -1029,6 +1031,10 @@ class Copter : public AP_Vehicle {
10291031
#endif
10301032
#if MODE_GUIDED_ENABLED
10311033
ModeGuided mode_guided;
1034+
#if AP_SCRIPTING_ENABLED
1035+
// Custom modes registered at runtime
1036+
ModeGuidedCustom *mode_guided_custom[5];
1037+
#endif
10321038
#endif
10331039
ModeLand mode_land;
10341040
#if MODE_LOITER_ENABLED

0 commit comments

Comments
 (0)