Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4224d0f
Added finally edited pixy_parser file that seems to give the desired …
Aksellence Oct 31, 2018
9f1cced
Tested more edge cases and added a feature which tell how many bytes …
Aksellence Nov 7, 2018
7fc24b1
Resolved writebuf Buffer print status issue
Aksellence Nov 8, 2018
069b7f6
Made changes which prints the block data bytes
Aksellence Nov 13, 2018
9262b4c
Renamed the working pixy_parser so that it does not get confused with…
Aksellence Nov 13, 2018
72f2db7
Refactored pixy_parser to OOP so that it can be ued inside the ardupi…
Aksellence Nov 13, 2018
dbbed62
Refactored the code to OOP, still needs debugging
Aksellence Nov 26, 2018
fe2e771
pixy_parser: fix misc errors
jschall Nov 26, 2018
f73a0e9
Integrated pixy_paser with the firmware, still doubt the integrity of…
Aksellence Nov 29, 2018
2e54c88
Fixed data integrity issue
Aksellence Nov 29, 2018
fbdace8
Added thread safe interface(between AC_Precland and pixy_parser) logic
Aksellence Nov 30, 2018
678deb4
Pixy parser driver complete, still needs testing
Aksellence Dec 4, 2018
d708c47
Pixy_parser driver code-complete, solved semaphore block issue (print…
Aksellence Dec 4, 2018
450780d
Added multi-target detection and contingency landing logic. Pixycam d…
Aksellence Dec 7, 2018
d68e06e
Cleaned the code and cleared garbage print statements
Aksellence Dec 7, 2018
994bcc5
Added finally edited pixy_parser file that seems to give the desired …
Aksellence Oct 31, 2018
c01757e
Tested more edge cases and added a feature which tell how many bytes …
Aksellence Nov 7, 2018
38ebe77
Resolved writebuf Buffer print status issue
Aksellence Nov 8, 2018
375834c
Made changes which prints the block data bytes
Aksellence Nov 13, 2018
3b522dc
Renamed the working pixy_parser so that it does not get confused with…
Aksellence Nov 13, 2018
cfb4535
Refactored pixy_parser to OOP so that it can be ued inside the ardupi…
Aksellence Nov 13, 2018
704cb71
Refactored the code to OOP, still needs debugging
Aksellence Nov 26, 2018
2cf6299
pixy_parser: fix misc errors
jschall Nov 26, 2018
d433453
Integrated pixy_paser with the firmware, still doubt the integrity of…
Aksellence Nov 29, 2018
12ff4e2
Fixed data integrity issue
Aksellence Nov 29, 2018
6b3f480
Added thread safe interface(between AC_Precland and pixy_parser) logic
Aksellence Nov 30, 2018
ca1fe8b
Pixy parser driver complete, still needs testing
Aksellence Dec 4, 2018
38ebfae
Pixy_parser driver code-complete, solved semaphore block issue (print…
Aksellence Dec 4, 2018
6a77ae0
Added multi-target detection and contingency landing logic. Pixycam d…
Aksellence Dec 7, 2018
9886d14
Cleaned the code and cleared garbage print statements
Aksellence Dec 7, 2018
849b610
Merge branch 'feature/pixy_parser' of github.com:matternet/ardupilot …
Aksellence Feb 27, 2019
59575de
Added Multi target detection alert & made it ready to be uploded on v…
Aksellence Mar 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions libraries/AC_PrecLand/AC_PrecLand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <AP_UAVCAN/AP_UAVCAN.h>
#endif

//param show PLND_type

extern const AP_HAL::HAL& hal;

const AP_Param::GroupInfo AC_PrecLand::var_info[] = {
Expand Down Expand Up @@ -178,8 +180,7 @@ void AC_PrecLand::update(float rangefinder_alt_cm, bool rangefinder_alt_valid)
}
}

bool AC_PrecLand::target_acquired()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's best not to change formatting for no reason. Also please follow the ArduPilot style guide.
http://ardupilot.org/dev/docs/style-guide.html

{
bool AC_PrecLand::target_acquired() {
if ((AP_HAL::millis()-_last_update_ms) >= 2000) {
_estimator_initialized = false;
_target_acquired = false;
Expand All @@ -188,6 +189,17 @@ bool AC_PrecLand::target_acquired()
return _target_acquired;
}

void AC_PrecLand::set_target_acquired(bool _target_acquired_value) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use an _ prefix on the variable name for a function?
(some people like _ for private variables in classes, which is fine if you like it, but pointless for local variables)

if (_target_acquired_value == false) {
_target_acquired = _target_acquired_value;
_estimator_initialized = false;
}
else {
_target_acquired = _target_acquired_value;
}
}


bool AC_PrecLand::get_height_above_target_cm(int32_t& ret) {
#if !HAL_WITH_UAVCAN
return false;
Expand Down
3 changes: 3 additions & 0 deletions libraries/AC_PrecLand/AC_PrecLand.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class AC_PrecLand
// returns true when the landing target has been detected
bool target_acquired();

// sets the value of _target_acquired
void set_target_acquired(bool _target_acquired_value);

// process a LANDING_TARGET mavlink message
void handle_msg(mavlink_message_t* msg);

Expand Down
4 changes: 2 additions & 2 deletions libraries/AC_PrecLand/AC_PrecLand_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class AC_PrecLand_Backend
{
public:
// Constructor
AC_PrecLand_Backend(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state) :
AC_PrecLand_Backend(AC_PrecLand& frontend, AC_PrecLand::precland_state& state) :
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the const? Better to expose the data you want in the state struct

_frontend(frontend),
_state(state) {}

Expand Down Expand Up @@ -43,6 +43,6 @@ class AC_PrecLand_Backend
int8_t get_bus(void) const { return _frontend._bus.get(); }

protected:
const AC_PrecLand& _frontend; // reference to precision landing front end
AC_PrecLand& _frontend; // reference to precision landing front end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should leave const alone

AC_PrecLand::precland_state &_state; // reference to this instances state
};
3 changes: 2 additions & 1 deletion libraries/AC_PrecLand/AC_PrecLand_Companion.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

#include <AP_HAL/AP_HAL.h>
#include "AC_PrecLand_Companion.h"

extern const AP_HAL::HAL& hal;

// Constructor
AC_PrecLand_Companion::AC_PrecLand_Companion(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state)
AC_PrecLand_Companion::AC_PrecLand_Companion(AC_PrecLand& frontend, AC_PrecLand::precland_state& state)
: AC_PrecLand_Backend(frontend, state),
_timestamp_us(0),
_distance_to_target(0.0f),
Expand Down
3 changes: 2 additions & 1 deletion libraries/AC_PrecLand/AC_PrecLand_Companion.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#pragma once

#include <AP_Common/AP_Common.h>
Expand All @@ -13,7 +14,7 @@ class AC_PrecLand_Companion : public AC_PrecLand_Backend
{
public:
// Constructor
AC_PrecLand_Companion(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state);
AC_PrecLand_Companion(AC_PrecLand& frontend, AC_PrecLand::precland_state& state);

// perform any required initialisation of backend
void init() override;
Expand Down
43 changes: 40 additions & 3 deletions libraries/AC_PrecLand/AC_PrecLand_IRLock.cpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,59 @@

#include <AP_HAL/AP_HAL.h>
#include "AC_PrecLand_IRLock.h"
#include <GCS_MAVLink/GCS.h>

extern const AP_HAL::HAL& hal;

// Constructor
AC_PrecLand_IRLock::AC_PrecLand_IRLock(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state)
AC_PrecLand_IRLock::AC_PrecLand_IRLock(AC_PrecLand& frontend, AC_PrecLand::precland_state& state)
: AC_PrecLand_Backend(frontend, state),
irlock(),
_have_los_meas(false),
_los_meas_time_ms(0)
_los_meas_time_ms(0),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't actually need to initialise values to 0 or false, as it happens automatically (as we override memory allocation with a function that zeros memory)

_multiple_target_timestamp_log(),
_index(0)
{
}

// init - perform initialisation of this backend
void AC_PrecLand_IRLock::init()
void AC_PrecLand_IRLock::init()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added extra whitespace?
It would be good to use "git add -p" when adding code for a commit so you don't end up with extra stuff

{
irlock.init(get_bus());
}

//multiple_target_check - Checks if multiple targets detected for 500 ms continously. If yes, sets target_acquired=False which calls contingency landing
void AC_PrecLand_IRLock::multiple_target_check()
{
if (_index == 24) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

magic value 24? Maybe you means ARRAY_SIZE(_multiple_target_timestamp_log) or add a #define for it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, why 24 anyway? Array is 25 long, so shouldn't we set to zero if value is 25?

_index = 0;
}
_multiple_target_timestamp_log[_index] = irlock.num_targets();
_index++;

/*
printf("\n _multiple_target_timestamp_log: ");
for (size_t j=0; j<24; j++) {
printf("%u ", _multiple_target_timestamp_log[j]);
}
*/
size_t count = 0;
for (size_t j=0; j<24; j++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is j size_t ? more magic values of 24 which look wrong

if (_multiple_target_timestamp_log[j] > 1) {
count++;
}
}
uint16_t multiple_target_count_percentage = count*100/25;
// printf("\nCount: %u -- Multiple_target_count_percentage: %u", irlock.num_targets(), multiple_target_count_percentage);
if (multiple_target_count_percentage >= 80) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is 80% the threshold?

// printf("\n----------------------------------------------------------------------HIGH COUNT PERCENTAGE: %u ------setting TARGET ACQUIRED FALSE -- %", multiple_target_count_percentage);
gcs().send_text(MAV_SEVERITY_CRITICAL, "Multiple Targets Detected");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at what rate will this message appear? We don't want to flood the link

// Send sn alert telling multiple targets detected
_frontend.set_target_acquired(false);
}
}


// update - give chance to driver to get updates from sensor
void AC_PrecLand_IRLock::update()
{
Expand All @@ -31,6 +67,7 @@ void AC_PrecLand_IRLock::update()
irlock.get_unit_vector_body(_los_meas_body);
_have_los_meas = true;
_los_meas_time_ms = irlock.last_update_ms();
multiple_target_check();
}
_have_los_meas = _have_los_meas && AP_HAL::millis()-_los_meas_time_ms <= 1000;
}
Expand Down
10 changes: 9 additions & 1 deletion libraries/AC_PrecLand/AC_PrecLand_IRLock.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#pragma once

#include <AP_Common/AP_Common.h>
Expand All @@ -19,7 +20,7 @@ class AC_PrecLand_IRLock : public AC_PrecLand_Backend
public:

// Constructor
AC_PrecLand_IRLock(const AC_PrecLand& frontend, AC_PrecLand::precland_state& state);
AC_PrecLand_IRLock(AC_PrecLand& frontend, AC_PrecLand::precland_state& state);

// perform any required initialisation of backend
void init() override;
Expand All @@ -37,10 +38,17 @@ class AC_PrecLand_IRLock : public AC_PrecLand_Backend
// return true if there is a valid los measurement available
bool have_los_meas() override;

//multiple_target_check - Checks if multiple targets detected for 500 ms continously.
//If yes, sets target_acquired=False which calls contingency landing
void multiple_target_check();


private:
AP_IRLock_I2C irlock;

Vector3f _los_meas_body; // unit vector in body frame pointing towards target
bool _have_los_meas; // true if there is a valid measurement from the camera
uint32_t _los_meas_time_ms; // system time in milliseconds when los was measured
uint32_t _multiple_target_timestamp_log[25]; // array of timestamps when multiple targets detected
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is 25, whereas above 24 is used. A #define or const would be good

size_t _index;
};
Loading