Skip to content

AP_Camera_Backend::Write_CameraInfo does not handle uninitialized location #29530

Closed
@blaab2

Description

@blaab2

Bug report

Issue details

This is a HAL_BOARD_SITL bug report. The panic function within libraries/AP_Common/Location.cpp is triggered if a camera trigger is requested without the location being available.

code details

This occurs as the

AP_HAL::panic("Should not be called on invalid location: Location cannot be (0, 0, 0)");

panic function will be raised by AP_Camera_Backend::Write_CameraInfo if camera trigger is requested (for example via mission planner) and location is not known yet. The unguarded call to current_loc.get_alt_cm raises this.

fix

if (!current_loc.get_alt_cm(Location::AltFrame::ABSOLUTE, altitude_cm)) {

and
if (!current_loc.get_alt_cm(Location::AltFrame::ABOVE_HOME, altitude_rel_cm)) {

should be
if (current_loc.initialised() && !current_loc.get_alt_cm(Location::AltFrame::ABSOLUTE, altitude_cm)) {
and
if (current_loc.initialised() && !current_loc.get_alt_cm(Location::AltFrame::ABOVE_HOME, altitude_rel_cm)) {

I could send a PR if requested.

Version
master branch
4.7.0-dev

Platform
[?] All
[ ] AntennaTracker
[X] Copter
[ ] Plane
[ ] Rover
[ ] Submarine

Airframe type
irrelevant

Hardware type
HAL_BOARD_SITL

Logs

#5  0x000055ebb20e1175 in AP_HAL::panic (errormsg=0x55ebb2231600 "Should not be called on invalid location: Location cannot be (0, 0, 0)") at ../../libraries/AP_HAL_SITL/system.cpp:51
        ap = {{gp_offset = 8, fp_offset = 48, overflow_arg_area = 0x7ffcabb23be0, reg_save_area = 0x7ffcabb23b20}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions