Skip to content
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: introducing SensorModule to provide access to environmental events #420

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

kschrab
Copy link
Contributor

@kschrab kschrab commented Oct 1, 2024

Description

  • Provides new interfaces to provide vehicle applications with sensor modules.
    • The BasicSensorModule is a single-value based sensor model which can be used to detect icy or rainy areas (e.g., via getOs().getBasicSensorModule().getStrengthOf(SensorType.ICE). This replaces the method getOs().getStateOfEnvironmentSensor(SensorType.ICE) in the general OperatingSystem. The data for this sensor module is produced by the EnvironmentAmbassador.
    • The LidarSensorModule provides access to the previously added PointCloud structure which is produced by vehicle simulators such as PHABMACS or Carla.
    • For now, only VehicleUnits are able to use the new sensor modules.
  • Adjusted all apps (e.g., WeatherWarningApp).

Issue(s) related to this PR

  • Resolves internal issue 889

Affected parts of the online documentation

Changes in the documentation required?

Yes, documentation and Barnim tutorials must be adjusted to use getBasicSensorModule instead now.

Definition of Done

Prerequisites

  • You have read CONTRIBUTING.md carefully.
  • You have signed the Contributor License Agreement.
  • Your GitHub user id is linked with your Eclipse Account.

Required

  • The title of this merge request follows the scheme type(scope): description (in the style of Conventional Commits)
  • You have assigned a suitable label to this pull request (e.g., enhancement, or bugfix)
  • origin/main has been merged into your Fork.
  • Coding guidelines have been followed (see CONTRIBUTING.md).
  • All checks on GitHub pass.
  • All tests on Jenkins pass.

Requested (can be enforced by maintainers)

  • New functionality is covered by unit tests or integration tests. Code coverage must not decrease.
  • If a bug has been fixed, a new unit test has been written (beforehand) to prove misbehavior
  • There are no new SpotBugs warnings.

Special notes to reviewer

@kschrab kschrab self-assigned this Oct 1, 2024
@hoelger
Copy link
Contributor

hoelger commented Oct 1, 2024

had a very brief read and came up with following things:

  • getEnvironmentSensor(): environment here gets a very special naming meaning "coming from environment simulator". also lidar data is from the environment... right? not sure how confusing this is in the future >> getSimpleSensor()
  • getEnvironmentSensor(): singular "Sensor" may be confusing, because environment has multiple sensor types...
  • getOs().getSensorModule().getEnvironmentSensor().enable() : this enable was happening on the module itself (looking at adhoc / cell), so after getModule(), now it's one layer deeper. I find this confusing and for my taste this should be unified.
  • same thing different perspective: with "sensible" you give access to both environment + lidar. so why would you enable() those separately?
  • discussed: have getLidarSensorModule() and getSimpleSensorModule() as two different modules
  • why DefaultSensorModule and not SensorModule (cmp AdhocModule / CellModule) (I don't fully understand why you want to split this very little functionality into the interface SensorModule, this only makes sense if you can reuse it, like for the Sensor<T>). I would merge Default + SensorModule

# Conflicts:
#	app/tutorials/traffic-light-communication/src/main/java/org/eclipse/mosaic/app/tutorial/EventSendingApp.java
#	app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherServerApp.java
#	app/tutorials/weather-warning/src/main/java/org/eclipse/mosaic/app/tutorial/WeatherWarningApp.java
#	fed/mosaic-application/src/main/java/org/eclipse/mosaic/fed/application/ambassador/simulation/AbstractSimulationUnit.java
}

@Override
public void reactOnSensorDataUpdate(Consumer<EnvironmentSensorData> consumer) {
callbacks.add(consumer);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we remove this handy option to add callbacks? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed that at least for this basic sensor, as I noticed it was not implemented correctly and doing it right would require more effort. The callback was only triggered when the vehicle entered the event area, but not when it left it or when the event time has reached its end. We can later offer this method, but right now it would not work as expected and would be out of scope of this re-design.

@@ -99,7 +94,6 @@ public abstract class AbstractSimulationUnit implements EventProcessor, Operatin

private final AdHocModule adhocModule;
private final CellModule cellModule;
private final SensorModule sensorModule;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why the module now goes into VehicleUnit. So implementing it here was wrong in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, as long as we only support vehicles with the proposed sensor modules, it's sufficient to initialize the implementation in the VehicleUnit only. We can discuss if we already want RSUs or TrafficLights to be able be Sensible, but again, this more sounds like a feature than a re-design.

@kschrab kschrab marked this pull request as ready for review October 9, 2024 12:00
@kschrab kschrab added enhancement New feature or request hacktoberfest-accepted labels Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants