Skip to content

Commit 226d860

Browse files
committed
remove name param, other sdks don't use it in nav wrappers
1 parent 3def54d commit 226d860

File tree

4 files changed

+61
-103
lines changed

4 files changed

+61
-103
lines changed

src/viam/sdk/services/navigation.hpp

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,48 +45,43 @@ class Navigation : public Service {
4545

4646
API api() const override;
4747

48-
virtual Mode get_mode(const std::string name, const ProtoStruct& extra) = 0;
49-
virtual void set_mode(const std::string name, const Mode mode, const ProtoStruct& extra) = 0;
50-
virtual LocationResponse get_location(const std::string name, const ProtoStruct& extra) = 0;
51-
virtual std::unique_ptr<std::vector<Waypoint>> get_waypoints(const std::string name,
52-
const ProtoStruct& extra) = 0;
53-
virtual void add_waypoint(const std::string name,
54-
const geo_point& location,
48+
virtual Mode get_mode(const ProtoStruct& extra) = 0;
49+
virtual void set_mode(const Mode mode, const ProtoStruct& extra) = 0;
50+
virtual LocationResponse get_location(const ProtoStruct& extra) = 0;
51+
virtual std::unique_ptr<std::vector<Waypoint>> get_waypoints(const ProtoStruct& extra) = 0;
52+
virtual void add_waypoint(const geo_point& location,
5553
const ProtoStruct& extra) = 0;
56-
virtual void remove_waypoint(const std::string name,
57-
const std::string id,
54+
virtual void remove_waypoint(const std::string id,
5855
const ProtoStruct& extra) = 0;
59-
virtual std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const std::string name,
60-
const ProtoStruct& extra) = 0;
61-
virtual std::unique_ptr<std::vector<Path>> get_paths(const std::string name,
62-
const ProtoStruct& extra) = 0;
63-
virtual MapType get_properties(const std::string) = 0;
56+
virtual std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const ProtoStruct& extra) = 0;
57+
virtual std::unique_ptr<std::vector<Path>> get_paths(const ProtoStruct& extra) = 0;
58+
virtual MapType get_properties() = 0;
6459
virtual ProtoStruct do_command(const ProtoStruct& command) = 0;
6560

6661
// overloads without `extra` param.
67-
inline Mode get_mode(const std::string name) {
68-
return get_mode(name, {});
62+
inline Mode get_mode() {
63+
return get_mode({});
6964
}
70-
inline void set_mode(const std::string name, const Mode mode) {
71-
set_mode(name, mode, {});
65+
inline void set_mode(const Mode mode) {
66+
set_mode(mode, {});
7267
}
73-
inline LocationResponse get_location(const std::string name) {
74-
return get_location(name, {});
68+
inline LocationResponse get_location() {
69+
return get_location({});
7570
}
76-
inline std::unique_ptr<std::vector<Waypoint>> get_waypoints(const std::string name) {
77-
return get_waypoints(name, {});
71+
inline std::unique_ptr<std::vector<Waypoint>> get_waypoints() {
72+
return get_waypoints({});
7873
}
79-
inline void add_waypoint(const std::string name, const geo_point& location) {
80-
add_waypoint(name, location, {});
74+
inline void add_waypoint(const geo_point& location) {
75+
add_waypoint(location, {});
8176
}
82-
inline void remove_waypoint(const std::string name, const std::string id) {
83-
remove_waypoint(name, id, {});
77+
inline void remove_waypoint(const std::string id) {
78+
remove_waypoint(id, {});
8479
}
85-
inline std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const std::string name) {
86-
return get_obstacles(name, {});
80+
inline std::unique_ptr<std::vector<geo_geometry>> get_obstacles() {
81+
return get_obstacles({});
8782
}
88-
inline std::unique_ptr<std::vector<Path>> get_paths(const std::string name) {
89-
return get_paths(name, {});
83+
inline std::unique_ptr<std::vector<Path>> get_paths() {
84+
return get_paths({});
9085
}
9186

9287
protected:

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

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,26 @@ 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

37-
Navigation::Mode NavigationClient::get_mode(const std::string name, const ProtoStruct& extra) {
37+
Navigation::Mode NavigationClient::get_mode(const ProtoStruct& extra) {
3838
return make_client_helper(this, *stub_, &StubType::GetMode)
39-
.with([&](auto& request) {
40-
*request.mutable_name() = name;
41-
*request.mutable_extra() = map_to_struct(extra);
42-
})
39+
.with([&](auto& request) { *request.mutable_extra() = map_to_struct(extra); })
4340
.invoke([](auto& response) { return Navigation::Mode(response.mode()); });
4441
}
4542

46-
void NavigationClient::set_mode(const std::string name,
47-
const Navigation::Mode mode,
48-
const ProtoStruct& extra) {
43+
void NavigationClient::set_mode(const Navigation::Mode mode, const ProtoStruct& extra) {
4944
return make_client_helper(this, *stub_, &StubType::SetMode)
5045
.with([&](auto& request) {
51-
*request.mutable_name() = name;
5246
request.set_mode(viam::service::navigation::v1::Mode(mode));
5347
*request.mutable_extra() = map_to_struct(extra);
5448
})
5549
.invoke([](auto& response) {});
5650
}
5751

58-
Navigation::LocationResponse NavigationClient::get_location(const std::string name,
59-
const ProtoStruct& extra) {
52+
Navigation::LocationResponse NavigationClient::get_location(const ProtoStruct& extra) {
6053
return make_client_helper(this, *stub_, &StubType::GetLocation)
61-
.with([&](auto& request) {
62-
*request.mutable_name() = name;
63-
*request.mutable_extra() = map_to_struct(extra);
64-
})
54+
.with([&](auto& request) { *request.mutable_extra() = map_to_struct(extra); })
6555
.invoke([](auto& response) {
6656
return Navigation::LocationResponse{
6757
geo_point::from_proto(response.location()),
@@ -71,50 +61,38 @@ Navigation::LocationResponse NavigationClient::get_location(const std::string na
7161
}
7262

7363
std::unique_ptr<std::vector<Navigation::Waypoint>> NavigationClient::get_waypoints(
74-
const std::string name, const ProtoStruct& extra) {
64+
const ProtoStruct& extra) {
7565
return make_client_helper(this, *stub_, &StubType::GetWaypoints)
76-
.with([&](auto& request) {
77-
*request.mutable_name() = name;
78-
*request.mutable_extra() = map_to_struct(extra);
79-
})
66+
.with([&](auto& request) { *request.mutable_extra() = map_to_struct(extra); })
8067
.invoke([](auto& response) {
8168
auto ret = std::make_unique<std::vector<Navigation::Waypoint>>();
8269
repeatedPtrToVec(response.waypoints(), *ret, waypoint_from_proto);
8370
return ret;
8471
});
8572
}
8673

87-
void NavigationClient::add_waypoint(const std::string name,
88-
const geo_point& location,
89-
const ProtoStruct& extra) {
74+
void NavigationClient::add_waypoint(const geo_point& location, const ProtoStruct& extra) {
9075
return make_client_helper(this, *stub_, &StubType::AddWaypoint)
9176
.with([&](auto& request) {
92-
*request.mutable_name() = name;
9377
*request.mutable_location() = location.to_proto();
9478
*request.mutable_extra() = map_to_struct(extra);
9579
})
9680
.invoke([](auto& response) {});
9781
}
9882

99-
void NavigationClient::remove_waypoint(const std::string name,
100-
const std::string id,
101-
const ProtoStruct& extra) {
83+
void NavigationClient::remove_waypoint(const std::string id, const ProtoStruct& extra) {
10284
return make_client_helper(this, *stub_, &StubType::RemoveWaypoint)
10385
.with([&](auto& request) {
104-
*request.mutable_name() = name;
10586
*request.mutable_id() = id;
10687
*request.mutable_extra() = map_to_struct(extra);
10788
})
10889
.invoke([](auto& response) {});
10990
}
11091

11192
std::unique_ptr<std::vector<geo_geometry>> NavigationClient::get_obstacles(
112-
const std::string name, const ProtoStruct& extra) {
93+
const ProtoStruct& extra) {
11394
return make_client_helper(this, *stub_, &StubType::GetObstacles)
114-
.with([&](auto& request) {
115-
*request.mutable_name() = name;
116-
*request.mutable_extra() = map_to_struct(extra);
117-
})
95+
.with([&](auto& request) { *request.mutable_extra() = map_to_struct(extra); })
11896
.invoke([](auto& response) {
11997
auto ret = std::make_unique<std::vector<geo_geometry>>();
12098
repeatedPtrToVec(response.obstacles(), *ret);
@@ -123,22 +101,19 @@ std::unique_ptr<std::vector<geo_geometry>> NavigationClient::get_obstacles(
123101
}
124102

125103
std::unique_ptr<std::vector<NavigationClient::Path>> NavigationClient::get_paths(
126-
const std::string name, const ProtoStruct& extra) {
104+
const ProtoStruct& extra) {
127105
return make_client_helper(this, *stub_, &StubType::GetPaths)
128-
.with([&](auto& request) {
129-
*request.mutable_name() = name;
130-
*request.mutable_extra() = map_to_struct(extra);
131-
})
106+
.with([&](auto& request) { *request.mutable_extra() = map_to_struct(extra); })
132107
.invoke([](auto& response) {
133108
auto ret = std::make_unique<std::vector<Path>>();
134109
repeatedPtrToVec(response.paths(), *ret, path_from_proto);
135110
return ret;
136111
});
137112
}
138113

139-
NavigationClient::MapType NavigationClient::get_properties(const std::string name) {
114+
NavigationClient::MapType NavigationClient::get_properties() {
140115
return make_client_helper(this, *stub_, &StubType::GetProperties)
141-
.with([&](auto& request) { *request.mutable_name() = name; })
116+
.with([&](auto& request) {})
142117
.invoke([](auto& response) { return MapType(response.map_type()); });
143118
}
144119

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,15 @@ class NavigationClient : public Navigation {
2121
using interface_type = Navigation;
2222
NavigationClient(std::string name, std::shared_ptr<grpc::Channel> channel);
2323

24-
Mode get_mode(const std::string name, const ProtoStruct& extra) override;
25-
void set_mode(const std::string name, const Mode mode, const ProtoStruct& extra) override;
26-
LocationResponse get_location(const std::string name, const ProtoStruct& extra) override;
27-
std::unique_ptr<std::vector<Waypoint>> get_waypoints(const std::string name,
28-
const ProtoStruct& extra) override;
29-
void add_waypoint(const std::string name,
30-
const geo_point& location,
31-
const ProtoStruct& extra) override;
32-
void remove_waypoint(const std::string name,
33-
const std::string id,
34-
const ProtoStruct& extra) override;
35-
std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const std::string name,
36-
const ProtoStruct& extra) override;
37-
std::unique_ptr<std::vector<Path>> get_paths(const std::string name,
38-
const ProtoStruct& extra) override;
39-
MapType get_properties(const std::string name) override;
24+
Mode get_mode(const ProtoStruct& extra) override;
25+
void set_mode(const Mode mode, const ProtoStruct& extra) override;
26+
LocationResponse get_location(const ProtoStruct& extra) override;
27+
std::unique_ptr<std::vector<Waypoint>> get_waypoints(const ProtoStruct& extra) override;
28+
void add_waypoint(const geo_point& location, const ProtoStruct& extra) override;
29+
void remove_waypoint(const std::string id, const ProtoStruct& extra) override;
30+
std::unique_ptr<std::vector<geo_geometry>> get_obstacles(const ProtoStruct& extra) override;
31+
std::unique_ptr<std::vector<Path>> get_paths(const ProtoStruct& extra) override;
32+
MapType get_properties() override;
4033
ProtoStruct do_command(const ProtoStruct& command) override;
4134

4235
private:

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

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ::grpc::Status NavigationServer::GetMode(::grpc::ServerContext*,
3636
GetModeResponse* response) noexcept {
3737
return make_service_helper<Navigation>(
3838
"NavigationServer::GetMode", this, request)([&](auto& helper, auto& nav) {
39-
response->set_mode(Mode(nav->get_mode(request->name(), helper.getExtra())));
39+
response->set_mode(Mode(nav->get_mode(helper.getExtra())));
4040
});
4141
}
4242

@@ -45,7 +45,7 @@ ::grpc::Status NavigationServer::SetMode(::grpc::ServerContext*,
4545
SetModeResponse*) noexcept {
4646
return make_service_helper<Navigation>(
4747
"NavigationServer::SetMode", this, request)([&](auto& helper, auto& nav) {
48-
nav->set_mode(request->name(), Navigation::Mode(request->mode()), helper.getExtra());
48+
nav->set_mode(Navigation::Mode(request->mode()), helper.getExtra());
4949
});
5050
}
5151

@@ -54,7 +54,7 @@ ::grpc::Status NavigationServer::GetLocation(::grpc::ServerContext*,
5454
GetLocationResponse* response) noexcept {
5555
return make_service_helper<Navigation>(
5656
"NavigationServer::GetLocation", this, request)([&](auto& helper, auto& nav) {
57-
const auto& loc = nav->get_location(request->name(), helper.getExtra());
57+
const auto& loc = nav->get_location(helper.getExtra());
5858
*response->mutable_location() = loc.location.to_proto();
5959
response->set_compass_heading(loc.compass_heading);
6060
});
@@ -65,7 +65,7 @@ ::grpc::Status NavigationServer::GetWaypoints(::grpc::ServerContext*,
6565
GetWaypointsResponse* response) noexcept {
6666
return make_service_helper<Navigation>(
6767
"NavigationServer::GetWaypoints", this, request)([&](auto& helper, auto& nav) {
68-
const auto& waypoints = nav->get_waypoints(request->name(), helper.getExtra());
68+
const auto& waypoints = nav->get_waypoints(helper.getExtra());
6969
vecToRepeatedPtr(*waypoints, *response->mutable_waypoints(), waypoint_to_proto);
7070
});
7171
}
@@ -75,26 +75,23 @@ ::grpc::Status NavigationServer::AddWaypoint(::grpc::ServerContext*,
7575
AddWaypointResponse*) noexcept {
7676
return make_service_helper<Navigation>(
7777
"NavigationServer::AddWaypoint", this, request)([&](auto& helper, auto& nav) {
78-
nav->add_waypoint(
79-
request->name(), geo_point::from_proto(request->location()), helper.getExtra());
78+
nav->add_waypoint(geo_point::from_proto(request->location()), helper.getExtra());
8079
});
8180
}
8281

8382
::grpc::Status NavigationServer::RemoveWaypoint(::grpc::ServerContext*,
8483
const RemoveWaypointRequest* request,
8584
RemoveWaypointResponse*) noexcept {
86-
return make_service_helper<Navigation>(
87-
"NavigationServer::RemoveWaypoint", this, request)([&](auto& helper, auto& nav) {
88-
nav->remove_waypoint(request->name(), request->id(), helper.getExtra());
89-
});
85+
return make_service_helper<Navigation>("NavigationServer::RemoveWaypoint", this, request)(
86+
[&](auto& helper, auto& nav) { nav->remove_waypoint(request->id(), helper.getExtra()); });
9087
}
9188

9289
::grpc::Status NavigationServer::GetObstacles(::grpc::ServerContext*,
9390
const GetObstaclesRequest* request,
9491
GetObstaclesResponse* response) noexcept {
9592
return make_service_helper<Navigation>(
9693
"NavigationServer::GetObstacles", this, request)([&](auto& helper, auto& nav) {
97-
const auto& obstacles = nav->get_obstacles(request->name(), helper.getExtra());
94+
const auto& obstacles = nav->get_obstacles(helper.getExtra());
9895
vecToRepeatedPtr(*obstacles, *response->mutable_obstacles());
9996
});
10097
}
@@ -104,18 +101,16 @@ ::grpc::Status NavigationServer::GetPaths(::grpc::ServerContext*,
104101
GetPathsResponse* response) noexcept {
105102
return make_service_helper<Navigation>(
106103
"NavigationServer::GetPaths", this, request)([&](auto& helper, auto& nav) {
107-
const auto& paths = nav->get_paths(request->name(), helper.getExtra());
104+
const auto& paths = nav->get_paths(helper.getExtra());
108105
vecToRepeatedPtr(*paths, *response->mutable_paths(), path_to_proto);
109106
});
110107
}
111108

112109
::grpc::Status NavigationServer::GetProperties(::grpc::ServerContext*,
113110
const GetPropertiesRequest* request,
114111
GetPropertiesResponse* response) noexcept {
115-
return make_service_helper<Navigation>(
116-
"NavigationServer::GetProperties", this, request)([&](auto&, auto& nav) {
117-
response->set_map_type(MapType(nav->get_properties(request->name())));
118-
});
112+
return make_service_helper<Navigation>("NavigationServer::GetProperties", this, request)(
113+
[&](auto&, auto& nav) { response->set_map_type(MapType(nav->get_properties())); });
119114
}
120115

121116
::grpc::Status NavigationServer::DoCommand(

0 commit comments

Comments
 (0)