8#include <viam/sdk/common/pose.hpp>
9#include <viam/sdk/common/proto_value.hpp>
10#include <viam/sdk/common/utils.hpp>
11#include <viam/sdk/common/world_state.hpp>
12#include <viam/sdk/resource/resource_api.hpp>
13#include <viam/sdk/services/service.hpp>
14#include <viam/sdk/spatialmath/geometry.hpp>
88 std::chrono::time_point<long long, std::chrono::nanoseconds>
timestamp;
122 typedef std::unordered_map<std::string, pose>
step;
127 friend bool operator==(
const struct steps& lhs,
const struct steps& rhs);
147 friend bool operator==(
const plan& lhs,
const plan& rhs);
170 float line_tolerance_mm;
171 float orientation_tolerance_degs;
178 float orientation_tolerance_degs;
188 std::vector<allowed_frame_collisions> allows;
195 std::vector<linear_constraint> linear_constraints;
196 std::vector<orientation_constraint> orientation_constraints;
197 std::vector<collision_specification> collision_specifications;
211 const std::shared_ptr<WorldState>& world_state,
226 const std::shared_ptr<WorldState>& world_state,
228 const ProtoStruct& extra) = 0;
237 const pose& destination,
238 const Name& component_name,
239 const Name& slam_name,
241 const std::vector<GeometryConfig>& obstacles) {
254 const pose& destination,
255 const Name& component_name,
256 const Name& slam_name,
258 const std::vector<GeometryConfig>& obstacles,
259 const ProtoStruct& extra) = 0;
273 const boost::optional<double>& heading,
274 const Name& component_name,
275 const Name& movement_sensor_name,
276 const std::vector<geo_geometry>& obstacles,
278 const std::vector<geo_geometry>& bounding_regions) {
282 movement_sensor_name,
302 const boost::optional<double>& heading,
303 const Name& component_name,
304 const Name& movement_sensor_name,
305 const std::vector<geo_geometry>& obstacles,
307 const std::vector<geo_geometry>& bounding_regions,
308 const ProtoStruct& extra) = 0;
318 const Name& component_name,
319 const std::string& destination_frame,
320 const std::vector<WorldState::transform>& supplemental_transforms) {
321 return get_pose(component_name, destination_frame, supplemental_transforms, {});
333 const Name& component_name,
334 const std::string& destination_frame,
335 const std::vector<WorldState::transform>& supplemental_transforms,
336 const ProtoStruct& extra) = 0;
347 virtual void stop_plan(
const Name& component_name,
const ProtoStruct& extra) = 0;
365 const ProtoStruct& extra) = 0;
373 inline std::pair<plan_with_status, std::vector<plan_with_status>>
385 virtual std::pair<plan_with_status, std::vector<plan_with_status>>
395 return get_plan(component_name, execution_id, {});
406 const std::string& execution_id,
407 const ProtoStruct& extra) = 0;
417 const Name& component_name,
const std::string& execution_id) {
430 const Name& component_name,
const std::string& execution_id,
const ProtoStruct& extra) = 0;
461 const ProtoStruct& extra) = 0;
466 virtual ProtoStruct
do_command(
const ProtoStruct& command) = 0;
Extends APIType to additionally define a resource's subtype (e.g., camera).
Definition resource_api.hpp:33
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
API api() const override
Returns the API associated with a particular resource.
virtual std::vector< plan_status_with_id > list_plan_statuses(const ProtoStruct &extra)=0
Returns the status of plans created by MoveOnGlobe requests. Includes statuses of plans that are exec...
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
virtual std::pair< plan_with_status, std::vector< plan_with_status > > get_plan_with_replan_history(const Name &component_name, const std::string &execution_id, const ProtoStruct &extra)=0
Returns the plan, state history, and replan history of the requested plan. Returns a result if the la...
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
virtual plan_with_status get_plan(const Name &component_name, const std::string &execution_id, const ProtoStruct &extra)=0
Returns the plan and state history of the requested plan. Returns a result if the last execution is s...
virtual pose_in_frame get_pose(const Name &component_name, const std::string &destination_frame, const std::vector< WorldState::transform > &supplemental_transforms, const ProtoStruct &extra)=0
Get the pose of any component on the robot.
plan_state
Describes the possible states a plan can be in.
Definition motion.hpp:73
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
virtual 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)=0
Moves any component on the robot to a specific destination on a SLAM map.
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
virtual std::vector< plan_status_with_id > list_active_plan_statuses(const ProtoStruct &extra)=0
Returns the status of currently active plans created by MoveOnGlobe requests. Includes statuses of pl...
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
virtual void stop_plan(const Name &component_name, const ProtoStruct &extra)=0
Stop a currently executing motion plan.
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
virtual std::pair< plan_with_status, std::vector< plan_with_status > > get_latest_plan_with_replan_history(const Name &component_name, const ProtoStruct &extra)=0
Returns the plan, state history, and replan history of the most recent execution to move a component....
virtual ProtoStruct do_command(const ProtoStruct &command)=0
Send/receive arbitrary commands to the resource.
virtual plan_with_status get_latest_plan(const Name &component_name, const ProtoStruct &extra)=0
Returns the plan and state history of the most recent execution to move a component....
virtual bool move(const pose_in_frame &destination, const Name &name, const std::shared_ptr< WorldState > &world_state, const std::shared_ptr< constraints > &constraints, const ProtoStruct &extra)=0
Moves any compononent on the robot to a specified destination.
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
virtual 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)=0
Moves any component on the robot to a specific destination on a globe.
A name for specific instances of resources.
Definition resource_api.hpp:63
virtual std::string name() const
Return the resource's name.
Definition service.hpp:10
Definition resource_api.hpp:50
Definition motion.hpp:184
used to selectively apply obstacle avoidance to specific parts of the robot.
Definition motion.hpp:183
Specifies all constraints to be passed to Viam's motion planning, along with any optional parameters.
Definition motion.hpp:194
Specifies that the component being moved should move linearly to its goal.
Definition motion.hpp:169
Specifies that the component being moved will not deviate its orientation beyond the specified thresh...
Definition motion.hpp:177
The motion plan status, plus plan ID, component name, and execution ID.
Definition motion.hpp:100
plan_status status
The plan status.
Definition motion.hpp:111
Name component_name
The component to be moved. Used for tracking and stopping.
Definition motion.hpp:105
std::string execution_id
The unique ID which identifies the plan execution.
Definition motion.hpp:108
std::string plan_id
The unique ID of the plan.
Definition motion.hpp:102
Describes the state of a given plan at a point in time.
Definition motion.hpp:83
plan_state state
The state of the plan execution.
Definition motion.hpp:85
std::chrono::time_point< long long, std::chrono::nanoseconds > timestamp
The time the executing plan transitioned to the state.
Definition motion.hpp:88
boost::optional< std::string > reason
The reason for the state change. The error message if the plan failed, or the re-plan reason if re-pl...
Definition motion.hpp:92
Describes a plan, its current status, and all status changes that have occurred previously on that pl...
Definition motion.hpp:154
plan_status status
The current status of the plan.
Definition motion.hpp:159
std::vector< plan_status > status_history
The prior status changes that have happened during plan execution.
Definition motion.hpp:162
Describes a motion plan.
Definition motion.hpp:133
Name component_name
The component requested to be moved. Used for tracking and stopping.
Definition motion.hpp:138
std::string id
The plan's unique ID.
Definition motion.hpp:135
std::string execution_id
The unique ID which identifies the execution. Multiple plans can share the same execution_id if they ...
Definition motion.hpp:142
An ordered list of plan steps.
Definition motion.hpp:119
std::vector< step > steps
The ordered list of steps.
Definition motion.hpp:125
std::unordered_map< std::string, pose > step
An individual "step", representing the state each component (keyed as a fully qualified component nam...
Definition motion.hpp:122
Definition geometry.hpp:80
Defines configuration options for certain Motion APIs.
Definition motion.hpp:36
boost::optional< double > angular_degs_per_sec
Optional angular velocity to target when turning.
Definition motion.hpp:53
std::vector< obstacle_detector > obstacle_detectors
The obstacle detectors to be used for the API call.
Definition motion.hpp:38
boost::optional< double > linear_m_per_sec
Optional linear velocity to target when moving.
Definition motion.hpp:50
boost::optional< double > position_polling_frequency_hz
If not null, sets the frequency to poll for the position of the robot.
Definition motion.hpp:41
boost::optional< double > plan_deviation_m
Optional distance in meters a robot is allowed to deviate from the motion plan.
Definition motion.hpp:47
boost::optional< double > obstacle_polling_frequency_hz
If not null, sets the frequency to poll the vision service(s) for new obstacles.
Definition motion.hpp:44
Name camera
The name of the camera component to be used for obstacle detection.
Definition motion.hpp:27
Name vision_service
The name of the vision service to be used for obstacle detection.
Definition motion.hpp:25