Viam C++ SDK current
Loading...
Searching...
No Matches
motion_client.hpp
1
4#pragma once
5
6#include <viam/api/service/motion/v1/motion.grpc.pb.h>
7
8#include <viam/sdk/rpc/dial.hpp>
9#include <viam/sdk/services/motion.hpp>
10
11namespace viam {
12namespace sdk {
13namespace impl {
14
18class MotionClient : public Motion {
19 public:
20 using interface_type = Motion;
21 MotionClient(std::string name, const ViamChannel& channel);
22
23 const ViamChannel& channel() const {
24 return *channel_;
25 }
26
27 bool move(const pose_in_frame& destination,
28 const std::string& component_name,
29 const std::shared_ptr<WorldState>& world_state,
30 const std::shared_ptr<constraints>& constraints,
31 const ProtoStruct& extra) override;
32
33 std::string move_on_map(const pose& destination,
34 const std::string& component_name,
35 const std::string& slam_name,
36 const std::shared_ptr<motion_configuration>& motion_configuration,
37 const std::vector<GeometryConfig>& obstacles,
38 const ProtoStruct& extra) override;
39
40 std::string move_on_globe(const geo_point& destination,
41 const boost::optional<double>& heading,
42 const std::string& component_name,
43 const std::string& movement_sensor_name,
44 const std::vector<geo_geometry>& obstacles,
45 const std::shared_ptr<motion_configuration>& motion_configuration,
46 const std::vector<geo_geometry>& bounding_regions,
47 const ProtoStruct& extra) override;
48
49 pose_in_frame get_pose(const std::string& component_name,
50 const std::string& destination_frame,
51 const std::vector<WorldState::transform>& supplemental_transforms,
52 const ProtoStruct& extra) override;
53
54 void stop_plan(const std::string& component_name, const ProtoStruct& extra) override;
55
56 Motion::plan_with_status get_latest_plan(const std::string& component_name,
57 const ProtoStruct& extra) override;
58
59 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
60
61 get_latest_plan_with_replan_history(const std::string& component_name,
62 const ProtoStruct& extra) override;
63
64 Motion::plan_with_status get_plan(const std::string& component_name,
65 const std::string& execution_id,
66 const ProtoStruct& extra) override;
67
68 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
69 get_plan_with_replan_history(const std::string& component_name,
70 const std::string& execution_id,
71 const ProtoStruct& extra) override;
72
73 std::vector<Motion::plan_status_with_id> list_active_plan_statuses(
74 const ProtoStruct& extra) override;
75
76 std::vector<Motion::plan_status_with_id> list_plan_statuses(const ProtoStruct& extra) override;
77
78 ProtoStruct do_command(const ProtoStruct& command) override;
79
80 // the `extra` param is frequently unnecessary but needs to be supported. Ideally, we'd
81 // like to live in a world where implementers of derived classes don't need to go out of
82 // their way to support two versions of a method (an `extra` version and a non-`extra`
83 // version), and users don't need to pass an unnecessary parameters to all method calls.
84 //
85 // To do this, we define in the parent resource class a non-virtual version of the methods
86 // that calls the virtual method and passes a `nullptr` by default in place of the `extra`
87 // param. In order to access these versions of the methods within the client code, however,
88 // we need to include these `using` lines.
91 using Motion::get_plan;
93 using Motion::get_pose;
96 using Motion::move;
100
101 private:
102 using StubType = service::motion::v1::MotionService::StubInterface;
103 std::vector<Motion::plan_status_with_id> list_plan_statuses_(bool only_active_plans,
104 const ProtoStruct& extra);
105 std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>> get_plan_(
106 const std::string& component_name,
107 boost::optional<std::string> execution_id,
108 bool last_plan_only,
109 const ProtoStruct& extra);
110 std::unique_ptr<StubType> stub_;
111 const ViamChannel* channel_;
112};
113
114} // namespace impl
115} // namespace sdk
116} // namespace viam
The Motion service coordinates motion planning across all components of a given robot....
Definition motion.hpp:69
std::pair< plan_with_status, std::vector< plan_with_status > > get_latest_plan_with_replan_history(const std::string &component_name)
Returns the plan, state history, and replan history of the most recent execution to move a component....
Definition motion.hpp:366
pose_in_frame get_pose(const std::string &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:309
void stop_plan(const std::string &component_name)
Stop a currently executing motion plan.
Definition motion.hpp:332
std::string move_on_globe(const geo_point &destination, const boost::optional< double > &heading, const std::string &component_name, const std::string &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:263
std::pair< plan_with_status, std::vector< plan_with_status > > get_plan_with_replan_history(const std::string &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:410
plan_with_status get_latest_plan(const std::string &component_name)
Returns the plan and state history of the most recent execution to move a component....
Definition motion.hpp:346
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:432
bool move(const pose_in_frame &destination, const std::string &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:201
plan_with_status get_plan(const std::string &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:387
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:447
std::string move_on_map(const pose &destination, const std::string &component_name, const std::string &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:228
virtual std::string name() const
Return the resource's name.
Definition dial.hpp:25
gRPC client implementation of a Motion service.
Definition motion_client.hpp:18
bool move(const pose_in_frame &destination, const std::string &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.
std::pair< Motion::plan_with_status, std::vector< Motion::plan_with_status > > get_latest_plan_with_replan_history(const std::string &component_name, const ProtoStruct &extra) override
Returns the plan, state history, and replan history of the most recent execution to move a component....
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...
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::string move_on_globe(const geo_point &destination, const boost::optional< double > &heading, const std::string &component_name, const std::string &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.
Motion::plan_with_status get_latest_plan(const std::string &component_name, const ProtoStruct &extra) override
Returns the plan and state history of the most recent execution to move a component....
pose_in_frame get_pose(const std::string &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.
ProtoStruct do_command(const ProtoStruct &command) override
Send/receive arbitrary commands to the resource.
std::string move_on_map(const pose &destination, const std::string &component_name, const std::string &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.
void stop_plan(const std::string &component_name, const ProtoStruct &extra) override
Stop a currently executing motion plan.
std::pair< Motion::plan_with_status, std::vector< Motion::plan_with_status > > get_plan_with_replan_history(const std::string &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...
Motion::plan_with_status get_plan(const std::string &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:186
Describes a plan, its current status, and all status changes that have occurred previously on that pl...
Definition motion.hpp:146
Definition geometry.hpp:79
Defines configuration options for certain Motion APIs.
Definition motion.hpp:37
Definition pose.hpp:39
Definition pose.hpp:30