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-7466 - Change navigation config to include bounding regions #3971

Merged
merged 18 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion services/motion/motion.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type MoveOnGlobeReq struct {
Obstacles []*spatialmath.GeoGeometry
// Optional motion configuration
MotionCfg *MotionConfiguration

// Set of obstacles which the robot must remain within while navigating
BoundingRegions []*spatialmath.GeoGeometry
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this to be with the obstacles?

Copy link
Member

Choose a reason for hiding this comment

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

A bounding region is not an obstacle...

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Nick is right, we should remove the word "obstacle" when referring to these

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, what do we think of:

Set of bounds which the robot must remain within while navigating

Is it worth updating the API to match the new definition we are putting forward?

Copy link
Member

Choose a reason for hiding this comment

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

Lets change bounds above to geometries. And yeah lets make the 1 line change to the API too. We probably need to clean up the comments in motion.proto more but this would be a good start

Extra map[string]interface{}
}
Expand Down
22 changes: 21 additions & 1 deletion services/navigation/builtin/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
errNegativeObstaclePollingFrequencyHz = errors.New("obstacle_polling_frequency_hz must be non-negative if set")
errNegativePlanDeviationM = errors.New("plan_deviation_m must be non-negative if set")
errNegativeReplanCostFactor = errors.New("replan_cost_factor must be non-negative if set")
errGeomWithTranslation = errors.New("geometries specified through navigation are not allowed to have a translation")
)

const (
Expand Down Expand Up @@ -99,6 +100,7 @@ type Config struct {
MetersPerSec float64 `json:"meters_per_sec,omitempty"`

Obstacles []*spatialmath.GeoGeometryConfig `json:"obstacles,omitempty"`
BoundingRegions []*spatialmath.GeoGeometryConfig `json:"bounding_regions,omitempty"`
PositionPollingFrequencyHz float64 `json:"position_polling_frequency_hz,omitempty"`
ObstaclePollingFrequencyHz float64 `json:"obstacle_polling_frequency_hz,omitempty"`
PlanDeviationM float64 `json:"plan_deviation_m,omitempty"`
Expand Down Expand Up @@ -181,7 +183,16 @@ func (conf *Config) Validate(path string) ([]string, error) {
for _, obs := range conf.Obstacles {
for _, geoms := range obs.Geometries {
if !geoms.TranslationOffset.ApproxEqual(r3.Vector{}) {
return nil, errors.New("geometries specified through the navigation are not allowed to have a translation")
return nil, errGeomWithTranslation
}
}
}

// Ensure bounding regions have no translation
for _, region := range conf.BoundingRegions {
for _, geoms := range region.Geometries {
if !geoms.TranslationOffset.ApproxEqual(r3.Vector{}) {
return nil, errGeomWithTranslation
Copy link
Member

Choose a reason for hiding this comment

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

Is there a test for this new validation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I will add this as a unit test.

}
}
}
Expand Down Expand Up @@ -225,6 +236,7 @@ type builtIn struct {
// exploreMotionService will be removed once the motion explore model is integrated into motion builtin
exploreMotionService motion.Service
obstacles []*spatialmath.GeoGeometry
boundingRegions []*spatialmath.GeoGeometry

motionCfg *motion.MotionConfiguration
replanCostFactor float64
Expand Down Expand Up @@ -368,6 +380,12 @@ func (svc *builtIn) Reconfigure(ctx context.Context, deps resource.Dependencies,
return err
}

// Parse bounding regions from the configuration
newBoundingRegions, err := spatialmath.GeoGeometriesFromConfigs(svcConfig.Obstacles)
if err != nil {
return err
}
nicksanford marked this conversation as resolved.
Show resolved Hide resolved

// Create explore motion service
// Note: this service will disappear after the explore motion model is integrated into builtIn
exploreMotionConf := resource.Config{ConvertedAttributes: &explore.Config{}}
Expand All @@ -381,6 +399,7 @@ func (svc *builtIn) Reconfigure(ctx context.Context, deps resource.Dependencies,
svc.mapType = mapType
svc.motionService = motionSvc
svc.obstacles = newObstacles
svc.boundingRegions = newBoundingRegions
svc.replanCostFactor = replanCostFactor
svc.visionServicesByName = visionServicesByName
svc.motionCfg = &motion.MotionConfiguration{
Expand Down Expand Up @@ -524,6 +543,7 @@ func (svc *builtIn) moveToWaypoint(ctx context.Context, wp navigation.Waypoint,
MovementSensorName: svc.movementSensor.Name(),
Obstacles: svc.obstacles,
MotionCfg: svc.motionCfg,
BoundingRegions: svc.boundingRegions,
Extra: extra,
}
cancelCtx, cancelFn := context.WithCancel(ctx)
Expand Down
3 changes: 3 additions & 0 deletions services/navigation/builtin/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,9 @@ func TestNavSetup(t *testing.T) {
paths, err := ns.Paths(ctx, nil)
test.That(t, err, test.ShouldBeNil)
test.That(t, paths, test.ShouldBeEmpty)

test.That(t, len(ns.(*builtIn).boundingRegions), test.ShouldEqual, 1)
test.That(t, len(ns.(*builtIn).obstacles), test.ShouldEqual, 1)
}

func setupStartWaypoint(ctx context.Context, t *testing.T, logger logging.Logger) startWaypointState {
Expand Down
23 changes: 23 additions & 0 deletions services/navigation/data/nav_cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,29 @@
"longitude": 1
}
}],
"bounding_regions":
[{
"geometries":
[{
"label":"aLabel2",
"orientation":{
"type":"ov_degrees",
"value":{
"X":1,
"Y":0,
"Z":0,
"Th": -90
}
},
"x":20,
"y":20,
"z":20
}],
"location":{
"latitude": 2,
"longitude": 2
}
}],
"store":{
"type":"memory"
}
Expand Down
Loading