ArduPilot / ardupilot

ArduPlane, ArduCopter, ArduRover, ArduSub source
http://ardupilot.org/
GNU General Public License v3.0
11.03k stars 17.58k forks source link

IR Sensor Sonar function has been broken in the ArduRover v2.30 code since the move to HAL #63

Closed TC3 closed 11 years ago

TC3 commented 11 years ago

Since the move to the HAL version of the ardupilot code the IR sensor sonar function is no longer functioning and constantly returns a value of 715 no matter what distance an object is from the sensor. I suspect that the problem may be in these two snippets of code:

ModeFilterInt16_Size5 sonar_mode_filter(2);

if CONFIG_SONAR == ENABLED

AP_HAL::AnalogSource *sonar_analog_source;
AP_RangeFinder_MaxsonarXL *sonar;

endif

if CONFIG_SONAR == ENABLED

if CONFIG_SONAR_SOURCE == SONAR_SOURCE_ADC

sonar_analog_source = new AP_ADC_AnalogSource(
    &adc, CONFIG_SONAR_SOURCE_ADC_CHANNEL, 0.25);

elif CONFIG_SONAR_SOURCE == SONAR_SOURCE_ANALOG_PIN

sonar_analog_source = hal.analogin->channel(
    CONFIG_SONAR_SOURCE_ANALOG_PIN);

else

warning "Invalid CONFIG_SONAR_SOURCE"

endif

sonar = new AP_RangeFinder_MaxsonarXL(sonar_analog_source,
                                      &sonar_mode_filter);

endif

rmackay9 commented 11 years ago

The sonar is working again in ardurover I hear.