-
-
Notifications
You must be signed in to change notification settings - Fork 503
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
350 mission backend #369
350 mission backend #369
Conversation
c61d8e0
to
6e922bf
Compare
{ | ||
// TODO | ||
auto upload_handle = uploadMissionAndSaveParams(nullptr, nullptr); |
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.
👍
{ | ||
// TODO | ||
auto upload_handle = uploadMissionAndSaveParams(nullptr, nullptr); | ||
_result_callback(dc::Mission::Result::UNKNOWN); |
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.
Why would the result be UNKNOWN
? I think the result should only be unknown if something in the enum translation went wrong. If it is an actual error, it should be ERROR
or some specific error code, right?
Or is it that the error is unknown because with nullptr
the callback has not actually been called?
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.
It is just that I need to synchronize the call in the service (see here and here). So the upload call is blocked until the callback is actually called (this assumes that the callback is always called, eventually).
The value of it in this unit test has not importance. It just needs to trigger. Maybe I should make it a variable called ARBITRARY_RESULT
, to make this clear!
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.
One question is also whether it would make sense to make a sync upload_mission(...)
function in the core libs as well, so that I could get rid of this future here.
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.
Ok, yer UNKNOWN
is totally fine then.
One question is also whether it would make sense to make a sync upload_mission(...) function in the core libs as well, so that I could get rid of this future here.
So, is the easier way to use sync calls in the grpc backend? If yes, then it probably makes sense to have sync calls by default.
auto request = generateUploadRequest(mission_items); | ||
auto upload_handle = uploadMissionAndSaveParams(request, response); | ||
|
||
_result_callback(GetParam().second); |
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.
Help me please. What's GetParam()
here?
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 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.
ah, got it, thank you!
auto mission_item = std::make_shared<dc::MissionItem>(); | ||
mission_item->set_position(41.848695, 75.132751); | ||
mission_item->set_relative_altitude(50.4); | ||
mission_item->set_speed(8.3); |
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.
Some of the fields are actually floats and so it should be 8.3f
, however, I wonder if we shouldn't just make everything double
in DroneCore, especially in the public interface since DroneCore is not run on embedded platforms generally and everything is becoming 64 bits these days.
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.
Oh, is the compiler here generating a double
with value 8.3, and then implicitly casting it to a float? I will fix that.
I am not familiar with performance issues on embedded platforms, so I'll follow you on that (but dronecore could be run onboard the drone, right?). For me it's not a big problem to have floats. We will just need to stick to our decisions as it will be define in the proto files :-).
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.
Yes, but the onboard computers are likely arm64 these days, so moving to a double only interface might make sense.
plugins/mission/mission_item.cpp
Outdated
bool operator==(const MissionItem &lhs, const MissionItem &rhs) | ||
{ | ||
return (lhs.get_latitude_deg() == rhs.get_latitude_deg() | ||
|| isnan(lhs.get_latitude_deg()) && isnan(rhs.get_latitude_deg())) |
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 think it would be better to make it explicit what the operator order is.
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.
Oh, right. macOS is warning about that, and apparently I did not fix it on the right computer. I'll change it!
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.
Haha, it's a warning. The operator precedence is clear in theory but it's nice for the reader to make it explicit in my opinion.
<< "\tloiter_time: " << mission_item.get_loiter_time_s() << std::endl | ||
<< "\tcamera_action: " << mission_item.get_camera_action() << std::endl | ||
<< "\tcamera_photo_interval: " << mission_item.get_camera_photo_interval_s() | ||
<< std::endl << "]" << std::endl; |
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.
Nice!
case MissionItem::CameraAction::STOP_VIDEO: | ||
return str << "CameraAction::STOP_VIDEO"; | ||
case MissionItem::CameraAction::NONE: | ||
return str << "CameraAction::NONE"; |
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.
We should probably do the same kind of thing instead of the result_str()
methods.
plugins/mission/mocks/mission_mock.h
Outdated
@@ -8,13 +8,14 @@ | |||
namespace dronecore { | |||
namespace testing { | |||
|
|||
typedef std::function<void(Mission::Result)> result_callback_t; | |||
typedef std::function<void(Mission::Result)> mission_result_callback_t; |
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.
Can't you get this typedef from somwhere else? Or is it specific to testing?
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.
You're right. I did not want to take Mission::result_callback_t
, but for wrong reasons :-).
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.
Looks good to merge whenever you're done with the changes.
Effectively fixing the type of the relative altitude field in MissionItem (was double, needs float).
* Add an ARBITRARY_RESULT to tests to make it clear that the result does not matter * Make comparison operators priority clear by adding parentheses * Use result_callback_t from Mission instead or redefining it * Fix some floats assignments ("f" suffix was forgotten)
144af79
to
9b677cf
Compare
Add
UploadMission
andStartMission
to the mission backend.Connects to #350.