Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-5391 - Create distinct planning and execution frames for PTG KinematicWrapper #3876

Open
wants to merge 96 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
247d4d1
initial add planning and execution frames for bases commit
nfranczak Apr 1, 2024
652ddcc
continue with solverFrame - not the best idea
nfranczak Apr 2, 2024
685d518
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 5, 2024
de3189d
merge with main:
nfranczak Apr 5, 2024
413cfa3
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 5, 2024
14fc7fe
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 9, 2024
2aab600
initial commit - rework move_req to rely on fs for placing obstacles
nfranczak Apr 9, 2024
6a49f8a
have fs place objects into worldframe within getTransientDetections
nfranczak Apr 10, 2024
aa98dea
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 17, 2024
ff9e945
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 19, 2024
44b3287
clean up + note about how to interpolate
nfranczak Apr 19, 2024
cde23a6
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Apr 30, 2024
ba2be7d
remove '&' from orientation printout when doing plan.Path.String()
nfranczak Apr 30, 2024
526b14d
add ExecutionFrame function impl + correct references to transforming…
nfranczak May 1, 2024
656d154
simplify how we create robot collision entities to only use frameInpu…
nfranczak May 1, 2024
09c27a8
fulfill placing obstacles into the world frame using only the newly i…
nfranczak May 1, 2024
662ef08
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 1, 2024
a8eca26
clean up remove print statements
nfranczak May 1, 2024
61d8fc1
clean up remove print statements
nfranczak May 1, 2024
5bc3a0a
clean up remove print statements
nfranczak May 1, 2024
7c07b15
remove print stmts
nfranczak May 1, 2024
7185d6e
remove note - clean up
nfranczak May 1, 2024
d454d21
logic complete-ish, sans tests
nfranczak May 1, 2024
5e39ce8
fix segment logic
nfranczak May 1, 2024
db3ca28
correct plannerSetUp inputs
nfranczak May 1, 2024
d8ab4ce
lint + revert tpspace test - not finished yet
nfranczak May 1, 2024
6917eb9
revert test file while updating TestGetTransientDetections
nfranczak May 1, 2024
7e25a8d
motion builtin-tests are passinggit statusgit status lets gooooooooo
nfranczak May 2, 2024
ce18c03
remove un-needed code commented out code
nfranczak May 2, 2024
dfeec43
clean some print statements
nfranczak May 3, 2024
ce5a122
remove un-needed changes
nfranczak May 3, 2024
1d18bb5
clean prints - TestPtgCheckPlan WIP
nfranczak May 3, 2024
2570e15
tpspace rrt test testptgcheckplan passes
nfranczak May 3, 2024
4b42874
tpspace rrt test testptgcheckplan passes
nfranczak May 3, 2024
a4d816f
linted
nfranczak May 3, 2024
0aa7c7f
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 3, 2024
fff9cf6
singlar bone of AddFrameBetween + revert messages.go since we are not…
nfranczak May 3, 2024
074cfbb
wip change to pass lint
nfranczak May 3, 2024
c745c4b
fix ptgkinematics no geom tests + add AddFrameBetween
nfranczak May 3, 2024
a21cc99
fix TestMoveOnMapStaticObs
nfranczak May 6, 2024
c064634
linted
nfranczak May 6, 2024
e91f0a9
add debug log to see where this test is failing on CI
nfranczak May 6, 2024
ac7d32a
remove print so we pass linter
nfranczak May 6, 2024
5bb3375
remove need to check for 'ExecutionFrame' in solverFrame code
nfranczak May 8, 2024
716f095
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 8, 2024
eb5a38a
fix CheckPlan
nfranczak May 8, 2024
d7e1a6b
sans fmt.Println in frame.go
nfranczak May 8, 2024
9b0405d
remove un-needed changes
nfranczak May 9, 2024
923f362
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 9, 2024
c197731
post merge + fixing checkPlanRelative functionality that was lost upo…
nfranczak May 10, 2024
01b7d93
fixed TestPtgCheckPlan and accompanying relative plan checking code
nfranczak May 13, 2024
eaf8ffc
fix test TestMoveOnMapStaticObs + move request set up nits for feedin…
nfranczak May 13, 2024
7f7e4c6
move request nits + feed in proper framesystem for checking of plan
nfranczak May 13, 2024
02fe62f
changes from linter
nfranczak May 13, 2024
c3569dd
nits
nfranczak May 13, 2024
1344a84
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 13, 2024
b6aac16
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 14, 2024
4f68a9f
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 14, 2024
cfa4aea
fix explore err string check
nfranczak May 17, 2024
c6c995c
remove prints
nfranczak May 17, 2024
21cdb8e
add back space
nfranczak May 17, 2024
40d4a77
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 17, 2024
43f910d
re-root FS in plan-manager
nfranczak May 20, 2024
dbf6c19
replace ExecutionFrame with LocalizationFrame
nfranczak May 21, 2024
ce50772
introduce Simple6DModel
nfranczak May 21, 2024
ddbde4d
migrate simple6Dmodel to be a 7D model
nfranczak May 21, 2024
d39e5d8
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 21, 2024
1d99d0c
change functionaluty of bases to use 7Dof frame - partway through pro…
nfranczak May 21, 2024
29af1f5
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 23, 2024
8118206
battle-testing use of 7DoF frame for checking plan - tests still failing
nfranczak May 23, 2024
21c8a4f
tests passing for 7DoF frame
nfranczak May 23, 2024
f149090
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak May 23, 2024
a3e1ee2
over-write inputs to correct first place frame but have original info…
nfranczak May 24, 2024
6a3a794
overwrite inputs for placing detection properly
nfranczak May 24, 2024
668a27a
rays comments sans interpolateInputs requested change
nfranczak May 28, 2024
7648907
hoppefully fixed TestObstacleReplanningGlobe
nfranczak May 28, 2024
5004e4c
fix TestPtgCheckPlan
nfranczak May 28, 2024
3f2df50
move anyNonZero check from solverFrame into planManager, as it was or…
nfranczak Jun 5, 2024
ec18e95
add localizationFrame as argument to CheckPlan + update tests
nfranczak Jun 5, 2024
3e186d9
add missing arguments to test files
nfranczak Jun 5, 2024
34f5269
add comment
nfranczak Jun 6, 2024
9d6dbe7
add back state.Position case in switch stmt for NewCollisionConstraint
nfranczak Jun 6, 2024
24c7349
add comment to fake_kinematics about why we have chosen the given lim…
nfranczak Jun 6, 2024
03ed80a
remove comment
nfranczak Jun 6, 2024
3978b66
update poseFrame interpolate method to use spatial.Interpolate
nfranczak Jun 6, 2024
56636f4
update testptgcheckplan to have correct starting inputs
nfranczak Jun 6, 2024
ba682e7
debugging TestObstacleReplanningGlobe
nfranczak Jun 7, 2024
7afc8ed
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Jun 7, 2024
ee14bf1
fixed TestObstacleReplanningGlobe
nfranczak Jun 7, 2024
9864457
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Jun 12, 2024
f43114d
rename absoluteFS to localizingFS
nfranczak Jun 12, 2024
34352cd
update naming
nfranczak Jun 12, 2024
59481af
Merge branch 'main' of github.com:viamrobotics/rdk into RSDK-5391
nfranczak Jun 14, 2024
d4e1c11
generate seed map with all input-enabled components
nfranczak Jun 17, 2024
3fc360b
use zeroth index of plan to construct our zeroCG
nfranczak Jun 17, 2024
3409b40
noramlize the orientation vector limits when set to infinity
nfranczak Jun 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 14 additions & 10 deletions components/base/kinematicbase/differentialDrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func wrapWithDifferentialDriveKinematics(
}
}

ddk.executionFrame, err = referenceframe.New2DMobileModelFrame(b.Name().ShortName(), limits, boundingSphere)
ddk.localizationFrame, err = referenceframe.New2DMobileModelFrame(b.Name().ShortName(), limits, boundingSphere)
if err != nil {
return nil, err
}
Expand All @@ -89,7 +89,7 @@ func wrapWithDifferentialDriveKinematics(
return nil, err
}
} else {
ddk.planningFrame = ddk.executionFrame
ddk.planningFrame = ddk.localizationFrame
}

ddk.noLocalizerCacheInputs = originInputs
Expand All @@ -99,19 +99,23 @@ func wrapWithDifferentialDriveKinematics(
type differentialDriveKinematics struct {
base.Base
motion.Localizer
logger logging.Logger
planningFrame, executionFrame referenceframe.Model
options Options
noLocalizerCacheInputs []referenceframe.Input
currentTrajectory [][]referenceframe.Input
currentIdx int
mutex sync.RWMutex
logger logging.Logger
planningFrame, localizationFrame referenceframe.Frame
options Options
noLocalizerCacheInputs []referenceframe.Input
currentTrajectory [][]referenceframe.Input
currentIdx int
mutex sync.RWMutex
}

func (ddk *differentialDriveKinematics) Kinematics() referenceframe.Frame {
return ddk.planningFrame
}

func (ddk *differentialDriveKinematics) LocalizationFrame() referenceframe.Frame {
return ddk.localizationFrame
}

func (ddk *differentialDriveKinematics) CurrentInputs(ctx context.Context) ([]referenceframe.Input, error) {
// If no localizer is present, CurrentInputs returns the expected position of the robot assuming after
// each part of move command was completed accurately.
Expand Down Expand Up @@ -310,7 +314,7 @@ func (ddk *differentialDriveKinematics) inputDiff(current, desired []referencefr
)

// transform the goal pose such that it is in the base frame
currentPose, err := ddk.executionFrame.Transform(current)
currentPose, err := ddk.localizationFrame.Transform(current)
if err != nil {
return 0, 0, err
}
Expand Down
4 changes: 2 additions & 2 deletions components/base/kinematicbase/differentialDrive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ func TestWrapWithDifferentialDriveKinematics(t *testing.T) {
if err != nil {
return
}
limits := ddk.executionFrame.DoF()
limits := ddk.localizationFrame.DoF()
test.That(t, limits[0].Min, test.ShouldBeLessThan, 0)
test.That(t, limits[1].Min, test.ShouldBeLessThan, 0)
test.That(t, limits[0].Max, test.ShouldBeGreaterThan, 0)
test.That(t, limits[1].Max, test.ShouldBeGreaterThan, 0)
geometry, err := ddk.executionFrame.(*referenceframe.SimpleModel).Geometries(make([]referenceframe.Input, len(limits)))
geometry, err := ddk.localizationFrame.(*referenceframe.SimpleModel).Geometries(make([]referenceframe.Input, len(limits)))
test.That(t, err, test.ShouldBeNil)
equivalent := spatialmath.GeometriesAlmostEqual(
geometry.GeometryByName(testCfg.Name+":"+testCfg.Frame.Geometry.Label),
Expand Down
2 changes: 1 addition & 1 deletion components/base/kinematicbase/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func (ptgk *ptgBaseKinematics) courseCorrect(
return nil, err
}
// trajPose is the pose we should have nominally reached along the currently executing arc from the start position.
trajPose, err := ptgk.frame.Transform(currentInputs)
trajPose, err := ptgk.Kinematics().Transform(currentInputs)
if err != nil {
return nil, err
}
Expand Down
122 changes: 78 additions & 44 deletions components/base/kinematicbase/fake_kinematics.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package kinematicbase
import (
"context"
"errors"
"math"
"sync"
"time"

Expand All @@ -20,12 +21,12 @@ import (

type fakeDiffDriveKinematics struct {
*fake.Base
parentFrame string
planningFrame, executionFrame referenceframe.Frame
inputs []referenceframe.Input
options Options
sensorNoise spatialmath.Pose
lock sync.RWMutex
parentFrame string
planningFrame, localizationFrame referenceframe.Frame
inputs []referenceframe.Input
options Options
sensorNoise spatialmath.Pose
lock sync.RWMutex
}

// WrapWithFakeDiffDriveKinematics creates a DiffDrive KinematicBase from the fake Base so that it satisfies the ModelFramer and
Expand Down Expand Up @@ -57,7 +58,7 @@ func WrapWithFakeDiffDriveKinematics(
geometry = fk.Base.Geometry[0]
}

fk.executionFrame, err = referenceframe.New2DMobileModelFrame(b.Name().ShortName(), limits, geometry)
fk.localizationFrame, err = referenceframe.New2DMobileModelFrame(b.Name().ShortName(), limits, geometry)
if err != nil {
return nil, err
}
Expand All @@ -68,7 +69,7 @@ func WrapWithFakeDiffDriveKinematics(
return nil, err
}
} else {
fk.planningFrame = fk.executionFrame
fk.planningFrame = fk.localizationFrame
}

fk.options = options
Expand All @@ -79,6 +80,10 @@ func (fk *fakeDiffDriveKinematics) Kinematics() referenceframe.Frame {
return fk.planningFrame
}

func (fk *fakeDiffDriveKinematics) LocalizationFrame() referenceframe.Frame {
return fk.localizationFrame
}

func (fk *fakeDiffDriveKinematics) CurrentInputs(ctx context.Context) ([]referenceframe.Input, error) {
fk.lock.RLock()
defer fk.lock.RUnlock()
Expand Down Expand Up @@ -122,19 +127,19 @@ func (fk *fakeDiffDriveKinematics) CurrentPosition(ctx context.Context) (*refere

type fakePTGKinematics struct {
*fake.Base
localizer motion.Localizer
frame referenceframe.Frame
options Options
sensorNoise spatialmath.Pose
ptgs []tpspace.PTGSolver
currentInput []referenceframe.Input
currentIndex int
plan motionplan.Plan
origin *referenceframe.PoseInFrame
positionlock sync.RWMutex
inputLock sync.RWMutex
logger logging.Logger
sleepTime int
localizer motion.Localizer
planningFrame, localizationFrame referenceframe.Frame
options Options
sensorNoise spatialmath.Pose
ptgs []tpspace.PTGSolver
currentInput []referenceframe.Input
currentIndex int
plan motionplan.Plan
origin *referenceframe.PoseInFrame
positionlock sync.RWMutex
inputLock sync.RWMutex
logger logging.Logger
sleepTime int
}

// WrapWithFakePTGKinematics creates a PTG KinematicBase from the fake Base so that it satisfies the ModelFramer and InputEnabled
Expand Down Expand Up @@ -180,7 +185,8 @@ func WrapWithFakePTGKinematics(

nonzeroBaseTurningRadiusMeters := (baseMillimetersPerSecond / rdkutils.DegToRad(angVelocityDegsPerSecond)) / 1000.

frame, err := tpspace.NewPTGFrameFromKinematicOptions(
// construct planning frame
planningFrame, err := tpspace.NewPTGFrameFromKinematicOptions(
b.Name().ShortName(),
logger,
nonzeroBaseTurningRadiusMeters,
Expand All @@ -193,30 +199,54 @@ func WrapWithFakePTGKinematics(
return nil, err
}

// construct localization frame
localizationFrame, err := referenceframe.NewPoseFrame(
b.Name().ShortName()+"LocalizationFrame",
[]referenceframe.Limit{
{Min: math.Inf(-1), Max: math.Inf(1)},
{Min: math.Inf(-1), Max: math.Inf(1)},
{Min: math.Inf(-1), Max: math.Inf(1)},
// we intentionally set our OX, OY, OZ values to be greater than 1 since
// a possible orientation which a planner produces may have the following
// values: OZ: 1.0000000002, Theta: t.
{Min: -1.5, Max: 1.5},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if all of these should be +/- infinity, and then normalized to a unit vector and +/- pi. That makes mildly more sense to me than having a buffer of 0.5.

{Min: -1.5, Max: 1.5},
{Min: -1.5, Max: 1.5},
{Min: -2 * math.Pi, Max: 2 * math.Pi},
},
nil,
)
if err != nil {
return nil, err
}

if sensorNoise == nil {
sensorNoise = spatialmath.NewZeroPose()
}

ptgProv, ok := frame.(tpspace.PTGProvider)
ptgProv, ok := planningFrame.(tpspace.PTGProvider)
if !ok {
return nil, errors.New("unable to cast ptgk frame to a PTG Provider")
}
ptgs := ptgProv.PTGSolvers()
traj := motionplan.Trajectory{{frame.Name(): zeroInput}}
path := motionplan.Path{{frame.Name(): referenceframe.NewPoseInFrame(origin.Parent(), spatialmath.Compose(origin.Pose(), sensorNoise))}}
traj := motionplan.Trajectory{{planningFrame.Name(): zeroInput}}
path := motionplan.Path{
{planningFrame.Name(): referenceframe.NewPoseInFrame(origin.Parent(), spatialmath.Compose(origin.Pose(), sensorNoise))},
}
zeroPlan := motionplan.NewSimplePlan(path, traj)

fk := &fakePTGKinematics{
Base: b,
frame: frame,
origin: origin,
ptgs: ptgs,
currentInput: zeroInput,
currentIndex: 0,
plan: zeroPlan,
sensorNoise: sensorNoise,
logger: logger,
sleepTime: sleepTime,
Base: b,
planningFrame: planningFrame,
localizationFrame: localizationFrame,
origin: origin,
ptgs: ptgs,
currentInput: zeroInput,
currentIndex: 0,
plan: zeroPlan,
sensorNoise: sensorNoise,
logger: logger,
sleepTime: sleepTime,
}
initLocalizer := &fakePTGKinematicsLocalizer{fk}
fk.localizer = motion.TwoDLocalizer(initLocalizer)
Expand All @@ -226,7 +256,11 @@ func WrapWithFakePTGKinematics(
}

func (fk *fakePTGKinematics) Kinematics() referenceframe.Frame {
return fk.frame
return fk.planningFrame
}

func (fk *fakePTGKinematics) LocalizationFrame() referenceframe.Frame {
return fk.localizationFrame
}

func (fk *fakePTGKinematics) CurrentInputs(ctx context.Context) ([]referenceframe.Input, error) {
Expand All @@ -241,9 +275,9 @@ func (fk *fakePTGKinematics) GoToInputs(ctx context.Context, inputSteps ...[]ref
fk.currentInput = zeroInput
fk.currentIndex = 0

traj := motionplan.Trajectory{{fk.frame.Name(): zeroInput}}
traj := motionplan.Trajectory{{fk.planningFrame.Name(): zeroInput}}
path := motionplan.Path{
{fk.frame.Name(): referenceframe.NewPoseInFrame(fk.origin.Parent(), spatialmath.Compose(fk.origin.Pose(), fk.sensorNoise))},
{fk.planningFrame.Name(): referenceframe.NewPoseInFrame(fk.origin.Parent(), spatialmath.Compose(fk.origin.Pose(), fk.sensorNoise))},
}
fk.plan = motionplan.NewSimplePlan(path, traj)
fk.inputLock.Unlock()
Expand All @@ -268,12 +302,12 @@ func (fk *fakePTGKinematics) GoToInputs(ctx context.Context, inputSteps ...[]ref

fk.inputLock.Lock()
fk.currentIndex = i
fk.currentInput, err = fk.frame.Interpolate(zeroInput, inputs, 0)
fk.currentInput, err = fk.planningFrame.Interpolate(zeroInput, inputs, 0)
fk.inputLock.Unlock()
if err != nil {
return err
}
finalPose, err := fk.frame.Transform(inputs)
finalPose, err := fk.planningFrame.Transform(inputs)
if err != nil {
return err
}
Expand All @@ -282,7 +316,7 @@ func (fk *fakePTGKinematics) GoToInputs(ctx context.Context, inputSteps ...[]ref
var interpolatedConfigurations [][]referenceframe.Input
for i := 0; i <= steps; i++ {
interp := float64(i) / float64(steps)
interpConfig, err := fk.frame.Interpolate(zeroInput, inputs, interp)
interpConfig, err := fk.planningFrame.Interpolate(zeroInput, inputs, interp)
if err != nil {
return err
}
Expand All @@ -292,7 +326,7 @@ func (fk *fakePTGKinematics) GoToInputs(ctx context.Context, inputSteps ...[]ref
if ctx.Err() != nil {
return ctx.Err()
}
relativePose, err := fk.frame.Transform(inter)
relativePose, err := fk.planningFrame.Transform(inter)
if err != nil {
return err
}
Expand Down Expand Up @@ -327,8 +361,8 @@ func (fk *fakePTGKinematics) ExecutionState(ctx context.Context) (motionplan.Exe
return motionplan.NewExecutionState(
fk.plan,
fk.currentIndex,
map[string][]referenceframe.Input{fk.frame.Name(): fk.currentInput},
map[string]*referenceframe.PoseInFrame{fk.frame.Name(): pos},
map[string][]referenceframe.Input{fk.Kinematics().Name(): fk.currentInput},
map[string]*referenceframe.PoseInFrame{fk.LocalizationFrame().Name(): pos},
)
}

Expand Down
1 change: 1 addition & 0 deletions components/base/kinematicbase/kinematics.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type KinematicBase interface {
referenceframe.InputEnabled

Kinematics() referenceframe.Frame
LocalizationFrame() referenceframe.Frame

// ErrorState takes a complete motionplan, as well as the index of the currently-executing set of inputs, and computes the pose
// difference between where the robot in fact is, and where it ought to be, i.e. PoseBetween(expected, actual)
Expand Down