-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve "Ignore obstacles in pathplanning that we drive away from"
Closes #1989 See merge request main/Sumatra!1883 sumatra-commit: 45132b0711fcc22f27e77083d5d9b3598faeb004
- Loading branch information
Showing
8 changed files
with
214 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
modules/common/src/main/java/edu/tigers/sumatra/movingrobot/AcceleratingRobot.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright (c) 2009 - 2024, DHBW Mannheim - TIGERs Mannheim | ||
*/ | ||
|
||
package edu.tigers.sumatra.movingrobot; | ||
|
||
import edu.tigers.sumatra.math.vector.IVector2; | ||
import edu.tigers.sumatra.trajectory.ITrajectory; | ||
|
||
|
||
/** | ||
* A moving robot that is accelerating to the maximum velocity and keeps driving at this velocity. | ||
*/ | ||
public class AcceleratingRobot extends AMovingRobot | ||
{ | ||
private final ITrajectory<Double> trajectoryForward; | ||
private final ITrajectory<Double> trajectoryBackward; | ||
|
||
|
||
AcceleratingRobot( | ||
IVector2 pos, | ||
IVector2 vel, | ||
double radius, | ||
double reactionTime, | ||
ITrajectory<Double> trajectoryForward, | ||
ITrajectory<Double> trajectoryBackward | ||
) | ||
{ | ||
super(pos, vel.normalizeNew(), radius, vel.getLength2(), reactionTime); | ||
this.trajectoryForward = trajectoryForward; | ||
this.trajectoryBackward = trajectoryBackward; | ||
} | ||
|
||
|
||
@Override | ||
MovingOffsets forwardBackwardOffset(double tHorizon, double tAdditionalReaction) | ||
{ | ||
double tReaction = Math.min(reactionTime + tAdditionalReaction, tHorizon); | ||
|
||
double distReaction = speed * tReaction * 1000; | ||
return new MovingOffsets( | ||
distReaction + trajectoryForward.getPositionMM(tHorizon - tReaction), | ||
distReaction + trajectoryBackward.getPositionMM(tHorizon - tReaction) | ||
); | ||
} | ||
} |
65 changes: 0 additions & 65 deletions
65
modules/common/src/main/java/edu/tigers/sumatra/movingrobot/AcceleratingRobotFactory.java
This file was deleted.
Oops, something went wrong.
64 changes: 64 additions & 0 deletions
64
modules/common/src/main/java/edu/tigers/sumatra/movingrobot/MovingRobotFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (c) 2009 - 2024, DHBW Mannheim - TIGERs Mannheim | ||
*/ | ||
|
||
package edu.tigers.sumatra.movingrobot; | ||
|
||
import edu.tigers.sumatra.math.vector.IVector2; | ||
import edu.tigers.sumatra.trajectory.BangBangTrajectoryFactory; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
|
||
/** | ||
* A factory for moving robots. | ||
*/ | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class MovingRobotFactory | ||
{ | ||
private static final double LARGE_DISTANCE = 20; | ||
private static final BangBangTrajectoryFactory TRAJECTORY_FACTORY = new BangBangTrajectoryFactory(); | ||
|
||
|
||
public static IMovingRobot acceleratingRobot( | ||
IVector2 pos, | ||
IVector2 vel, | ||
double vMax, | ||
double acc, | ||
double radius, | ||
double reactionTime | ||
) | ||
{ | ||
double speed = vel.getLength2(); | ||
return new AcceleratingRobot( | ||
pos, | ||
vel, | ||
radius, | ||
reactionTime, | ||
TRAJECTORY_FACTORY.single(0, LARGE_DISTANCE, speed, vMax, acc), | ||
TRAJECTORY_FACTORY.single(0, -LARGE_DISTANCE, speed, vMax, acc) | ||
); | ||
} | ||
|
||
|
||
public static IMovingRobot stoppingRobot( | ||
IVector2 pos, | ||
IVector2 vel, | ||
double vLimit, | ||
double aLimit, | ||
double brkLimit, | ||
double radius, | ||
double reactionTime | ||
) | ||
{ | ||
return new StoppingRobot( | ||
pos, | ||
vel, | ||
radius, | ||
reactionTime, | ||
vLimit, | ||
aLimit, | ||
brkLimit | ||
); | ||
} | ||
} |
Oops, something went wrong.