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: refactor AdHocMessageRoutingBuilder #433

Merged
merged 28 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
66c4b20
fix(workshop): Enabled color changing of externally added vehicles in…
FunKuchen Jun 19, 2024
795b2ce
Merge remote-tracking branch 'upstream/main'
FunKuchen Jul 22, 2024
0a11ba1
Merge remote-tracking branch 'upstream/main'
FunKuchen Jul 29, 2024
f09805c
Merge remote-tracking branch 'upstream/main'
FunKuchen Aug 7, 2024
dfaad7e
Merge remote-tracking branch 'refs/remotes/upstream/main'
FunKuchen Sep 4, 2024
4c229c8
Merge remote-tracking branch 'upstream/main'
FunKuchen Sep 4, 2024
b9c9274
Merge remote-tracking branch 'upstream/main'
FunKuchen Oct 7, 2024
ed0bd47
feat: Refactored AdHoc message routing
FunKuchen Nov 4, 2024
2973bd3
fix: reverted accidental cell change
FunKuchen Nov 4, 2024
648011c
fix: fixed weather app test
FunKuchen Nov 4, 2024
745e90e
Revert "fix: fixed weather app test"
FunKuchen Nov 6, 2024
7d227c7
feat: Refactored AdHoc message routing
FunKuchen Nov 6, 2024
46f6e84
feat: Added hops argument for builder
FunKuchen Nov 6, 2024
7510adf
feat: Fix streaming
FunKuchen Nov 12, 2024
db2762f
fix: show correct icons in barnim scenario (#422)
hoelger Oct 9, 2024
51412b2
docs: link the new documentation page in the README (#421)
hoelger Oct 9, 2024
5783b64
build: store etc-files in mosaic-starter and copy them to bundle (#423)
kschrab Oct 15, 2024
3337498
feat(sumo): support sumo 1.21.0 (#424)
kschrab Oct 15, 2024
d7f7609
fix: remove VSimRTI from WebVisualizer (#426)
hoelger Oct 17, 2024
aebf82b
feat: run windows-mosaic with wsl-ns3 (#425)
hoelger Oct 17, 2024
bf33487
feat(sns): support multi-hop unicast for topological and geographical…
kschrab Nov 5, 2024
c14ef1e
feat: introducing SensorModule to provide access to environmental eve…
kschrab Nov 6, 2024
7888d66
Merge branch 'eclipse:main' into 917-refactor-ad-hoc-message-routing
FunKuchen Nov 12, 2024
a70d986
fix: Adjusted to pull request comments
FunKuchen Nov 13, 2024
1e4e79a
fix: Made builder only usable once
FunKuchen Nov 15, 2024
b0b42b0
fix: Removed unnecessary logging
FunKuchen Nov 15, 2024
8f352a5
fix: Added singlehop to every call of broadcast().topological() that …
FunKuchen Nov 15, 2024
8763e05
fix: Comments and formatting
FunKuchen Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ private void detectEmergencyBrake() {

// Prepare the DENMessage
MessageRouting routing =
getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).topoBroadCast();
getOs().getAdHocModule().createMessageRouting()
.channel(AdHocChannel.CCH)
.singlehop()
.broadcast()
.topological()
.build();
Denm denm = new Denm(routing, new DenmContent(getOs().getSimulationTime(), vehicleLongLat, roadId,
SensorType.SPEED, 1, curSpeed, curDeceleration * 9.81f, null,
null, null), 200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ public class RoadSideUnitApp extends AbstractApplication<RoadSideUnitOperatingSy

private void sendAdHocBroadcast() {
final MessageRouting routing =
getOs().getAdHocModule().createMessageRouting().viaChannel(AdHocChannel.CCH).topoBroadCast();
getOs().getAdHocModule().createMessageRouting()
.channel(AdHocChannel.CCH)
.singlehop()
.broadcast()
.topological()
.build();
final InterVehicleMsg message = new InterVehicleMsg(routing, getOs().getPosition());
getOs().getAdHocModule().sendV2xMessage(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@
public final class VehicleToTrafficLightApp extends AbstractApplication<VehicleOperatingSystem> {
private final static long TIME_INTERVAL = TIME.SECOND;

//Use TopoBroadcast instead of GeoBroadcast because latter is not compatible with OMNeT++ or ns-3
//Use topologically-scoped broadcast instead of geologically-scoped broadcast because latter is not compatible with OMNeT++ or ns-3
private void sendTopoBroadcastMessage() {
final MessageRouting routing = getOperatingSystem()
.getAdHocModule()
.createMessageRouting()
.topoBroadCast();
final MessageRouting routing = getOperatingSystem().getAdHocModule().createMessageRouting()
.singlehop()
.broadcast()
.topological()
.build();
getOs().getAdHocModule().sendV2xMessage(new GreenWaveMsg(routing, TrafficLightApp.SECRET));
getLog().infoSimTime(this, "Sent secret passphrase");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ private void reactOnEnvironmentData(SensorType type, int strength) {
if (useCellNetwork()) {
mr = getOs().getCellModule().createMessageRouting().topoCast("server_0");
} else {
mr = getOs().getAdHocModule().createMessageRouting().geoBroadCast(dest);
mr = getOs().getAdHocModule().createMessageRouting().broadcast().geographical(dest).build();
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.eclipse.mosaic.fed.application.app.api.os.VehicleOperatingSystem;
import org.eclipse.mosaic.fed.application.app.api.perception.BasicSensorModule;
import org.eclipse.mosaic.lib.enums.SensorType;
import org.eclipse.mosaic.lib.geo.GeoArea;
import org.eclipse.mosaic.lib.objects.addressing.AdHocMessageRoutingBuilder;
import org.eclipse.mosaic.lib.objects.addressing.SourceAddressContainer;
import org.eclipse.mosaic.lib.objects.road.IConnection;
Expand Down Expand Up @@ -129,7 +130,9 @@ private void setupMessageRouting() {
AdHocMessageRoutingBuilder adHocMessageRoutingBuilderMock = mock(AdHocMessageRoutingBuilder.class);
when(adHocModuleMock.createMessageRouting()).thenReturn(adHocMessageRoutingBuilderMock);
MessageRouting messageRoutingMock = mock(MessageRouting.class);
when(adHocMessageRoutingBuilderMock.geoBroadCast(any())).thenReturn(messageRoutingMock);
when(adHocMessageRoutingBuilderMock.broadcast()).thenReturn(adHocMessageRoutingBuilderMock);
when(adHocMessageRoutingBuilderMock.geographical(any(GeoArea.class))).thenReturn(adHocMessageRoutingBuilderMock);
when(adHocMessageRoutingBuilderMock.build()).thenReturn(messageRoutingMock);
}

private void setupVehiclePosition() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public Integer sendCam() {
log.warn("sendCAM: Ad hoc communication disabled (!adhocModule.isEnabled()).");
return null;
}
return super.sendCam(createMessageRouting().topoBroadCast());
return super.sendCam(createMessageRouting().singlehop().broadcast().topological().build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void testStartEvent_cellRouting() {
@Test
public void testStartEvent_adhocRouting() {
//SETUP
routing.set(new AdHocMessageRoutingBuilder("veh_0", null).topoBroadCast());
routing.set(new AdHocMessageRoutingBuilder("veh_0", null).singlehop().broadcast().topological().build());

V2xMessageTransmission sendV2xMsg = new V2xMessageTransmission(12 * TIME.SECOND, v2XMessage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void setUp() {
// ======================================================

AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", null);
MessageRouting messageRouting = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast();
MessageRouting messageRouting = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build();

V2xMessage em = new V2xMessage.Empty(messageRouting);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,17 @@ public void topoBroadcast_differentSendingRadiusPerVehicle() throws InternalFede

//RUN + ASSERT
AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", vehToPosition.get("veh_0"));
MessageRouting routing1 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast();
MessageRouting routing1 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build();
sendMessage(routing1);
assertReceivedMessages("veh_1");

adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_1", vehToPosition.get("veh_1"));
MessageRouting routing2 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast();
MessageRouting routing2 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build();
sendMessage(routing2);
assertReceivedMessages("veh_0", "veh_2");

adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_2", vehToPosition.get("veh_2"));
MessageRouting routing3 = adHocMessageRoutingBuilder.viaChannel(AdHocChannel.CCH).topoBroadCast();
MessageRouting routing3 = adHocMessageRoutingBuilder.channel(AdHocChannel.CCH).singlehop().broadcast().topological().build();

sendMessage(routing3);
assertReceivedMessages();
Expand All @@ -168,8 +168,10 @@ public void geoBroadcast_vehiclesInRowWithCustomRadius() throws InternalFederate
// RUN + ASSERT
AdHocMessageRoutingBuilder adHocMessageRoutingBuilder = new AdHocMessageRoutingBuilder("veh_0", vehToPosition.get("veh_0"));
MessageRouting routing1 = adHocMessageRoutingBuilder
.viaChannel(AdHocChannel.CCH)
.geoBroadCast(new GeoCircle(vehToPosition.get("veh_2"), 300));
.channel(AdHocChannel.CCH)
.broadcast()
.geographical(new GeoCircle(vehToPosition.get("veh_2"), 300))
.build();
sendMessage(routing1);
assertReceivedMessages("veh_1", "veh_2");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ private void receiveInteraction(VehicleSensorActivation vehicleSensorActivation)
*/
private void receiveInteraction(VehicleParametersChange vehicleParametersChange) throws InternalFederateException {
if (externalVehicles.containsKey(vehicleParametersChange.getVehicleId())) {
changeExternalParameters(vehicleParametersChange);
kschrab marked this conversation as resolved.
Show resolved Hide resolved
return;
}

Expand Down Expand Up @@ -1283,6 +1284,17 @@ private void removeExternalVehiclesFromUpdates(VehicleUpdates updates) {
updates.getRemovedNames().removeIf(vehicle -> externalVehicles.remove(vehicle) != null);
}

public void changeExternalParameters(VehicleParametersChange vehicleParametersChange) throws InternalFederateException {
final String veh_id = vehicleParametersChange.getVehicleId();
for (final VehicleParameter param : vehicleParametersChange.getVehicleParameters()) {
// Only color is supported as a parameter for external vehicles so far.
if (param.getParameterType() == VehicleParameter.VehicleParameterType.COLOR) {
final Color color = param.getValue();
bridge.getVehicleControl().setColor(veh_id, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
}
}
}

/**
* This handles the case that sumo handles routing and creates new routes while doing so.
*
Expand Down
Loading
Loading