Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/viam/api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ set_target_properties(
)

target_include_directories(viamapi
SYSTEM
PUBLIC
# Unfortunately, the generated protos don't say 'viam/api' at
# the beginning so we need the subdirectory include path so the
Expand Down
2 changes: 1 addition & 1 deletion src/viam/api/api_proto_tag.lock
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.475

1,085 changes: 912 additions & 173 deletions src/viam/api/app/v1/billing.pb.cc

Large diffs are not rendered by default.

907 changes: 887 additions & 20 deletions src/viam/api/app/v1/billing.pb.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/viam/api/buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ deps:
- remote: buf.build
owner: viamrobotics
repository: api
commit: 62132a8359d946918eb4169b339a0f3a
commit: 76735db689f9436182a51cc4f94efd59
- remote: buf.build
owner: viamrobotics
repository: goutils
Expand Down
1,735 changes: 1,181 additions & 554 deletions src/viam/api/service/motion/v1/motion.pb.cc

Large diffs are not rendered by default.

2,060 changes: 1,426 additions & 634 deletions src/viam/api/service/motion/v1/motion.pb.h

Large diffs are not rendered by default.

57 changes: 31 additions & 26 deletions src/viam/sdk/services/motion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ namespace sdk {
/// @ingroup Motion
struct obstacle_detector {
/// @brief The name of the vision service to be used for obstacle detection.
Name vision_service;
std::string vision_service;

/// @brief The name of the camera component to be used for obstacle detection.
Name camera;
std::string camera;

friend bool operator==(const obstacle_detector& lhs, const obstacle_detector& rhs);
friend std::ostream& operator<<(std::ostream& os, const obstacle_detector& v);
Expand Down Expand Up @@ -102,7 +103,7 @@ class Motion : public Service {
std::string plan_id;

/// @brief The component to be moved. Used for tracking and stopping.
Name component_name;
std::string component_name;

/// @brief The unique ID which identifies the plan execution.
std::string execution_id;
Expand All @@ -126,7 +127,7 @@ class Motion : public Service {
std::string id;

/// @brief The component requested to be moved. Used for tracking and stopping.
Name component_name;
std::string component_name;

/// @brief The unique ID which identifies the execution.
/// Multiple plans can share the same execution_id if they were generated due to replanning.
Expand Down Expand Up @@ -198,7 +199,7 @@ class Motion : public Service {
/// @param constraints Constraints to apply to how the robot will move.
/// @return Whether or not the move was successful.
inline bool move(const pose_in_frame& destination,
const Name& name,
const std::string& name,
const std::shared_ptr<WorldState>& world_state,
const std::shared_ptr<constraints>& constraints) {
return move(destination, name, world_state, constraints, {});
Expand All @@ -213,7 +214,7 @@ class Motion : public Service {
/// @param extra Any additional arguments to the method.
/// @return Whether or not the move was successful.
virtual bool move(const pose_in_frame& destination,
const Name& name,
const std::string& name,
const std::shared_ptr<WorldState>& world_state,
const std::shared_ptr<constraints>& constraints,
const ProtoStruct& extra) = 0;
Expand All @@ -226,8 +227,8 @@ class Motion : public Service {
/// @return The execution ID of the move_on_map request.
inline std::string move_on_map(
const pose& destination,
const Name& component_name,
const Name& slam_name,
const std::string& component_name,
const std::string& slam_name,
const std::shared_ptr<motion_configuration>& motion_configuration,
const std::vector<GeometryConfig>& obstacles) {
return move_on_map(
Expand All @@ -243,8 +244,8 @@ class Motion : public Service {
/// @return The execution ID of the move_on_map request.
virtual std::string move_on_map(
const pose& destination,
const Name& component_name,
const Name& slam_name,
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) = 0;
Expand All @@ -262,8 +263,8 @@ class Motion : public Service {
inline 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::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) {
Expand Down Expand Up @@ -291,8 +292,8 @@ class Motion : public Service {
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::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,
Expand All @@ -306,7 +307,7 @@ class Motion : public Service {
/// needed to compute the component's pose.
/// @return The pose of the component.
inline pose_in_frame get_pose(
const Name& component_name,
const std::string& component_name,
const std::string& destination_frame,
const std::vector<WorldState::transform>& supplemental_transforms) {
return get_pose(component_name, destination_frame, supplemental_transforms, {});
Expand All @@ -321,28 +322,28 @@ class Motion : public Service {
/// @param extra Any additional arguments to the method.
/// @return The pose of the component.
virtual pose_in_frame get_pose(
const Name& component_name,
const std::string& component_name,
const std::string& destination_frame,
const std::vector<WorldState::transform>& supplemental_transforms,
const ProtoStruct& extra) = 0;

/// @brief Stop a currently executing motion plan.
/// @param component_name the component of the currently executing plan to stop.
inline void stop_plan(const Name& component_name) {
inline void stop_plan(const std::string& component_name) {
return stop_plan(component_name, {});
}

/// @brief Stop a currently executing motion plan.
/// @param component_name the component of the currently executing plan to stop.
/// @param extra Any additional arguments to the method.
virtual void stop_plan(const Name& component_name, const ProtoStruct& extra) = 0;
virtual void stop_plan(const std::string& component_name, const ProtoStruct& extra) = 0;

/// @brief Returns the plan and state history of the most recent execution to move a component.
/// Returns a result if the last execution is still executing, or changed state within the last
/// 24 hours without an intervening robot reinitialization.
/// @param component_name The name of the component which the MoveOnGlobe request asked to move.
/// @return the plan and status of the most recent execution to move the requested component
inline plan_with_status get_latest_plan(const Name& component_name) {
inline plan_with_status get_latest_plan(const std::string& component_name) {
return get_latest_plan(component_name, {});
}

Expand All @@ -352,7 +353,7 @@ class Motion : public Service {
/// @param component_name The name of the component which the MoveOnGlobe request asked to move.
/// @param extra Any additional arguments to the method.
/// @return the plan and status of the most recent execution to move the requested component
virtual plan_with_status get_latest_plan(const Name& component_name,
virtual plan_with_status get_latest_plan(const std::string& component_name,
const ProtoStruct& extra) = 0;

/// @brief Returns the plan, state history, and replan history of the most recent execution to
Expand All @@ -362,7 +363,7 @@ class Motion : public Service {
/// @return a pair of (1) the plan and status and (2) the replan history of the most recent
/// execution to move the requested component
inline std::pair<plan_with_status, std::vector<plan_with_status>>
get_latest_plan_with_replan_history(Name component_name) {
get_latest_plan_with_replan_history(const std::string& component_name) {
return get_latest_plan_with_replan_history(component_name, {});
}

Expand All @@ -374,15 +375,17 @@ class Motion : public Service {
/// @return a pair of (1) the plan and status and (2) the replan history of the most recent
/// execution to move the requested component
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;
get_latest_plan_with_replan_history(const std::string& component_name,
const ProtoStruct& extra) = 0;

/// @brief Returns the plan and state history of the requested plan. Returns a result
/// if the last execution is still executing, or changed state within the last 24 hours
/// without an intervening robot reinitialization.
/// @param component_name The name of the component which the MoveOnGlobe request asked to move.
/// @param execution_id The execution id of the requested plan.
/// @return the plan and status of the requested execution's move the requested component
inline plan_with_status get_plan(const Name& component_name, const std::string& execution_id) {
inline plan_with_status get_plan(const std::string& component_name,
const std::string& execution_id) {
return get_plan(component_name, execution_id, {});
}

Expand All @@ -393,7 +396,7 @@ class Motion : public Service {
/// @param execution_id The execution id of the requested plan.
/// @param extra Any additional arguments to the method.
/// @return the plan and status of the requested execution's move the requested component
virtual plan_with_status get_plan(const Name& component_name,
virtual plan_with_status get_plan(const std::string& component_name,
const std::string& execution_id,
const ProtoStruct& extra) = 0;

Expand All @@ -405,7 +408,7 @@ class Motion : public Service {
/// @return a pair of (1) the plan and status and (2) the replan history of the most recent
/// execution to move the requested component
inline 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 std::string& component_name, const std::string& execution_id) {
return get_plan_with_replan_history(component_name, execution_id, {});
}

Expand All @@ -418,7 +421,9 @@ class Motion : public Service {
/// @return a pair of (1) the plan and status and (2) the replan history of the most recent
/// execution to move the requested component
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;
const std::string& component_name,
const std::string& execution_id,
const ProtoStruct& extra) = 0;

/// @brief Returns the status of plans created by MoveOnGlobe requests.
/// Includes statuses of plans that are executing, or are part of an executing that changed
Expand Down
50 changes: 26 additions & 24 deletions src/viam/sdk/services/private/motion_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ using sdk::to_proto;

service::motion::v1::ObstacleDetector to_proto(const obstacle_detector& od) {
service::motion::v1::ObstacleDetector proto;
*proto.mutable_vision_service() = to_proto(od.vision_service);
*proto.mutable_camera() = to_proto(od.camera);
*proto.mutable_vision_service() = od.vision_service;
*proto.mutable_camera() = od.camera;
return proto;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ std::vector<Motion::plan_status> from_proto(
Motion::plan_status_with_id from_proto(const service::motion::v1::PlanStatusWithID& proto) {
Motion::plan_status_with_id pswi;
pswi.execution_id = proto.execution_id();
pswi.component_name = from_proto(proto.component_name());
pswi.component_name = proto.component_name();
pswi.plan_id = proto.plan_id();
pswi.status = from_proto(proto.status());

Expand All @@ -155,7 +155,7 @@ Motion::plan plan_from_proto(const service::motion::v1::Plan& proto) {
Motion::plan plan;
plan.id = proto.id();
plan.execution_id = proto.execution_id();
plan.component_name = from_proto(proto.component_name());
plan.component_name = proto.component_name();
plan.steps = steps_from_proto(proto.steps());
return plan;
}
Expand Down Expand Up @@ -184,14 +184,14 @@ MotionClient::MotionClient(std::string name, std::shared_ptr<grpc::Channel> chan
channel_(std::move(channel)) {}

bool MotionClient::move(const pose_in_frame& destination,
const Name& component_name,
const std::string& component_name,
const std::shared_ptr<WorldState>& world_state,
const std::shared_ptr<Motion::constraints>& constraints,
const ProtoStruct& extra) {
return make_client_helper(this, *stub_, &StubType::Move)
.with(extra,
[&](auto& request) {
*request.mutable_component_name() = to_proto(component_name);
*request.mutable_component_name() = component_name;
*request.mutable_destination() = to_proto(destination);
if (constraints) {
*request.mutable_constraints() = to_proto(*constraints);
Expand All @@ -205,17 +205,17 @@ bool MotionClient::move(const pose_in_frame& destination,

std::string MotionClient::move_on_map(
const pose& destination,
const Name& component_name,
const Name& slam_name,
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) {
return make_client_helper(this, *stub_, &StubType::MoveOnMap)
.with(extra,
[&](auto& request) {
*request.mutable_destination() = to_proto(destination);
*request.mutable_component_name() = to_proto(component_name);
*request.mutable_slam_service_name() = to_proto(slam_name);
*request.mutable_component_name() = component_name;
*request.mutable_slam_service_name() = slam_name;

for (const auto& obstacle : obstacles) {
*request.mutable_obstacles()->Add() = to_proto(obstacle);
Expand All @@ -231,8 +231,8 @@ std::string MotionClient::move_on_map(
std::string MotionClient::move_on_globe(
const geo_point& destination,
const boost::optional<double>& heading,
const Name& component_name,
const Name& movement_sensor_name,
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,
Expand All @@ -241,8 +241,8 @@ std::string MotionClient::move_on_globe(
.with(extra,
[&](auto& request) {
*request.mutable_destination() = to_proto(destination);
*request.mutable_component_name() = to_proto(component_name);
*request.mutable_movement_sensor_name() = to_proto(movement_sensor_name);
*request.mutable_component_name() = component_name;
*request.mutable_movement_sensor_name() = movement_sensor_name;

if (heading && !isnan(*heading)) {
request.set_heading(*heading);
Expand All @@ -260,36 +260,36 @@ std::string MotionClient::move_on_globe(
}

pose_in_frame MotionClient::get_pose(
const Name& component_name,
const std::string& component_name,
const std::string& destination_frame,
const std::vector<WorldState::transform>& supplemental_transforms,
const ProtoStruct& extra) {
return make_client_helper(this, *stub_, &StubType::GetPose)
.with(extra,
[&](auto& request) {
*request.mutable_component_name() = to_proto(component_name);
*request.mutable_component_name() = component_name;
*request.mutable_destination_frame() = destination_frame;
*request.mutable_supplemental_transforms() =
impl::to_repeated_field(supplemental_transforms);
})
.invoke([](auto& response) { return from_proto(response.pose()); });
}

void MotionClient::stop_plan(const Name& name, const ProtoStruct& extra) {
void MotionClient::stop_plan(const std::string& name, const ProtoStruct& extra) {
return make_client_helper(this, *stub_, &StubType::StopPlan)
.with(extra, [&](auto& request) { *request.mutable_component_name() = to_proto(name); })
.with(extra, [&](auto& request) { *request.mutable_component_name() = name; })
.invoke();
}

std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>> MotionClient::get_plan_(
const Name& component_name,
const std::string& component_name,
boost::optional<std::string> execution_id,
bool last_plan_only,
const ProtoStruct& extra) {
return make_client_helper(this, *stub_, &StubType::GetPlan)
.with(extra,
[&](auto& request) {
*request.mutable_component_name() = to_proto(component_name);
*request.mutable_component_name() = component_name;
request.set_last_plan_only(last_plan_only);
if (execution_id) {
*request.mutable_execution_id() = *execution_id;
Expand All @@ -302,25 +302,27 @@ std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>> Motio
});
}

Motion::plan_with_status MotionClient::get_plan(const Name& name,
Motion::plan_with_status MotionClient::get_plan(const std::string& name,
const std::string& execution_id,
const ProtoStruct& extra) {
return get_plan_(name, execution_id, true, extra).first;
}

Motion::plan_with_status MotionClient::get_latest_plan(const Name& name, const ProtoStruct& extra) {
Motion::plan_with_status MotionClient::get_latest_plan(const std::string& name,
const ProtoStruct& extra) {
return get_plan_(name, {}, true, extra).first;
}

std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
MotionClient::get_plan_with_replan_history(const Name& name,
MotionClient::get_plan_with_replan_history(const std::string& name,
const std::string& execution_id,
const ProtoStruct& extra) {
return get_plan_(name, execution_id, false, extra);
}

std::pair<Motion::plan_with_status, std::vector<Motion::plan_with_status>>
MotionClient::get_latest_plan_with_replan_history(const Name& name, const ProtoStruct& extra) {
MotionClient::get_latest_plan_with_replan_history(const std::string& name,
const ProtoStruct& extra) {
return get_plan_(name, {}, false, extra);
}

Expand Down
Loading
Loading