Skip to content
Open
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
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Moves an arm (or any movable component) between a list of named poses via the Mo
"component_name": "<string>",
"motion": "<string>",
"reference_frame": "<string>",
"linear_constraint": {
"line_tolerance_mm": <float>,
"orientation_tolerance_degs": <float>
},
"poses": [
{
"pose_name": "<string>",
Expand All @@ -31,22 +35,34 @@ Moves an arm (or any movable component) between a list of named poses via the Mo
}
```

| Name | Type | Required | Description |
| ----------------- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `component_name` | string | Yes | Name of the arm component to move. |
| `motion` | string | Yes | Name of the motion service (typically `"builtin"`). |
| `reference_frame` | string | No | Reference frame for poses. Defaults to `"world"`. |
| `poses` | array | Yes | One or more named poses. Each pose needs a `pose_name` and position/orientation fields. |
| Name | Type | Required | Description |
| ------------------- | ------ | -------- | --------------------------------------------------------------------------------------- |
| `component_name` | string | Yes | Name of the arm component to move. |
| `motion` | string | Yes | Name of the motion service (typically `"builtin"`). |
| `reference_frame` | string | No | Reference frame for poses. Defaults to `"world"`. |
| `linear_constraint` | object | No | When set, forces the arm to move in a straight line between poses. |
| `poses` | array | Yes | One or more named poses. Each pose needs a `pose_name` and position/orientation fields. |

**Pose fields:** `x`, `y`, `z` are in millimeters. `o_x`, `o_y`, `o_z` define the orientation axis, `theta_degrees` is the rotation angle in degrees.

**Linear constraint fields:**

| Name | Type | Description |
| --------------------------- | ----- | ------------------------------------------------------------------------ |
| `line_tolerance_mm` | float | Max deviation from the straight-line path between start and goal, in mm. |
| `orientation_tolerance_degs` | float | Max orientation deviation allowed during the movement, in degrees. |

### Example Configuration

```json
{
"component_name": "my-arm",
"motion": "builtin",
"reference_frame": "world",
"linear_constraint": {
"line_tolerance_mm": 1,
"orientation_tolerance_degs": 2
},
"poses": [
{
"pose_name": "home",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.25.1
require (
github.com/golang/geo v0.0.0-20230421003525-6adc56603217
go.viam.com/rdk v0.115.0
go.viam.com/utils v0.4.3
)

require (
Expand Down Expand Up @@ -173,7 +174,6 @@ require (
go.uber.org/zap v1.27.0 // indirect
go.viam.com/api v0.1.519 // indirect
go.viam.com/test v1.2.4 // indirect
go.viam.com/utils v0.4.3 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/exp v0.0.0-20251113190631-e25ba8c21ef6 // indirect
Expand Down
31 changes: 25 additions & 6 deletions multiposesexecutionswitch/multiposesexecutionswitch.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"go.viam.com/rdk/logging"
"go.viam.com/rdk/referenceframe"
"go.viam.com/rdk/resource"
"go.viam.com/rdk/motionplan"
"go.viam.com/rdk/services/motion"
"go.viam.com/rdk/spatialmath"
)
Expand All @@ -30,10 +31,16 @@ func init() {
}

type Config struct {
ReferenceFrame string `json:"reference_frame"`
ComponentName string `json:"component_name"`
Motion string `json:"motion"`
Poses []PoseConf `json:"poses"`
ReferenceFrame string `json:"reference_frame"`
ComponentName string `json:"component_name"`
Motion string `json:"motion"`
Poses []PoseConf `json:"poses"`
LinearConstraint *LinearConstraintConf `json:"linear_constraint,omitempty"`
}

type LinearConstraintConf struct {
LineToleranceMm float64 `json:"line_tolerance_mm"`
OrientationToleranceDegs float64 `json:"orientation_tolerance_degs"`
}

type PoseConf struct {
Expand Down Expand Up @@ -176,10 +183,22 @@ func (s *multiPosesExecutionSwitch) goToPosition(ctx context.Context, position u
)
destination := referenceframe.NewPoseInFrame(s.cfg.ReferenceFrame, pose)

_, err := s.motion.Move(ctx, motion.MoveReq{
moveReq := motion.MoveReq{
ComponentName: s.cfg.ComponentName,
Destination: destination,
})
}
if s.cfg.LinearConstraint != nil {
moveReq.Constraints = &motionplan.Constraints{
LinearConstraint: []motionplan.LinearConstraint{
{
LineToleranceMm: s.cfg.LinearConstraint.LineToleranceMm,
OrientationToleranceDegs: s.cfg.LinearConstraint.OrientationToleranceDegs,
},
},
}
}

_, err := s.motion.Move(ctx, moveReq)
if err != nil {
return fmt.Errorf("failed to move to pose %q: %w", pc.PoseName, err)
}
Expand Down