-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat(interaction): Added LidarUpdates interaction and LidarData object #391
Changes from all commits
8d35be6
9f11484
f5b77c4
57386f6
d361a5d
60d7ccc
b863234
66c4b20
795b2ce
0a11ba1
f09805c
5da7ee9
6e21ace
b6a1ee7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.eclipse.mosaic.fed.application.app.api; | ||
|
||
import org.eclipse.mosaic.lib.objects.vehicle.sensor.LidarData; | ||
|
||
import javax.annotation.Nonnull; | ||
|
||
public interface LidarApplication extends Application { | ||
void onLidarUpdated(@Nonnull LidarData updatedLidarData); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.eclipse.mosaic.interactions.environment; | ||
|
||
import static org.apache.commons.lang3.builder.ToStringStyle.SHORT_PREFIX_STYLE; | ||
|
||
import org.eclipse.mosaic.lib.objects.vehicle.sensor.LidarData; | ||
import org.eclipse.mosaic.rti.api.Interaction; | ||
|
||
import org.apache.commons.lang3.builder.EqualsBuilder; | ||
import org.apache.commons.lang3.builder.HashCodeBuilder; | ||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class LidarUpdates extends Interaction { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This class needs some more documentation before being merged |
||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* String identifying the type of this interaction. | ||
*/ | ||
public final static String TYPE_ID = createTypeIdentifier(LidarUpdates.class); | ||
|
||
/** | ||
* Time at which the next sensor update will be sent. | ||
*/ | ||
private long nextUpdate; | ||
|
||
|
||
/** | ||
* List of {@link LidarData} containing LiDAR data from the simulator. | ||
*/ | ||
private final List<LidarData> updated; | ||
|
||
|
||
|
||
public LidarUpdates(long time, List<LidarData> updated) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me it isn't clear what exactly the list of updated
This kind of stuff should be documented. As far as I get, each ego-vehicle has a LidarData-Object for each lidar-collection-time, which contains the measured point clouds, right? |
||
super(time); | ||
this.updated = updated; | ||
} | ||
|
||
public List<LidarData> getUpdated() { | ||
return this.updated; | ||
} | ||
|
||
public void setNextUpdate(long nextUpdate) { | ||
this.nextUpdate = nextUpdate; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return new HashCodeBuilder(5, 17) | ||
.append(nextUpdate) | ||
.append(updated) | ||
.toHashCode(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (obj == this) { | ||
return true; | ||
} | ||
if (obj.getClass() != getClass()) { | ||
return false; | ||
} | ||
|
||
LidarUpdates other = (LidarUpdates) obj; | ||
return new EqualsBuilder() | ||
.append(this.nextUpdate, other.nextUpdate) | ||
.append(this.updated, other.updated) | ||
.isEquals(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this, SHORT_PREFIX_STYLE) | ||
.appendSuper(super.toString()) | ||
.append("updated", updated.stream().map(LidarData::getName).collect(Collectors.joining(","))) | ||
.toString(); | ||
} | ||
|
||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright (c) 2024 Fraunhofer FOKUS and others. All rights reserved. | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contact: [email protected] | ||
*/ | ||
|
||
package org.eclipse.mosaic.lib.objects.vehicle.sensor; | ||
|
||
import org.eclipse.mosaic.lib.spatial.PointCloud; | ||
import org.eclipse.mosaic.lib.util.gson.PolymorphismTypeAdapterFactory; | ||
|
||
import com.google.gson.annotations.JsonAdapter; | ||
|
||
import java.io.Serializable; | ||
|
||
public class LidarData implements Serializable { | ||
@JsonAdapter(PolymorphismTypeAdapterFactory.class) | ||
private final PointCloud lidarData; | ||
|
||
private final long time; | ||
private final String name; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the fields and maybe rename |
||
/** | ||
* Creates a new {@link LidarData}. | ||
* | ||
* @param time time of the last update | ||
* @param name name of the unit | ||
* @param lidarData Object that contains the LidarFrame data | ||
*/ | ||
public LidarData(long time, String name, PointCloud lidarData) { | ||
this.lidarData = lidarData; | ||
this.time = time; | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Returns lidar data produced by the traffic or vehicle simulator. | ||
* Should be of type LidarFrame. | ||
*/ | ||
public Object getLidarData() { | ||
return this.lidarData; | ||
} | ||
|
||
public long getTime() { | ||
return this.time; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
|
||
/** | ||
* A builder for creating {@link LidarData} objects | ||
*/ | ||
public static class Builder { | ||
private final long time; | ||
private final String name; | ||
private PointCloud lidarData; | ||
|
||
/** | ||
* Init the builder with the current simulation time [ns] and name of the vehicle. | ||
*/ | ||
public Builder(long time, String name) { | ||
this.time = time; | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Set position related values for the vehicle info. | ||
*/ | ||
public LidarData.Builder lidarData(PointCloud lidarData) { | ||
this.lidarData = lidarData; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the final {@link LidarData} based on the properties given before. | ||
*/ | ||
public LidarData create() { | ||
return new LidarData( | ||
time, name, lidarData); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class needs to be documented before being merged.