-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dynamic avoidance reaction #104
base: main
Are you sure you want to change the base?
Conversation
069cb63
to
e9b16ba
Compare
d3c92e0
to
6361274
Compare
}; | ||
|
||
|
||
// Wait until health is OK and vehicle is ready to arm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignore this
public: | ||
// Do not use a default constructor. The evasion state needs to know | ||
// the location of the obstacle | ||
ObstacleEvasionState() = delete; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if you need to delete the default constructor. I think if you define another one it will not generate a default one. But deleting it shouldn't hurt.
// Output after an obstacle has been detected | ||
struct Detection { | ||
std::chrono::time_point<std::chrono::system_clock> time; | ||
// TODO(Samir): is there a type for location of bounding box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a bounding box but it stores two corners of the bounding box, not the center of the bounding box.
obcpp/include/cv/utilities.hpp
Lines 20 to 29 in 664bbc8
class Bbox { | |
public: | |
int x1; | |
int y1; | |
int x2; | |
int y2; | |
int width(); | |
int height(); | |
}; |
class ObstacleDetectionQueue { | ||
public: | ||
ObstacleDetectionQueue(); | ||
void add(Detection detection); | ||
bool isEmpty(); | ||
// prune every image older than `age` seconds ago | ||
void pruneQueue(int age); | ||
// copies the queue so you can look at the data | ||
void copyQueue(std::queue<Detection> queue); | ||
|
||
private: | ||
// This is used to store all previous obstacles. | ||
// We need to make sure that a detection is not spurious | ||
// before engaging in emergency evasion. | ||
std::queue<Detection> queue; | ||
// Note that Step 4 in "Steps" above only triggers on a boolean | ||
// condition. I am still making this Detection queue thread safe | ||
// because it can be useful to be able to access this in the main | ||
// program. For example, once emergency evasion is engaged it can | ||
// poll the queue to make sure there is nothing more to evade. | ||
std::mutex mutex; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like hiding the complexity of the queue a lot and exposing a thread safe interface. It would be nice if we could have a generic version of this for all of obcpp since so many places are using thread safe queues.
ObstacleDetectionQueue::pruneQueue(); | ||
|
||
// TODO: check if the boxes are getting larger AND bigger than a threshold | ||
std::queue<Detection> queue; | ||
ObstacleDetectionQueue::copyQueue(queue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the ::
syntax here do? I might be trolling with C++ but I thought you needed to create an ObstacleDetectionQueue
instance to call methods on it?
// TODO: I am rethinking this now and it does not make sense to | ||
// have dynamic obstacle detection be part of it's own state. | ||
// The dynamic detection should be a part of a separate thread and | ||
// send a message to the Airdrop state to switch to the dynamic avoidance | ||
// state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this sentiment. I think it should be running in another thread during Airdrop and Search states.
I will close this PR unless anyone objects. Ultimately, I do not believe vision is a satisfactory approach for dynamic avoidance. It would not be the worst to adapt the ideas from this PR to next year. However, we need to have a proper LiDAR solution at some point. |
Greetings, gamers.
This PR desperately needs some CPR. I am requesting some backup in reviving this. As it is right now, it is just skeleton code. I think the comments express the idea I was going for. (TLDR: camera is always taking pics in another thread and this should trigger a state transition iff in airdrop state to emergency avoidance state which changes altitude until it cannot see an obstacle)
There are a few issues: