Viam C++ SDK current
Loading...
Searching...
No Matches
motion_client.hpp
1
4#pragma once
5
6#include <grpcpp/channel.h>
7
8#include <viam/api/service/motion/v1/motion.grpc.pb.h>
9
10#include <viam/sdk/services/motion.hpp>
11
12namespace viam {
13namespace sdk {
14namespace impl {
15
19class MotionClient : public Motion {
20 public:
21 using interface_type = Motion;
22 MotionClient(std::string name, std::shared_ptr<grpc::Channel> channel);
23 bool move(const pose_in_frame& destination,
24 const Name& component_name,
25 const std::shared_ptr<WorldState>& world_state,
26 const std::shared_ptr<constraints>& constraints,
27 const ProtoStruct& extra) override;
28
29 std::string move_on_map(const pose& destination,
30 const Name& component_name,
31 const Name& slam_name,
32 const std::shared_ptr<motion_configuration>& motion_configuration,
33 const std::vector<GeometryConfig>& obstacles,
34 const ProtoStruct& extra) override;
35
36 std::string move_on_globe(const geo_point& destination,
37 const boost::optional<double>& heading,
38 const Name& component_name,
39 const Name& movement_sensor_name,
40 const std::vector<geo_geometry>& obstacles,
41 const std::shared_ptr<motion_configuration>& motion_configuration,
42 const std::vector<geo_geometry>& bounding_regions,
43 const ProtoStruct& extra) override;
44
45 pose_in_frame get_pose(const Name& component_name,
46 const std::string& destination_frame,
47 const std::vector<WorldState::transform>& supplemental_transforms,
48 const ProtoStruct& extra) override;
49
50 void stop_plan(const Name& component_name, const ProtoStruct& extra) override;
51
53 const ProtoStruct& extra) override;
54
55 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
56
58 const ProtoStruct& extra) override;
59
60 Motion::plan_with_status get_plan(const Name& component_name,
61 const std::string& execution_id,
62 const ProtoStruct& extra) override;
63
64 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
65 get_plan_with_replan_history(const Name& component_name,
66 const std::string& execution_id,
67 const ProtoStruct& extra) override;
68
69 std::vector<Motion::plan_status_with_id> list_active_plan_statuses(
70 const ProtoStruct& extra) override;
71
72 std::vector<Motion::plan_status_with_id> list_plan_statuses(const ProtoStruct& extra) override;
73
74 ProtoStruct do_command(const ProtoStruct& command) override;
75
76 // the `extra` param is frequently unnecessary but needs to be supported. Ideally, we'd
77 // like to live in a world where implementers of derived classes don't need to go out of
78 // their way to support two versions of a method (an `extra` version and a non-`extra`
79 // version), and users don't need to pass an unnecessary parameters to all method calls.
80 //
81 // To do this, we define in the parent resource class a non-virtual version of the methods
82 // that calls the virtual method and passes a `nullptr` by default in place of the `extra`
83 // param. In order to access these versions of the methods within the client code, however,
84 // we need to include these `using` lines.
87 using Motion::get_plan;
89 using Motion::get_pose;
92 using Motion::move;
96
97 private:
98 using StubType = service::motion::v1::MotionService::StubInterface;
99 std::vector<Motion::plan_status_with_id> list_plan_statuses_(bool only_active_plans,
100 const ProtoStruct& extra);
101 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>> get_plan_(
102 const Name& component_name,
103 boost::optional<std::string> execution_id,
104 bool last_plan_only,
105 const ProtoStruct& extra);
106 std::unique_ptr<StubType> stub_;
107 std::shared_ptr<grpc::Channel> channel_;
108};
109
110} // namespace impl
111} // namespace sdk
112} // namespace viam
The Motion service coordinates motion planning across all components of a given robot....
Definition motion.hpp:68
pose_in_frame get_pose(const Name &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &supplemental_transforms)
Get the pose of any component on the robot.
Definition motion.hpp:317
std::string move_on_map(const pose &destination, const Name &component_name, const Name &slam_name, const std::shared_ptr< motion_configuration > &motion_configuration, const std::vector< GeometryConfig > &obstacles)
Moves any component on the robot to a specific destination on a SLAM map.
Definition motion.hpp:236
bool move(const pose_in_frame &destination, const Name &name, const std::shared_ptr< WorldState > &world_state, const std::shared_ptr< constraints > &constraints)
Moves any compononent on the robot to a specified destination.
Definition motion.hpp:209
std::string move_on_globe(const geo_point &destination, const boost::optional< double > &heading, const Name &component_name, const Name &movement_sensor_name, const std::vector< geo_geometry > &obstacles, const std::shared_ptr< motion_configuration > &motion_configuration, const std::vector< geo_geometry > &bounding_regions)
Moves any component on the robot to a specific destination on a globe.
Definition motion.hpp:271
void stop_plan(const Name &component_name)
Stop a currently executing motion plan.
Definition motion.hpp:340
plan_with_status get_plan(const Name &component_name, const std::string &execution_id)
Returns the plan and state history of the requested plan. Returns a result if the last execution is s...
Definition motion.hpp:394
std::pair< plan_with_status, std::vector< plan_with_status > > get_latest_plan_with_replan_history(Name component_name)
Returns the plan, state history, and replan history of the most recent execution to move a component....
Definition motion.hpp:374
std::pair< plan_with_status, std::vector< plan_with_status > > get_plan_with_replan_history(const Name &component_name, const std::string &execution_id)
Returns the plan, state history, and replan history of the requested plan. Returns a result if the la...
Definition motion.hpp:416
std::vector< plan_status_with_id > list_plan_statuses()
Returns the status of plans created by MoveOnGlobe requests. Includes statuses of plans that are exec...
Definition motion.hpp:436
plan_with_status get_latest_plan(const Name &component_name)
Returns the plan and state history of the most recent execution to move a component....
Definition motion.hpp:354
std::vector< plan_status_with_id > list_active_plan_statuses()
Returns the status of currently active plans created by MoveOnGlobe requests. Includes statuses of pl...
Definition motion.hpp:451
A name for specific instances of resources.
Definition resource_api.hpp:63
virtual std::string name() const
Return the resource's name.
gRPC client implementation of a Motion service.
Definition motion_client.hpp:19
pose_in_frame get_pose(const Name &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &supplemental_transforms, const ProtoStruct &extra) override
Get the pose of any component on the robot.
void stop_plan(const Name &component_name, const ProtoStruct &extra) override
Stop a currently executing motion plan.
std::vector< Motion::plan_status_with_id > list_active_plan_statuses(const ProtoStruct &extra) override
Returns the status of currently active plans created by MoveOnGlobe requests. Includes statuses of pl...
Motion::plan_with_status get_latest_plan(const Name &component_name, const ProtoStruct &extra) override
Returns the plan and state history of the most recent execution to move a component....
std::vector< Motion::plan_status_with_id > list_plan_statuses(const ProtoStruct &extra) override
Returns the status of plans created by MoveOnGlobe requests. Includes statuses of plans that are exec...
std::pair< Motion::plan_with_status, std::vector< Motion::plan_with_status > > get_plan_with_replan_history(const Name &component_name, const std::string &execution_id, const ProtoStruct &extra) override
Returns the plan, state history, and replan history of the requested plan. Returns a result if the la...
std::string move_on_map(const pose &destination, const Name &component_name, const Name &slam_name, const std::shared_ptr< motion_configuration > &motion_configuration, const std::vector< GeometryConfig > &obstacles, const ProtoStruct &extra) override
Moves any component on the robot to a specific destination on a SLAM map.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
std::pair< Motion::plan_with_status, std::vector< Motion::plan_with_status > > get_latest_plan_with_replan_history(const Name &component_name, const ProtoStruct &extra) override
Returns the plan, state history, and replan history of the most recent execution to move a component....
std::string move_on_globe(const geo_point &destination, const boost::optional< double > &heading, const Name &component_name, const Name &movement_sensor_name, const std::vector< geo_geometry > &obstacles, const std::shared_ptr< motion_configuration > &motion_configuration, const std::vector< geo_geometry > &bounding_regions, const ProtoStruct &extra) override
Moves any component on the robot to a specific destination on a globe.
bool move(const pose_in_frame &destination, const Name &component_name, const std::shared_ptr< WorldState > &world_state, const std::shared_ptr< constraints > &constraints, const ProtoStruct &extra) override
Moves any compononent on the robot to a specified destination.
Motion::plan_with_status get_plan(const Name &component_name, const std::string &execution_id, const ProtoStruct &extra) override
Returns the plan and state history of the requested plan. Returns a result if the last execution is s...
Specifies all constraints to be passed to Viam's motion planning, along with any optional parameters.
Definition motion.hpp:194
Describes a plan, its current status, and all status changes that have occurred previously on that pl...
Definition motion.hpp:154
Definition geometry.hpp:80
Defines configuration options for certain Motion APIs.
Definition motion.hpp:36
Definition pose.hpp:30
Definition pose.hpp:18