ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Copter: Change enum values to int type

Open muramura opened this issue 1 year ago • 2 comments

AP_Enum is an ENUM variable. The FLOAT type is incorrect. Change it to the INT type.

muramura avatar Oct 15 '24 16:10 muramura

All defaults are stored as floats. https://github.com/ArduPilot/ardupilot/blob/81768b26ff447c7a8684c75f03fe6db941846b92/libraries/AP_Param/AP_Param.h#L205

IamPete1 avatar Oct 15 '24 16:10 IamPete1

@IamPete1 san. Comments thanks. All the values are floating-point numbers, aren't they? I think it would be better if the parameter definitions matched the type of AP_XXXX. Enums are integer values.

muramura avatar Oct 16 '24 03:10 muramura

@muramura as @IamPete1 points out, the underlying type in the structure is float, not integer. The cast to float would have been added to fix the compilation error which said pretty much exactly that.

Casting it to an integer first won't prevent the cast to float but will (a) make the code more ugly and (b) hide the fact that the value is stored as a float.

Sorry, closing this one.

peterbarker avatar Nov 08 '24 01:11 peterbarker

I understand that the parameter values are float values.

muramura avatar Nov 08 '24 01:11 muramura