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

CAMs Reception #285

Open
MartinaBarbiFivecomm opened this issue May 5, 2023 · 9 comments
Open

CAMs Reception #285

MartinaBarbiFivecomm opened this issue May 5, 2023 · 9 comments

Comments

@MartinaBarbiFivecomm
Copy link

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
Copy link
Owner

riebl commented May 7, 2023

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
Copy link
Author

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
Copy link
Owner

riebl commented May 9, 2023

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
Copy link
Author

MartinaBarbiFivecomm commented May 10, 2023

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
Copy link
Contributor

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
Copy link
Author

MartinaBarbiFivecomm commented May 10, 2023

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
Copy link
Contributor

fysch commented May 10, 2023

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
Copy link
Author

MartinaBarbiFivecomm commented May 11, 2023

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
Copy link
Owner

riebl commented May 12, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants