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

Throw invalid argument exception in camera plugin #2496

Open
persuader72 opened this issue Jan 18, 2025 · 4 comments
Open

Throw invalid argument exception in camera plugin #2496

persuader72 opened this issue Jan 18, 2025 · 4 comments
Labels

Comments

@persuader72
Copy link
Contributor

This piece of code in camera_definition.cpp at row 745 (in main)

`  for (const auto& option : _parameter_map[setting_name]->options) {
        if (option->value == option_name) {
            description = option->name;
            return true;
        }
    }
    LogWarn() << "Option " << option_name << " not found";`

Is throwing an invalid argument exception because option_name can't be converted to an unsigned integer.

Image

Maybe is a typo?

I changed

        if (option->value == option_name) {

with

        if (option->name == option_name) {

and now the library i working normally.

The following is the xml file that is throwing the exception when is parsed.

<?xml version="1.0" encoding="UTF-8" ?>
<mavlinkcamera>
    <definition version="11">
        <model>GaeboEO</model>
        <vendor>XP4</vendor>
    </definition>
    <parameters>
        <!-- control = 0 tells us this should not create an automatic UI control -->
        <parameter name="CAM_MODE" type="uint32" default="1" control="0">
            <description>Camera Mode</description>
            <options>
                <option name="Photo" value="0"/>
                <option name="Video" value="1"/>
            </options>
        </parameter>
        <parameter name="CAM_ZOOM" type="uint32" default="1" control="1">
            <description>Optical Zoom</description>
            <options>
                <option name="1x" value="1"/>
                <option name="2x" value="2"/>
                <option name="3x" value="3"/>
                <option name="4x" value="4"/>
                <option name="5x" value="5"/>
                <option name="6x" value="6"/>
                <option name="7x" value="7"/>
                <option name="8x" value="8"/>
                <option name="9x" value="9"/>
                <option name="10x" value="10"/>
                <option name="11x" value="11"/>
                <option name="12x" value="12"/>
                <option name="13x" value="13"/>
                <option name="14x" value="14"/>
                <option name="15x" value="15"/>
                <option name="16x" value="16"/>
                <option name="17x" value="17"/>
                <option name="18x" value="18"/>
                <option name="19x" value="19"/>
                <option name="20x" value="20"/>
                <option name="21x" value="21"/>
                <option name="22x" value="22"/>
                <option name="23x" value="23"/>
                <option name="24x" value="24"/>
                <option name="25x" value="25"/>
                <option name="26x" value="26"/>
                <option name="27x" value="27"/>
                <option name="28x" value="28"/>
                <option name="29x" value="29"/>
                <option name="30x" value="30"/>
            </options>
        </parameter>
        <parameter name="CAM_OPTCTRL" type="uint32" writeonly="1" default="3" control="1">
            <description>Camera Zoom</description>
            <options>
                <option name="tele" value="1"/>
                <option name="wide" value="2"/>
                <option name="stop" value="3"/>
            </options>
        </parameter>
        <parameter name="CAM_Z2F" type="float" default="4.3" control="0">
            <description>Zoom to focal length</description>
            <options>
                <option name="1x" value="4.3"/>
                <option name="2x" value="4.4"/>
                <option name="3x" value="4.8"/>
                <option name="4x" value="5.4"/>
                <option name="5x" value="6.1"/>
                <option name="6x" value="6.9"/>
                <option name="7x" value="7.8"/>
                <option name="8x" value="8.0"/>
                <option name="9x" value="10.0"/>
                <option name="10x" value="10.9"/>
                <option name="11x" value="12.7"/>
                <option name="12x" value="14.4"/>
                <option name="13x" value="16.3"/>
                <option name="14x" value="18.6"/>
                <option name="15x" value="21.3"/>
                <option name="16x" value="24.3"/>
                <option name="17x" value="27.6"/>
                <option name="18x" value="31.2"/>
                <option name="19x" value="35.1"/>
                <option name="20x" value="39.5"/>
                <option name="21x" value="44.3"/>
                <option name="22x" value="49.5"/>
                <option name="23x" value="55.6"/>
                <option name="24x" value="62.1"/>
                <option name="25x" value="69.5"/>
                <option name="26x" value="78.2"/>
                <option name="27x" value="88.4"/>
                <option name="28x" value="100.9"/>
                <option name="29x" value="112.1"/>
                <option name="30x" value="126.8"/>
                <option name="31x" value="127.9"/>
                <option name="32x" value="129.0"/>
            </options>
        </parameter>
    </parameters>
</mavlinkcamera>
@julianoes
Copy link
Collaborator

Ah, sounds like you're right. Do you mind making a pull request?

@persuader72
Copy link
Contributor Author

👌, Done in PR 2498

@persuader72
Copy link
Contributor Author

I see now that the PR can't be cherry picked in v2 branch.
Can I make a different PR for the v2 branch?

@julianoes
Copy link
Collaborator

Sure, you can make a backport PR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants