AP_IRLock: tidy up inclusions to match standards

including adding an _config.h
This commit is contained in:
Peter Barker 2025-02-06 21:23:54 +11:00 committed by Randy Mackay
parent 549c1fafb5
commit 14cbc1995c
10 changed files with 75 additions and 17 deletions

View File

@ -6,12 +6,13 @@
#include <AC_PrecLand/AC_PrecLand_Backend.h>
#include <AP_Math/AP_Math.h>
#include <AP_IRLock/AP_IRLock_config.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include <AP_IRLock/AP_IRLock_SITL.h>
#else
#include <AP_IRLock/AP_IRLock.h>
#endif
#if AP_IRLOCK_SITL_ENABLED
#include <AP_IRLock/AP_IRLock_SITL.h>
#elif AP_IRLOCK_I2C_ENABLED
#include <AP_IRLock/AP_IRLock_I2C.h>
#endif // AP_IRLOCK_I2C_ENABLED
/*
* AC_PrecLand_IRLock - implements precision landing using target vectors provided
@ -32,9 +33,9 @@ public:
void update() override;
private:
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_IRLOCK_SITL_ENABLED
AP_IRLock_SITL irlock;
#else
#elif AP_IRLOCK_I2C_ENABLED
AP_IRLock_I2C irlock;
#endif
};

View File

@ -5,6 +5,10 @@
* Author: MLandes
*/
#include "AP_IRLock_config.h"
#if AP_IRLOCK_ENABLED
#include "AP_IRLock.h"
// retrieve body frame unit vector in direction of target
@ -23,3 +27,5 @@ bool AP_IRLock::get_unit_vector_body(Vector3f& ret) const
ret /= ret.length();
return true;
}
#endif // AP_IRLOCK_ENABLED

View File

@ -21,6 +21,10 @@
*/
#pragma once
#include "AP_IRLock_config.h"
#if AP_IRLOCK_ENABLED
#include <AP_Math/AP_Math.h>
class AP_IRLock
@ -65,3 +69,5 @@ protected:
irlock_target_info _target_info;
};
#endif // AP_IRLOCK_ENABLED

View File

@ -20,6 +20,10 @@
*
* See: http://irlock.com/pages/serial-communication-protocol
*/
#include "AP_IRLock_config.h"
#if AP_IRLOCK_I2C_ENABLED
#include <AP_HAL/AP_HAL.h>
#include "AP_IRLock_I2C.h"
#include <stdio.h>
@ -171,3 +175,5 @@ bool AP_IRLock_I2C::update()
// return true if new data found
return new_data;
}
#endif // AP_IRLOCK_I2C_ENABLED

View File

@ -4,6 +4,10 @@
*/
#pragma once
#include "AP_IRLock_config.h"
#if AP_IRLOCK_I2C_ENABLED
#include "AP_IRLock.h"
#include <AP_HAL/AP_HAL.h>
@ -39,3 +43,5 @@ private:
HAL_Semaphore sem;
uint32_t _last_read_ms;
};
#endif // AP_IRLOCK_I2C_ENABLED

View File

@ -19,9 +19,10 @@
* Created on: June 09, 2016
* Author: Ian Chen
*/
#include <AP_HAL/AP_HAL.h>
#include "AP_IRLock_config.h"
#if AP_IRLOCK_SITL_ENABLED
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_IRLock_SITL.h"
#include "AP_AHRS/AP_AHRS.h"
@ -55,4 +56,4 @@ bool AP_IRLock_SITL::update()
return false;
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_SITL
#endif // AP_IRLOCK_SITL_ENABLED

View File

@ -6,7 +6,10 @@
*/
#pragma once
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_IRLock_config.h"
#if AP_IRLOCK_SITL_ENABLED
#include "AP_IRLock.h"
#include <SITL/SITL.h>
@ -23,4 +26,5 @@ private:
SITL::SIM *_sitl; // sitl instance pointer
uint32_t _last_timestamp = 0;
};
#endif // CONFIG_HAL_BOARD
#endif // AP_IRLOCK_SITL_ENABLED

View File

@ -19,9 +19,10 @@
* Created on: June 09, 2016
* Author: Ian Chen
*/
#include <AP_HAL/AP_HAL.h>
#include "AP_IRLock_config.h"
#if AP_IRLOCK_SITL_GAZEBO_ENABLED
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_IRLock_SITL_Gazebo.h"
#include <SITL/SITL.h>
#include <fcntl.h>
@ -92,4 +93,4 @@ bool AP_IRLock_SITL_Gazebo::update()
return new_data;
}
#endif // CONFIG_HAL_BOARD == HAL_BOARD_SITL
#endif // AP_IRLOCK_SITL_GAZEBO_ENABLED

View File

@ -6,8 +6,11 @@
*/
#pragma once
#include "AP_IRLock_config.h"
#if AP_IRLOCK_SITL_GAZEBO_ENABLED
#include <AP_HAL/utility/Socket_native.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include "AP_IRLock.h"
class AP_IRLock_SITL_Gazebo : public AP_IRLock
@ -26,4 +29,5 @@ private:
uint32_t _last_timestamp;
SocketAPM_native sock;
};
#endif // CONFIG_HAL_BOARD
#endif // AP_IRLOCK_SITL_GAZEBO_ENABLED

View File

@ -0,0 +1,23 @@
#pragma once
#include <AP_HAL/AP_HAL_Boards.h>
#ifndef AP_IRLOCK_ENABLED
#define AP_IRLOCK_ENABLED 1
#endif // AP_IRLOCK_ENABLED
#ifndef AP_IRLOCK_BACKEND_DEFAULT_ENABLED
#define AP_IRLOCK_BACKEND_DEFAULT_ENABLED AP_IRLOCK_ENABLED
#endif // AP_IRLOCK_BACKEND_DEFAULT_ENABLED
#ifndef AP_IRLOCK_I2C_ENABLED
#define AP_IRLOCK_I2C_ENABLED AP_IRLOCK_BACKEND_DEFAULT_ENABLED
#endif // AP_IRLOCK_I2C_ENABLED
#ifndef AP_IRLOCK_SITL_ENABLED
#define AP_IRLOCK_SITL_ENABLED AP_IRLOCK_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
#endif // AP_IRLOCK_SITL_ENABLED
#ifndef AP_IRLOCK_SITL_GAZEBO_ENABLED
#define AP_IRLOCK_SITL_GAZEBO_ENABLED AP_IRLOCK_BACKEND_DEFAULT_ENABLED && (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
#endif // AP_IRLOCK_SITL_GAZEBO_ENABLED