35 if (
uart !=
nullptr) {
49 if (
uart ==
nullptr) {
117 if (ignore_area_count == 0) {
124 for (uint8_t i=0; i<ignore_area_count; i++) {
127 uint16_t ign_area_angle;
128 uint8_t ign_area_width;
132 int16_t start_angle, end_angle;
135 int16_t degrees_to_fill =
wrap_360(end_angle - start_angle);
139 uint16_t sector_size;
140 if (degrees_to_fill >= 90) {
143 }
else if (degrees_to_fill > 45) {
145 sector_size = degrees_to_fill / 2.0f;
148 sector_size = degrees_to_fill;
155 start_angle += sector_size;
157 degrees_to_fill -= sector_size;
176 if (
uart ==
nullptr) {
197 if (
uart ==
nullptr) {
218 if (
uart ==
nullptr) {
223 char request_str[15];
226 snprintf(request_str,
sizeof(request_str),
"#MBF,%d\r\n", yaw_corr);
238 if (
uart ==
nullptr) {
266 if (
uart ==
nullptr) {
278 if (
uart ==
nullptr) {
289 char request_str[16];
290 snprintf(request_str,
sizeof(request_str),
"?TS,%u,%u\r\n",
306 if (
uart ==
nullptr) {
318 while (nbytes-- > 0) {
321 if (c ==
'\r' || c ==
'\n') {
337 }
else if (c ==
'?') {
346 }
else if (c ==
',') {
356 }
else if (isdigit(c) || c ==
'.' || c ==
'-') {
373 if (
uart ==
nullptr) {
377 bool success =
false;
415 _angle[sector] = angle_deg;
static AP_SerialManager serial_manager
bool _distance_valid[PROXIMITY_SECTORS_MAX]
void set_forward_direction()
int16_t constrain_int16(const int16_t amt, const int16_t low, const int16_t high)
union AP_Proximity_LightWareSF40C::@166 _sensor_status
uint32_t _last_distance_received_ms
float _angle[PROXIMITY_SECTORS_MAX]
virtual void begin(uint32_t baud)=0
AP_Proximity_LightWareSF40C(AP_Proximity &_frontend, AP_Proximity::Proximity_State &_state, AP_SerialManager &serial_manager)
void set_motor_speed(bool on_off)
bool send_request_for_distance()
void set_motor_direction()
#define PROXIMITY_SF40C_TIMEOUT_MS
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
uint16_t _sector_middle_deg[PROXIMITY_SECTORS_MAX]
bool is_positive(const T fVal1)
int16_t get_yaw_correction(uint8_t instance) const
void set_status(AP_Proximity::Proximity_Status status)
float distance_max() const
uint32_t find_baudrate(enum SerialProtocol protocol, uint8_t instance) const
void send_request_for_health()
bool convert_angle_to_sector(float angle_degrees, uint8_t §or) const
uint32_t _last_request_ms
uint8_t get_ignore_area_count() const
enum RequestType _last_request_type
float wrap_360(const T angle, float unit_mod)
float _distance[PROXIMITY_SECTORS_MAX]
static bool detect(AP_SerialManager &serial_manager)
int sscanf(const char *buf, const char *fmt,...)
virtual size_t write(uint8_t)=0
virtual uint32_t available()=0
AP_Proximity::Proximity_State & state
bool get_next_ignore_start_or_end(uint8_t start_or_end, int16_t start_angle, int16_t &ignore_start) const
int snprintf(char *str, size_t size, const char *fmt,...)
uint8_t _sector_width_deg[PROXIMITY_SECTORS_MAX]
bool get_ignore_area(uint8_t index, uint16_t &angle_deg, uint8_t &width_deg) const
void update_boundary_for_sector(uint8_t sector)
#define PROXIMITY_SECTORS_MAX
float distance_min() const
AP_HAL::UARTDriver * uart
int16_t _forward_direction
AP_HAL::UARTDriver * find_serial(enum SerialProtocol protocol, uint8_t instance) const
uint8_t get_orientation(uint8_t instance) const