Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
MishkaMN committed Sep 17, 2024
1 parent 9739e4c commit 6f3377a
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- develop
- master
- test/map_frame_pose
- "release/*"
tags:
- "carma-system-*"
Expand Down
1 change: 1 addition & 0 deletions co-simulation/bridge/carla_integration/synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import glob
import os
import sys
import logging

try:
sys.path.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"longitude": 0
},
"cartesianOffset": {
"x": 0,
"y": 0
"x": 503.02,
"y": 423.76
}
},
"network": {
Expand All @@ -36,6 +36,6 @@
"carma": true,
"infrastructure": true,
"carma-cloud": true

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
<!-- Routes -->
<route id="r_0" edges="11 10 17"/>
<route id="r_1" edges="12"/>
<!--This is for keeping the simulation alive-->
<vehicle id="v_3" type="vehicle.carlamotors.carlacola" depart="999.00" route="r_0"/>
<vehicle id="v_4" type="type1" route="r_1" depart="0" color="0,1,1"/>
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public V2xMessageTransmission onV2XMessageTx(InetAddress sourceAddr, CarmaV2xMes
sender.getCarlaRoleName(), sender.getLocation()).viaChannel(AdHocChannel.CCH);
// TODO: Get maximum broadcast radius from configuration file.
MessageRouting routing = messageRoutingBuilder.geoBroadCast(new GeoCircle(sender.getLocation(), 300));
log.debug("Generating V2XMessageTransmission interaction sim time: {}, sender id: {}, location: {}, type: {}, payload: {}",
time,
log.debug("Generating V2XMessageTransmission interaction sim time: {}, sender id: {}, location: {}, type: {}, payload: {}",
time,
sender.getCarmaVehicleId(),
sender.getLocation(),
txMsg.getType(),
Expand All @@ -116,6 +116,7 @@ public void onVehicleUpdates(VehicleUpdates vui) {
for (VehicleData veh : vui.getUpdated()) {
if (managedInstances.containsKey(veh.getName())) {
managedInstances.get(veh.getName()).setLocation(veh.getPosition());
log.warn("On vehicle updates in carma instance manager, vehicle position, veh_name:{}, position {}", veh.getName(), veh.getPosition().toString());
}
}
}
Expand All @@ -142,7 +143,7 @@ public void onV2XMessageRx(byte[] rxMsg, String rxVehicleId) {
/**
* This function is used to send out encoded timestep update to all registered
* instances the manager has on the managed instances map
*
*
* @param message This time message is used to store current seq and timestep
* from the ambassador side
* @throws IOException
Expand All @@ -156,9 +157,9 @@ public void onTimeStepUpdate(TimeSyncMessage message) throws IOException {
byte[] bytes = gson.toJson(message).getBytes();
for (CarmaInstance currentInstance : managedInstances.values()) {
log.debug("Sending CARMA Platform instance {} at {}:{} time sync message for time {}!" ,
currentInstance.getCarmaVehicleId(),
currentInstance.getTargetAddress(),
currentInstance.getTimeSyncPort(),
currentInstance.getCarmaVehicleId(),
currentInstance.getTargetAddress(),
currentInstance.getTimeSyncPort(),
message.getTimestep());
currentInstance.sendTimeSyncMsg(bytes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public CarmaMessageAmbassador(AmbassadorParameter ambassadorParameter) {

/**
* This method is called to tell the federate the start time and the end time.
*
*
* @param startTime Start time of the simulation run in nano seconds.
* @param endTime End time of the simulation run in nano seconds.
* @throws InternalFederateException Exception is thrown if an error is occurred
Expand Down Expand Up @@ -182,10 +182,10 @@ public synchronized void processTimeAdvanceGrant(long time) throws InternalFeder
// Time Syncmessage in nano seconds
TimeSyncMessage timeSyncMessage = new TimeSyncMessage(currentSimulationTime, timeSyncSeq);
carmaInstanceManager.onTimeStepUpdate(timeSyncMessage);
// Increment time
// Increment time
currentSimulationTime += carmaConfiguration.updateInterval * TIME.MILLI_SECOND;
timeSyncSeq += 1;

rti.requestAdvanceTime(currentSimulationTime, 0, (byte) 2);
} catch (IllegalValueException e) {
log.error("Error during advanceTime(" + time + ")", e);
Expand All @@ -197,7 +197,7 @@ public synchronized void processTimeAdvanceGrant(long time) throws InternalFeder
log.error("Error during advanceTime(" + time + ")", e);
throw new InternalFederateException(e);
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ protected void processInteractionAdvanced(Interaction interaction, long time) th
throw new InternalFederateException(
"Interaction time lies in the future:" + interaction.getTime() + ", current time:" + time);
}
log.warn("Received interaction of type: {}",interaction.getTypeId());

if (interaction.getTypeId().equals(VehicleFederateAssignment.TYPE_ID)) {
receiveInteraction((VehicleFederateAssignment) interaction);
Expand Down Expand Up @@ -564,6 +565,7 @@ private synchronized void receiveInteraction(VehicleUpdates vehicleUpdates) thro
vehicleState = externalVehicleMap.get(updatedVehicle.getName());
if (vehicleState != null) {
vehicleState.setLastMovementInfo(updatedVehicle);
log.warn("Received interaction for externally simulated vehicle {} with position x {}, y {}", vehicleState.getLastMovementInfo().getProjectedPosition().getX(), vehicleState.getLastMovementInfo().getProjectedPosition().getY());
}
}

Expand All @@ -572,6 +574,7 @@ private synchronized void receiveInteraction(VehicleUpdates vehicleUpdates) thro
traci.getSimulationControl().removeVehicle(removed, VehicleSetRemove.Reason.ARRIVED);
}
}

}

/**
Expand Down Expand Up @@ -1237,6 +1240,14 @@ public synchronized void processTimeAdvanceGrant(long time) throws InternalFeder
log.trace("Leaving advance time: {}", time);
removeExternalVehiclesFromUpdates(simulationStepResult.getVehicleUpdates());
propagateNewRoutes(simulationStepResult.getVehicleUpdates(), time);
log.warn("Updated vehicle list");
List<VehicleData> vehicle_data_list = simulationStepResult.getVehicleUpdates().getUpdated();
for (int i =0; i < vehicle_data_list.size(); i++)
{
VehicleData veh_data = vehicle_data_list.get(i);
log.warn("Vehicle name: {}, geoPoint lat: {} lon: {}", veh_data.getName(), veh_data.getPosition().getLatitude(), veh_data.getPosition().getLongitude());
log.warn("Vehicle name: {}, projectedPosition lat: {} lon: {}", veh_data.getName(), veh_data.getProjectedPosition().getX(), veh_data.getProjectedPosition().getY());
}

nextTimeStep += sumoConfig.updateInterval * TIME.MILLI_SECOND;
simulationStepResult.getVehicleUpdates().setNextUpdate(nextTimeStep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ private void receiveInteraction(VehicleRegistration interaction) {
} else {
log.debug("Won't subscribe to vehicle \"{}\".", vehicleId);
}
log.warn("Received vehicle registration interaction for vehicle id: {}", vehicleId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.eclipse.mosaic.lib.objects.vehicle.VehicleSignals;
import org.eclipse.mosaic.lib.objects.vehicle.sensor.DistanceSensor;
import org.eclipse.mosaic.lib.objects.vehicle.sensor.RadarSensor;
import org.eclipse.mosaic.lib.transform.GeoProjection;
import org.eclipse.mosaic.rti.TIME;
import org.eclipse.mosaic.rti.api.InternalFederateException;

Expand Down Expand Up @@ -368,6 +369,7 @@ public TraciSimulationStepResult simulateUntil(long time) throws InternalFederat
for (AbstractSubscriptionResult subscriptionResult : subscriptions) {
if (subscriptionResult instanceof VehicleSubscriptionResult) {
veh = (VehicleSubscriptionResult) subscriptionResult;
log.warn("Got vehicle from subscription result, position x:{} y:{}", veh.position.getX(), veh.position.getY());
} else {
continue;
}
Expand All @@ -392,6 +394,7 @@ public TraciSimulationStepResult simulateUntil(long time) throws InternalFederat
}
continue;
} else {
log.warn("Constructing new vehicleData");
vehicleData = new VehicleData.Builder(time, veh.id)
.position(veh.position.getGeographicPosition(), veh.position.getProjectedPosition())
.road(getRoadPosition(lastVehicleData, veh))
Expand All @@ -407,8 +410,14 @@ public TraciSimulationStepResult simulateUntil(long time) throws InternalFederat
.create();
}



this.lastVehicleData.put(vehicleData.getName(), vehicleData);

log.warn("{\"id\":{}, \"Latitude\":{}, \"Longitude\":{}, \"x\":{}, \"y\":{}}",vehicleData.getName(), vehicleData.getPosition().getLatitude(), vehicleData.getPosition().getLongitude(), vehicleData.getProjectedPosition().getX(), vehicleData.getProjectedPosition().getY());
log.warn(vehicleData.getPosition().toString());
log.warn("Test position to geo function: ", vehicleData.getProjectedPosition().toGeo().toString());

updateVehicleLists(addedVehicles, updatedVehicles, removedVehicles, vehicleData);
}

Expand Down
2 changes: 1 addition & 1 deletion docker/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ if [[ $COMPONENT_VERSION_STRING = "develop" ]]; then
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .
else
docker build --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
docker build --progress=plain --no-cache -t $USERNAME/$IMAGE:$COMPONENT_VERSION_STRING \
--build-arg VERSION="$COMPONENT_VERSION_STRING" \
--build-arg VCS_REF=`git rev-parse --short HEAD` \
--build-arg BUILD_DATE=`date -u +”%Y-%m-%dT%H:%M:%SZ”` .
Expand Down

0 comments on commit 6f3377a

Please sign in to comment.