-
-
Notifications
You must be signed in to change notification settings - Fork 502
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
Refactoring of the MAVLink parameter interface #449
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
18bd02b
mavlink_parameters: remove commented out code
julianoes 26e6550
mavlink_parameters: added param cache
julianoes f63a205
action: actually get params, don't just set them
julianoes 929ddd7
action: don't assume default params in tests
julianoes 9615c7b
action: don't use std::cout in integration tests
julianoes 6efc36e
action: add error code for getter/setter
julianoes 492c386
core: add sync param setter/getter
julianoes 7f584ee
ycm_extra_conf: get includes right
julianoes 1ef9c99
core: add sync param getters as well
julianoes 6ccf9c1
action: use sync interface for params
julianoes 1cf99c6
action: don't prescribe a default takeoff altitude
julianoes a346376
action: remove the cached params
julianoes 7d538e2
core: fix pair types
julianoes 2e235cd
core: move future/promise into param helper
julianoes 6fde25c
core: added comment on how to cache parameters
julianoes 32085c7
core: removed some unneeded older comments
julianoes bd5ef61
follow_me: use sync param setter, remove default
julianoes 9f89f75
backend: update the proto submodule
julianoes 27c6c1e
backend: WIP for getter/setter API changes
julianoes 5a2a95c
backend: update proto submodule
JonasVautherin 21f5c30
backend: fix SetMaximumSpeed in action
JonasVautherin 2d68e6d
backend: fix getsCorrectTakeoffAltitude and getMaxSpeedGetsRightValue…
JonasVautherin 29aa760
backend: add PARAMETER_ERROR to action
JonasVautherin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule proto
updated
from 7c7017 to 1728f6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,8 @@ using ActionServiceImpl = dronecode_sdk::backend::ActionServiceImpl<MockAction>; | |
using ActionResult = dronecode_sdk::rpc::action::ActionResult; | ||
using InputPair = std::pair<std::string, dronecode_sdk::ActionResult>; | ||
|
||
static constexpr auto ARBITRARY_ALTITUDE = 42.42f; | ||
static constexpr auto ARBITRARY_SPEED = 8.24f; | ||
static constexpr float ARBITRARY_ALTITUDE = 42.42f; | ||
static constexpr float ARBITRARY_SPEED = 8.24f; | ||
|
||
std::vector<InputPair> generateInputPairs(); | ||
std::string armAndGetTranslatedResult(dronecode_sdk::ActionResult arm_result); | ||
|
@@ -257,23 +257,24 @@ TEST_F(ActionServiceImplTest, getTakeoffAltitudeCallsGetter) | |
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
EXPECT_CALL(action, get_takeoff_altitude_m()).Times(1); | ||
EXPECT_CALL(action, get_takeoff_altitude()).Times(1); | ||
dronecode_sdk::rpc::action::GetTakeoffAltitudeResponse response; | ||
|
||
actionService.GetTakeoffAltitude(nullptr, nullptr, &response); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, getsCorrectTakeoffAltitude) | ||
TEST_P(ActionServiceImplTest, getsCorrectTakeoffAltitude) | ||
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
const float expected_altitude = ARBITRARY_ALTITUDE; | ||
ON_CALL(action, get_takeoff_altitude_m()).WillByDefault(Return(expected_altitude)); | ||
const auto expected_pair = std::make_pair<>(GetParam().second, ARBITRARY_ALTITUDE); | ||
ON_CALL(action, get_takeoff_altitude()).WillByDefault(Return(expected_pair)); | ||
dronecode_sdk::rpc::action::GetTakeoffAltitudeResponse response; | ||
|
||
actionService.GetTakeoffAltitude(nullptr, nullptr, &response); | ||
|
||
EXPECT_EQ(expected_altitude, response.altitude_m()); | ||
EXPECT_EQ(GetParam().first, ActionResult::Result_Name(response.action_result().result())); | ||
EXPECT_EQ(expected_pair.second, response.altitude()); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, getTakeoffAltitudeDoesNotCrashWithNullResponse) | ||
|
@@ -302,14 +303,14 @@ TEST_F(ActionServiceImplTest, setTakeoffAltitudeCallsSetter) | |
actionService.SetTakeoffAltitude(nullptr, &request, nullptr); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, setTakeoffAltitudeSetsRightValue) | ||
TEST_P(ActionServiceImplTest, setTakeoffAltitudeSetsRightValue) | ||
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
float expected_altitude = ARBITRARY_ALTITUDE; | ||
EXPECT_CALL(action, set_takeoff_altitude(expected_altitude)).Times(1); | ||
dronecode_sdk::rpc::action::SetTakeoffAltitudeRequest request; | ||
request.set_altitude_m(expected_altitude); | ||
request.set_altitude(expected_altitude); | ||
|
||
actionService.SetTakeoffAltitude(nullptr, &request, nullptr); | ||
} | ||
|
@@ -326,31 +327,43 @@ TEST_F(ActionServiceImplTest, getMaxSpeedCallsGetter) | |
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
EXPECT_CALL(action, get_max_speed_m_s()).Times(1); | ||
EXPECT_CALL(action, get_max_speed()).Times(1); | ||
dronecode_sdk::rpc::action::GetMaximumSpeedResponse response; | ||
|
||
actionService.GetMaximumSpeed(nullptr, nullptr, &response); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, getMaxSpeedGetsRightValue) | ||
TEST_P(ActionServiceImplTest, getMaxSpeedGetsRightValue) | ||
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
const auto expected_max_speed = ARBITRARY_SPEED; | ||
ON_CALL(action, get_max_speed_m_s()).WillByDefault(Return(expected_max_speed)); | ||
const auto expected_pair = std::make_pair<>(GetParam().second, ARBITRARY_SPEED); | ||
ON_CALL(action, get_max_speed()).WillByDefault(Return(expected_pair)); | ||
dronecode_sdk::rpc::action::GetMaximumSpeedResponse response; | ||
|
||
actionService.GetMaximumSpeed(nullptr, nullptr, &response); | ||
|
||
EXPECT_EQ(expected_max_speed, response.speed_m_s()); | ||
EXPECT_EQ(GetParam().first, ActionResult::Result_Name(response.action_result().result())); | ||
EXPECT_EQ(expected_pair.second, response.speed()); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, setMaxSpeedDoesNotCrashWithNullRequest) | ||
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
dronecode_sdk::rpc::action::SetMaximumSpeedResponse response; | ||
|
||
actionService.SetMaximumSpeed(nullptr, nullptr, nullptr); | ||
actionService.SetMaximumSpeed(nullptr, nullptr, &response); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, setMaxSpeedDoesNotCrashWithNullResponse) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
{ | ||
MockAction action; | ||
ActionServiceImpl actionService(action); | ||
dronecode_sdk::rpc::action::SetMaximumSpeedRequest request; | ||
request.set_speed(ARBITRARY_SPEED); | ||
|
||
actionService.SetMaximumSpeed(nullptr, &request, nullptr); | ||
} | ||
|
||
TEST_F(ActionServiceImplTest, setMaxSpeedCallsSetter) | ||
|
@@ -370,7 +383,7 @@ TEST_F(ActionServiceImplTest, setMaxSpeedSetsRightValue) | |
const auto expected_speed = ARBITRARY_SPEED; | ||
EXPECT_CALL(action, set_max_speed(expected_speed)).Times(1); | ||
dronecode_sdk::rpc::action::SetMaximumSpeedRequest request; | ||
request.set_speed_m_s(expected_speed); | ||
request.set_speed(expected_speed); | ||
|
||
actionService.SetMaximumSpeed(nullptr, &request, nullptr); | ||
} | ||
|
@@ -401,6 +414,8 @@ std::vector<InputPair> generateInputPairs() | |
input_pairs.push_back(std::make_pair("NO_VTOL_TRANSITION_SUPPORT", | ||
dronecode_sdk::ActionResult::NO_VTOL_TRANSITION_SUPPORT)); | ||
input_pairs.push_back(std::make_pair("UNKNOWN", dronecode_sdk::ActionResult::UNKNOWN)); | ||
input_pairs.push_back( | ||
std::make_pair("PARAMETER_ERROR", dronecode_sdk::ActionResult::PARAMETER_ERROR)); | ||
|
||
return input_pairs; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Aaaah!