Commit ed93f397 authored by MarkG's avatar MarkG Committed by TIGERs GitLab
Browse files

Resolve "Copy and paste move destinations in snapshots"

Closes #1748

See merge request main/Sumatra!1522

sumatra-commit: 00a291076bcecdfbcdddce8fe88a1e692fd6d84f
parent 4ecf987a
Pipeline #17721 passed with stage
in 3 minutes and 16 seconds
/*
* Copyright (c) 2009 - 2018, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.bot;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import com.sleepycat.persist.model.Persistent;
import edu.tigers.sumatra.bot.params.BotParams;
import edu.tigers.sumatra.bot.params.IBotParams;
import edu.tigers.sumatra.ids.BotID;
import edu.tigers.sumatra.math.IMirrorable;
import edu.tigers.sumatra.math.vector.IVector3;
import edu.tigers.sumatra.trajectory.ITrajectory;
import org.apache.commons.lang.Validate;
import java.util.EnumMap;
import java.util.Map;
import java.util.Optional;
/**
......@@ -30,7 +28,7 @@ public class RobotInfo implements IMirrorable<RobotInfo>
private final long timestamp;
private final EBotType type;
private final ERobotMode robotMode;
private final transient ITrajectory<IVector3> trajectory;
private final ITrajectory<IVector3> trajectory;
private final Map<EFeature, EFeatureState> botFeatures;
private final float kickSpeed;
private final boolean chip;
......@@ -43,15 +41,15 @@ public class RobotInfo implements IMirrorable<RobotInfo>
private final boolean isBarrierInterrupted;
private final IBotParams botParams;
private final boolean isOk;
@SuppressWarnings("unused")
private RobotInfo()
{
this(stubBuilder(BotID.noBot(), 0));
}
private RobotInfo(final Builder builder)
{
botId = builder.botId;
......@@ -72,8 +70,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
botParams = builder.botParams;
isOk = builder.isOk;
}
/**
* @return a new builder
*/
......@@ -81,11 +79,11 @@ public class RobotInfo implements IMirrorable<RobotInfo>
{
return new Builder();
}
/**
* Create a stub with default data
*
*
* @param botId the botId is still required
* @param timestamp the timestamp of this information
* @return new bot info
......@@ -94,8 +92,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
{
return stubBuilder(botId, timestamp).build();
}
/**
* Create a stub with default data
*
......@@ -111,7 +109,7 @@ public class RobotInfo implements IMirrorable<RobotInfo>
.withType(EBotType.UNKNOWN)
.withRobotMode(ERobotMode.IDLE)
.withTrajectory(null)
.withBotFeatures(new HashMap<>())
.withBotFeatures(new EnumMap<>(EFeature.class))
.withKickSpeed(0)
.withChip(false)
.withArmed(false)
......@@ -124,8 +122,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
.withBotParams(new BotParams())
.withOk(true);
}
/**
* @param copy for inital values
* @return new builder
......@@ -152,8 +150,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
builder.isOk = copy.isOk;
return builder;
}
/**
* @return new deep copy
*/
......@@ -161,8 +159,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
{
return RobotInfo.copyBuilder(this).build();
}
@Override
public RobotInfo mirrored()
{
......@@ -177,115 +175,115 @@ public class RobotInfo implements IMirrorable<RobotInfo>
}
return builder.build();
}
public BotID getBotId()
{
return botId;
}
public long getTimestamp()
{
return timestamp;
}
public EBotType getType()
{
return type;
}
public ERobotMode getRobotMode()
{
return robotMode;
}
public double getCenter2DribblerDist()
{
return botParams.getDimensions().getCenter2DribblerDist();
}
public IBotParams getBotParams()
{
return botParams;
}
public Optional<ITrajectory<IVector3>> getTrajectory()
{
return Optional.ofNullable(trajectory);
}
public Map<EFeature, EFeatureState> getBotFeatures()
{
return botFeatures;
}
public float getKickSpeed()
{
return kickSpeed;
}
public boolean isChip()
{
return chip;
}
public boolean isArmed()
{
return armed;
}
public float getBattery()
{
return battery;
}
public float getKickerVoltage()
{
return kickerVoltage;
}
public float getDribbleRpm()
{
return dribbleRpm;
}
public int getHardwareId()
{
return hardwareId;
}
public boolean isOk()
{
return isOk;
}
public boolean isBarrierInterrupted()
{
return isBarrierInterrupted;
}
public Optional<BotState> getInternalState()
{
return Optional.ofNullable(internalState);
}
/**
* {@code RobotInfo} builder static inner class.
*/
......@@ -308,13 +306,13 @@ public class RobotInfo implements IMirrorable<RobotInfo>
private boolean barrierInterrupted;
private IBotParams botParams;
private boolean isOk = true;
private Builder()
{
}
/**
* Sets the {@code botId} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -326,11 +324,11 @@ public class RobotInfo implements IMirrorable<RobotInfo>
botId = val;
return this;
}
/**
* Sets if the robot is ok (thus usable for the AI)
*
*
* @param ok
* @return
*/
......@@ -339,8 +337,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
isOk = ok;
return this;
}
/**
* Sets the {@code timestamp} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -352,8 +350,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
timestamp = val;
return this;
}
/**
* Sets the {@code type} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -365,8 +363,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
type = val;
return this;
}
/**
* Sets the {@code robotMode} and returns a reference to this Builder so that
* the methods can be chained together.
......@@ -379,8 +377,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
robotMode = val;
return this;
}
/**
* Sets the {@code botParams} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -393,8 +391,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
botParams = val;
return this;
}
/**
* Sets the {@code trajectory} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -407,8 +405,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
trajectory = val;
return this;
}
/**
* Sets the {@code botFeatures} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -421,8 +419,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
botFeatures = val;
return this;
}
/**
* Sets the {@code kickSpeed} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -434,8 +432,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
kickSpeed = (float) val;
return this;
}
/**
* Sets the {@code chip} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -447,8 +445,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
chip = val;
return this;
}
/**
* Sets the {@code arm} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -460,8 +458,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
armed = val;
return this;
}
/**
* Sets the {@code battery} and returns a reference to this Builder so that the methods can be chained together.
*
......@@ -473,8 +471,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
battery = (float) val;
return this;
}
/**
* Sets the {@code kickerVoltage} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -487,8 +485,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
kickerVoltage = (float) val;
return this;
}
/**
* Sets the {@code dribbleRpm} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -501,8 +499,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
dribbleRpm = (float) val;
return this;
}
/**
* Sets the {@code hardwareId} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -515,8 +513,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
hardwareId = val;
return this;
}
/**
* Sets the {@code internalState} and returns a reference to this Builder so that the methods can be chained
* together.
......@@ -529,8 +527,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
this.internalState = internalState;
return this;
}
/**
* Sets the {@code barrierInterrupted} and returns a reference to this Builder so that the methods can be
* chained
......@@ -544,8 +542,8 @@ public class RobotInfo implements IMirrorable<RobotInfo>
barrierInterrupted = isBarrierInterrupted;
return this;
}
/**
* Returns a {@code RobotInfo} built from the parameters previously set.
*
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.trajectory;
import com.sleepycat.persist.model.Persistent;
/**
* Part of a trajectory
*/
@Persistent
class BBTrajectoryPart
{
float tEnd;
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.trajectory;
import com.sleepycat.persist.model.Persistent;
import edu.tigers.sumatra.math.SumatraMath;
import lombok.ToString;
......@@ -14,6 +15,7 @@ import java.util.List;
* Bang Bang Trajectory for one dimension.
*/
@ToString
@Persistent
class BangBangTrajectory1D implements ITrajectory<Double>
{
static final int MAX_PARTS = 3;
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.trajectory;
import com.sleepycat.persist.model.Persistent;
import edu.tigers.sumatra.math.AngleMath;
import lombok.RequiredArgsConstructor;
......@@ -12,12 +13,20 @@ import java.util.List;
/**
* Bang Bang Trajectory for one dimension for orientation.
*/
@Persistent
@RequiredArgsConstructor
class BangBangTrajectory1DOrient implements ITrajectory<Double>
{
final BangBangTrajectory1D child;
@SuppressWarnings("unused") // berkeley
private BangBangTrajectory1DOrient()
{
child = new BangBangTrajectory1D();
}
@Override
public Double getPositionMM(final double t)
{
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.trajectory;
import com.sleepycat.persist.model.Persistent;
import edu.tigers.sumatra.math.AngleMath;
import edu.tigers.sumatra.math.vector.IVector2;
import edu.tigers.sumatra.math.vector.Vector2;
......@@ -13,13 +14,14 @@ import net.jafama.FastMath;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.function.UnaryOperator;
/**
* Bang Bang Trajectory for two dimensions.
*/
@ToString
@Persistent
class BangBangTrajectory2D implements ITrajectory<IVector2>
{
final BangBangTrajectory1D x = new BangBangTrajectory1D();
......@@ -123,7 +125,7 @@ class BangBangTrajectory2D implements ITrajectory<IVector2>
final float vmax,
final float acc,
final float accuracy,
final Function<Float, Float> alphaFn
final UnaryOperator<Float> alphaFn
)
{
final var s0x = (float) s0.x();
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.trajectory;
import com.sleepycat.persist.model.Persistent;
import edu.tigers.sumatra.math.AngleMath;
import edu.tigers.sumatra.math.vector.IVector2;
import edu.tigers.sumatra.math.vector.Vector2;
......@@ -21,6 +22,7 @@ import java.util.List;
*/
@ToString
@Getter
@Persistent
@RequiredArgsConstructor
class BangBangTrajectory2DAsync implements ITrajectory<IVector2>
{
......@@ -29,6 +31,15 @@ class BangBangTrajectory2DAsync implements ITrajectory<IVector2>
final double rotation;