riebl / artery

OMNeT++ V2X simulation framework for ETSI ITS-G5
GNU General Public License v2.0
204 stars 132 forks source link

CAMs Reception #285

Closed MartinaBarbiFivecomm closed 4 months ago

MartinaBarbiFivecomm commented 1 year ago

Hi,

I would like to replicate the same behaviour of the police scenario, but using CAMs. So I equipped the police car with the CaService but then in the service ClearLaneService running on the other cars, which have to receive the message and slow down I cannot make it to work.

I have added this function reveiveSignal image

also I have subscribed to the receivedCam signal.

image

but it does not do anything.

Do I have to define in this service the same method as in indicate() in CaService?

How do I access the CAM content?

Many thanks,

Martina

riebl commented 1 year ago

CAM reception signals are emitted by the CaService, i.e. if your non-police cars are not equipped with this service, your implementation will not get triggered. However, you may receive CAMs in your custom ClearLaneService if it is assigned the same port (2001) as the CaService run by police cars. You will need to handle message reception on your own, though, i.e. by ClearLaneService::indicate.

MartinaBarbiFivecomm commented 1 year ago

Ok Thanks.

And how can I define for example inside the CaService.cc that the police car is an emergency vehicle through the field EmergencyContainer_t ?

riebl commented 1 year ago

I suggest adding a NED parameter to the CaService such as isEmergencyVehicle or similar. If this parameter is set, your customized CaService fills the EmergencyContainer_t when preparing the CAM. You can configure NED parameters in the omnetpp.ini then. Alternatively, you can modify the CaService by checking the SUMO vehicle name. The vehicle name is accessible through the VehicleController, see getFacilities() how to access this object.

MartinaBarbiFivecomm commented 1 year ago

In the CaService.cc there is no bool like isEmergencyVehicle neither the definition of specialVehcileContainer, so where is this field supposed to be filled if it is not retrieved in the service?

also trying retrieving it using like the other methods:

SpecialVehicleContainer_t& svc = cam.camParameters.specialVehicleContainer; // ADDED SpecialVehicleContainer& svc = svc.choice.emergencyContainer;

it gives me errors. And How am I supposed to fill it?

awillecke commented 1 year ago

This parameter and the container are not implemented. The suggestion only hinted at how the emergency container could be implemented and enabled via a parameter (or based on the vehicle type).

MartinaBarbiFivecomm commented 1 year ago

I did manage to put some of the fields of SpecialVehicleContainer in the function createCooperativeAwarenessMessage as: if (header.stationID == 226) { cam.camParameters.specialVehicleContainer->present == SpecialVehicleContainer_PR_emergencyContainer; EmergencyContainer_t& ec = cam.camParameters.specialVehicleContainer->choice.emergencyContainer; ec.incidentIndication->causeCode = 95; } It does not give me building errors but when running the scenario it just crashes. If I remove this code it works. Do I have to add this container somewhere else besides in this function?

fysch commented 1 year ago

I suspect you forgot to allocate the SpecialVehicleContainer. Take a look at the LowFrequencyContainer implementation in the CaService. A good rule of thumb is to use vanetza::asn1::allocate() whenever a parameter is marked as optional.

MartinaBarbiFivecomm commented 1 year ago

I have added the container as per the LowFrequency one : void addSpecialVehicleContainer(vanetza::asn1::Cam& message, const VehicleDataProvider& vdp) { if (vdp.station_id() == 226) { SpecialVehicleContainer& svc = message->cam.camParameters.specialVehicleContainer; svc = vanetza::asn1::allocate(); svc->present = SpecialVehicleContainer_PR_emergencyContainer; EmergencyContainer& ec = svc->choice.emergencyContainer; ec.incidentIndication-> causeCode = 95; ec.lightBarSirenInUse.buf = static_cast<uint8_t>(vanetza::asn1::allocate(1)); ec.lightBarSirenInUse.size = 1; ec.lightBarSirenInUse.buf[0] = 0; ec.emergencyPriority-> buf = static_cast<uint8_t*>(vanetza::asn1::allocate(1)); //ec.emergencyPriority.size = 1; ec.emergencyPriority->buf[0] = 0; }

}

As soon as it gets triggered the sim crashes. I don't actually know what I am doing wrong. Is there any other place where I have to declare this special container?

riebl commented 1 year ago

Unfortunately, "sim crashes" is a rather fuzzy problem description. I suggest running Artery with a debugger attached. Every run_X target has an accompanying debug_X target if CMAKE_BUILD_TYPE is set to Debug. Then, the debugger usually stops at the point where the simulation crash occurs. That should help you with analyzing the problematic code section.