Skip to content

Commit

Permalink
Add support for specifying vehicle bounding boxes
Browse files Browse the repository at this point in the history
* Add support for specifying a bounding box for a vehicle via the Model
  Editor application. A vehicle's bounding box, which, among other
  things, is defined by a length, width and height, replaces the
  vehicle's "length" property, which could previously be specified for
  vehicles.
* Add support for specifying a maximum vehicle bounding box for a point
  via the Model Editor application.
* Add XML schema for v6.0.0 plant model files which allows bounding
  boxes for vehicles and ant points to be persisted.
* Add a README file documenting some guidelines regarding the openTCS
  plant model XML schemas.

Merged-by: Stefan Walter <[email protected]>
  • Loading branch information
martingr authored and swltr committed Aug 14, 2024
1 parent 8f242b9 commit 8c3b1da
Show file tree
Hide file tree
Showing 58 changed files with 4,760 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/**
* Copyright (c) The openTCS Authors.
*
* This program is free software and subject to the MIT license. (For details,
* see the licensing information (LICENSE.txt) you should have received with
* this copy of the software.)
*/
package org.opentcs.access.to.model;

import static java.util.Objects.requireNonNull;
import static org.opentcs.util.Assertions.checkInRange;

import java.io.Serializable;

/**
* A transfer object describing a bounding box.
*/
public class BoundingBoxCreationTO
implements
Serializable {

private final long length;
private final long width;
private final long height;
private final CoupleCreationTO referenceOffset;

/**
* Creates a new instance with a (0, 0) reference offset.
*
* @param length The bounding box's length.
* @param width The bounding box's width.
* @param height The bounding box's height.
*/
public BoundingBoxCreationTO(long length, long width, long height) {
this(length, width, height, new CoupleCreationTO(0, 0));
}

private BoundingBoxCreationTO(
long length,
long width,
long height,
CoupleCreationTO referenceOffset
) {
this.length = checkInRange(length, 1, Long.MAX_VALUE, "length");
this.width = checkInRange(width, 1, Long.MAX_VALUE, "width");
this.height = checkInRange(height, 1, Long.MAX_VALUE, "height");
this.referenceOffset = requireNonNull(referenceOffset, "referenceOffset");
}

/**
* Returns the bounding box's length.
*
* @return The bounding box's length.
*/
public long getLength() {
return length;
}

/**
* Creates a copy of this object, with the given length.
*
* @param length The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public BoundingBoxCreationTO withLength(long length) {
return new BoundingBoxCreationTO(length, width, height, referenceOffset);
}

/**
* Returns the bounding box's width.
*
* @return The bounding box's width.
*/
public long getWidth() {
return width;
}

/**
* Creates a copy of this object, with the given width.
*
* @param width The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public BoundingBoxCreationTO withWidth(long width) {
return new BoundingBoxCreationTO(length, width, height, referenceOffset);
}

/**
* Returns the bounding box's height.
*
* @return The bounding box's height.
*/
public long getHeight() {
return height;
}

/**
* Creates a copy of this object, with the given height.
*
* @param height The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public BoundingBoxCreationTO withHeight(long height) {
return new BoundingBoxCreationTO(length, width, height, referenceOffset);
}

/**
* Returns the bounding box's reference offset.
*
* @return The bounding box's reference offset.
*/
public CoupleCreationTO getReferenceOffset() {
return referenceOffset;
}

/**
* Creates a copy of this object, with the given reference offset.
*
* @param referenceOffset The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public BoundingBoxCreationTO withReferenceOffset(CoupleCreationTO referenceOffset) {
return new BoundingBoxCreationTO(length, width, height, referenceOffset);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) The openTCS Authors.
*
* This program is free software and subject to the MIT license. (For details,
* see the licensing information (LICENSE.txt) you should have received with
* this copy of the software.)
*/
package org.opentcs.access.to.model;

import java.io.Serializable;

/**
* A transfer object describing generic 2-tuple of long integer values.
*/
public class CoupleCreationTO
implements
Serializable {

private final long x;
private final long y;

/**
* Creates a new instance.
*
* @param x The X coordinate.
* @param y The Y coordinate.
*/
public CoupleCreationTO(long x, long y) {
this.x = x;
this.y = y;
}

/**
* Returns the x coordinate.
*
* @return The x coordinate.
*/
public long getX() {
return x;
}

/**
* Creates a copy of this object, with the given x coordinate.
*
* @param x The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public CoupleCreationTO withX(long x) {
return new CoupleCreationTO(x, y);
}

/**
* Returns the y coordinate.
*
* @return The y coordinate.
*/
public long getY() {
return y;
}

/**
* Creates a copy of this object, with the given y coordinate.
*
* @param y The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public CoupleCreationTO withY(long y) {
return new CoupleCreationTO(x, y);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public class PointCreationTO
*/
private final Map<String, Envelope> vehicleEnvelopes;
/**
* The information regarding the grahical representation of this point.
* The maximum bounding box (in mm) that a vehicle at this point is allowed to have.
*/
private final BoundingBoxCreationTO maxVehicleBoundingBox;
/**
* The information regarding the graphical representation of this point.
*/
private final Layout layout;

Expand All @@ -59,6 +63,8 @@ public PointCreationTO(
this.pose = new Pose(new Triple(0, 0, 0), Double.NaN);
this.type = Point.Type.HALT_POSITION;
this.vehicleEnvelopes = Map.of();
this.maxVehicleBoundingBox
= new BoundingBoxCreationTO(1000, 1000, 1000);
this.layout = new Layout();
}

Expand All @@ -74,12 +80,15 @@ private PointCreationTO(
@Nonnull
Map<String, Envelope> vehicleEnvelopes,
@Nonnull
BoundingBoxCreationTO maxVehicleBoundingBox,
@Nonnull
Layout layout
) {
super(name, properties);
this.pose = requireNonNull(pose, "pose");
this.type = requireNonNull(type, "type");
this.vehicleEnvelopes = requireNonNull(vehicleEnvelopes, "vehicleEnvelopes");
this.maxVehicleBoundingBox = requireNonNull(maxVehicleBoundingBox, "maxVehicleBoundingBox");
this.layout = requireNonNull(layout, "layout");
}

Expand All @@ -100,6 +109,7 @@ public PointCreationTO withName(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand Down Expand Up @@ -130,6 +140,7 @@ public PointCreationTO withPose(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand Down Expand Up @@ -160,6 +171,7 @@ public PointCreationTO withType(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand All @@ -181,6 +193,7 @@ public PointCreationTO withProperties(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand All @@ -192,7 +205,7 @@ public PointCreationTO withProperties(
* @param key the key.
* @param value the value
* @return A copy of this object that either
* includes the given entry in it's current properties, if value != null or
* includes the given entry in its current properties, if value != null or
* excludes the entry otherwise.
*/
@Override
Expand All @@ -208,6 +221,7 @@ public PointCreationTO withProperty(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand Down Expand Up @@ -237,14 +251,42 @@ public PointCreationTO withVehicleEnvelopes(
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}

/**
* Returns the maximum bounding box (in mm) that a vehicle at this point is allowed to have.
*
* @return The maximum bounding box (in mm) that a vehicle at this point is allowed to have.
*/
public BoundingBoxCreationTO getMaxVehicleBoundingBox() {
return maxVehicleBoundingBox;
}

/**
* Creates a copy of this object, with the given maximum vehicle bounding box.
*
* @param maxVehicleBoundingBox The value to be set in the copy.
* @return A copy of this object, differing in the given value.
*/
public PointCreationTO withMaxVehicleBoundingBox(BoundingBoxCreationTO maxVehicleBoundingBox) {
return new PointCreationTO(
getName(),
getModifiableProperties(),
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}

/**
* Returns the information regarding the grahical representation of this point.
* Returns the information regarding the graphical representation of this point.
*
* @return The information regarding the grahical representation of this point.
* @return The information regarding the graphical representation of this point.
*/
public Layout getLayout() {
return layout;
Expand All @@ -263,6 +305,7 @@ public PointCreationTO withLayout(Layout layout) {
pose,
type,
vehicleEnvelopes,
maxVehicleBoundingBox,
layout
);
}
Expand All @@ -275,12 +318,13 @@ public String toString() {
+ ", type=" + type
+ ", vehicleEnvelopes=" + vehicleEnvelopes
+ ", layout=" + layout
+ ", maxVehicleBoundingBox=" + maxVehicleBoundingBox
+ ", properties=" + getProperties()
+ '}';
}

/**
* Contains information regarding the grahical representation of a point.
* Contains information regarding the graphical representation of a point.
*/
public static class Layout
implements
Expand Down
Loading

0 comments on commit 8c3b1da

Please sign in to comment.