Skip to content

Commit 679432c

Browse files
committed
operator==, fix type on NavServer::DoCommand
1 parent 0128a00 commit 679432c

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/viam/sdk/services/navigation.hpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ class Navigation : public Service {
3131
struct LocationResponse {
3232
geo_point location;
3333
double compass_heading;
34+
35+
bool operator==(const LocationResponse& rhs) const {
36+
return compass_heading == rhs.compass_heading && location == rhs.location;
37+
}
3438
};
3539

3640
struct Properties {
@@ -45,6 +49,11 @@ class Navigation : public Service {
4549
struct Path {
4650
std::string destination_waypoint_id;
4751
std::vector<geo_point> geopoints;
52+
53+
bool operator==(const Path& rhs) const {
54+
return destination_waypoint_id == rhs.destination_waypoint_id &&
55+
geopoints == rhs.geopoints;
56+
}
4857
};
4958

5059
API api() const override;
@@ -53,10 +62,8 @@ class Navigation : public Service {
5362
virtual void set_mode(const Mode mode, const ProtoStruct& extra) = 0;
5463
virtual LocationResponse get_location(const ProtoStruct& extra) = 0;
5564
virtual std::unique_ptr<std::vector<Waypoint>> get_waypoints(const ProtoStruct& extra) = 0;
56-
virtual void add_waypoint(const geo_point& location,
57-
const ProtoStruct& extra) = 0;
58-
virtual void remove_waypoint(const std::string id,
59-
const ProtoStruct& extra) = 0;
65+
virtual void add_waypoint(const geo_point& location, const ProtoStruct& extra) = 0;
66+
virtual void remove_waypoint(const std::string id, const ProtoStruct& extra) = 0;
6067
virtual std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const ProtoStruct& extra) = 0;
6168
virtual std::unique_ptr<std::vector<Path>> get_paths(const ProtoStruct& extra) = 0;
6269
virtual Properties get_properties() = 0;

src/viam/sdk/services/private/navigation_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Navigation::Path path_from_proto(const viam::service::navigation::v1::Path& prot
3232
NavigationClient::NavigationClient(std::string name, std::shared_ptr<grpc::Channel> channel)
3333
: Navigation(std::move(name)),
3434
stub_(service::navigation::v1::NavigationService::NewStub(channel)),
35-
channel_(std::move(channel)) {};
35+
channel_(std::move(channel)){};
3636

3737
Navigation::Mode NavigationClient::get_mode(const ProtoStruct& extra) {
3838
return make_client_helper(this, *stub_, &StubType::GetMode)

src/viam/sdk/services/private/navigation_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ::grpc::Status NavigationServer::DoCommand(
120120
::grpc::ServerContext*,
121121
const ::viam::common::v1::DoCommandRequest* request,
122122
::viam::common::v1::DoCommandResponse* response) noexcept {
123-
return make_service_helper<Motion>(
123+
return make_service_helper<Navigation>(
124124
"NavigationServer::DoCommand", this, request)([&](auto&, auto& motion) {
125125
const ProtoStruct result = motion->do_command(struct_to_map(request->command()));
126126
*response->mutable_result() = map_to_struct(result);

0 commit comments

Comments
 (0)