Skip to main content

Motion Planner Service Client

The MotionPlannerClient is the recommended interface to interact with the MotionPlannerService. There are two implementations of the MotionPlannerClient.

As a skill developer

Skill developers can get access to an instance of the MotionPlannerClient through either the ExecuteContext or the PreviewContext. The client C++, Python offers five APIs

  • PlanTrajectory: Plans a trajectory for a given motion planning problem and robot.
  • ComputeIK: Computes inverse kinematics.
  • ComputeFK: Computes forward kinematics.
  • CheckCollisions: Checks collisions for a given path.
  • ClearCache: Clears the PlanTrajectory cache.

The following snippet shows an example of using the PlanTrajectory API in the Predict method of a skill MyMoveRobot.

absl::StatusOr<intrinsic_proto::skills::PredictResult> MyMoveRobot::Predict(
const PredictRequest& request, PredictContext& context) const {
INTR_ASSIGN_OR_RETURN(
auto params,
request.params<intrinsic_proto::skills::MyMoveRobotParams>());

INTR_ASSIGN_OR_RETURN(
MotionPlannerClient::PlanTrajectoryResult trajectory,
context.motion_planner().PlanTrajectory(
params.robot_specification(), params.motion_specification(),
params.planning_options, "skills.MyMoveRobot/Predict", context));
}

As a process developer

Process developers can construct a MotionPlannerClient using the Solution Building Library. Process developer currently have only access to one API call: ClearCache. The following snippet shows an example of constructing a MotionPlannerClient and clear the PlanTrajectory cache with it.

from intrinsic.solutions import deployments
from intrinsic.solutions.motion_planning import motion_planner_client
from intrinsic.solutions.motion_planning import motion_planner_service_pb2_grpc

# Connect a running application
solution = deployments.connect_to_selected_solution()
# Construct a MotionPlannerClient
stub = motion_planner_service_pb2_grpc.MotionPlannerServiceStub(solution.grpc_channel)
client = motion_planner_client.MotionPlannerClient(solution.world.world_id, stub)
# Clear the cache
client.clear_cache()