Open jschiefele opened 7 months ago
For your first question, the inaccuracy is due to the forward Euler approximation being done internally. You might be able to get better results with a smaller step size (see the note here), but with this method there will always be some noise.
As to your second question, to my knowledge there's no direct way to calculate that distance in Scenic right now, though this has come up in the past and it's something we'd like to add/review a PR adding.
Thanks @Eric-Vin. Thinking about your hint with the Euler approximation, I guess the VectorField which defines the orientation of a PolylineRegion is simply not intended to support my specific use-case:
I aim to move a railroad vehicle along a 1-dimensional track. It cannot go off sideways, just forwards and backwards. In the plot, I use track = PolylineRegion([(0., -1., 0.),(0., 0., 0.), (2. , 2., 0.)])
.
The orientation of the PolylineRegion has field lines parallel to the line segments. This does supports my idea of following as long as there are no corners. (As in the blue trajectory_1.)
Where the straight segments form corners, the step procedure in VectorField.followFrom
will overshoot the corner at some place or the other. From there on, it will step along parallel to the track instead of correcting the overshooting. (As in the orange trajectory_0.)
My plan now is to modify one of the Regions implemented in Scenic 3 (PathRegion?) by defining something like a 1D VectorField to serve as the track's orientation. Its followFrom()
should stay strictly on the linear segments, somehow wrapping the incremental step around to the next linear segment when a corner is reached.
Please let me know if you think this is a reasonable idea (and if this might be of general interest as a PR).
Apologies for the late response, just saw that this comment was posted! This seems like a reasonable idea to me overall, and the idea for the default vector field for PathRegion
seems similar to the one for PolylineRegion
.
Versions: Scenic 2.1.0, Python 3.11
Hi.
My goal is to model a scenario where the ego vehicle follows a curved track, and there is an obstacle on this track. I want to be able to specify the distance between ego and obstacle, not as the crow flies, but measured along the track (like a braking distance on a curved road).
I am using the
following
specifier to obtain this, like in the minimal example below, but do not get the intended results:The obstacle was not placed on the track, and the ego-obstacle-distance is not 10. Am I misunderstanding something here? Or is there any other syntax to specify a distance along a curve?