Rangefinder_max_instances

Hi there,

I’m trying to figure out what is the connection between “RANGEFINDER_MAX_INSTANCES” and “num_instances” values.

The default is:

  • RANGEFINDER_MAX_INSTANCES = 2
  • num_instances: 3

I managed to raise the values to:

  • RANGEFINDER_MAX_INSTANCES = 4
  • num_instances: 5

And build the code successfully, but if I try to use:

  • RANGEFINDER_MAX_INSTANCES = 6
  • num_instances: 7

Then the code is built but the PIXHAWK won’t initialize.

Could someone please explain me the connection between the 2 values?
Are they limited on some way?
Perhaps I am not understanding fully the bit field structure.

Someone? Someone? Someone?

the limitation is here : https://github.com/ArduPilot/ardupilot/blob/master/libraries/AP_RangeFinder/RangeFinder.cpp#L403
With rangefinder_max_instances > 3 you will segfault by trying to access an object that doesn’t exist.

It cant be the problem because I added parameters for 6 Rangefinders with the same statements - “rangefinders max_instances > 4” & “rangefinders max instances > 5”.