Closed michael89-sys closed 3 years ago
Hi @michael89-sys,
Yes, you should create a new service that can then deal with your message type conveying battery states and alike.
Services hosted by vehicles (i.e. instantiated by VehicleMiddleware
) can easily fetch an instance of VehicleController
, see PoliceService
for an example of how to fetch this controller object.
VehicleController
's getTraCI
method grants you access to the full TraCI API, so you can query any SUMO variable through this facility.
Thank you for your answer, sir, I've created my message files (VeMessage.cc , VeMessage.h , VeMessage.ned ) . and i create a service that i called (VeService) , i am not sure if i write it right or not , but i followed the same structure of PoliceService .
i changed some lines like : auto& vehicle_api = mVehicleController->getTraCI().vehicle();
packet->setactualBatteryCapacity(vehicle_api.traci.vehicle.getElectricityConsumption());
It builds right, but after it popped up a message:
(NED module type "VeService" not found (fully qualified type name expected) -- in module (artery::VehicleMiddleware) World.node[0].middleware (id=23), at t=0.535994902626s, event #7)
(my service NED file exist and it has the same structure of PoliceService.ned )
Where is your VeMessage.ned located? Please note that the scenarios/highway-police folder, which contains the PoliceService.ned, is added to the considered NED paths in scenarios/highway-police/CMakeLists.txt in line 3 by add_opp_run(highway_police NED_FOLDERS ${CMAKE_CURRENT_SOURCE_DIR})
.
You have to place the VeMessage.ned either to Artery's default NED path, i.e. somewhere below src/artery or add your folder explicitly to add_opp_run
.
thank you , it worked but i still got an error while building , my vehicles do not get recognised it popped up this error ,
/home/veins/artery/scenarios/v-electric/VeService.cc:44:57: error: ‘std::cxx11::string’ {aka ‘class std::cxx11::basic_string
the same line exist in the other services , (i'am working of the same file of car2car_grid)
I am not aware of any Artery source file containing the very same line. getTypeId()
returns an ordinardy std::string
, so the compiler error is justified. You probably want something like mVehicleController->getTraCI()->vehicle
.
getTraCI() is not recognised , can you please tell me if you have an idea where i can found it , in artery source file .
error: ‘const class traci::VehicleController’ has no member named ‘getTraCI’; did you mean ‘getTypeId’?
thank you so much for your help i really appreciate it .
last question please . i got an error with my libarteryMessage.cc.so . what can generate this problem **(<!> Error: Cannot load library '/home/veins/artery/build/scenarios/v-electric/libarteryVeMessage.cc.so':)**
I recommend using Artery's CMake macros to add your message and service to the build system. You scenarios/v-electric/CMakeLists.txt should contain lines like the following ones:
# add your source files to a new "Artery feature", which is automatically built then
add_artery_feature(electric VeMessage.cc VeService.cc)
# runs scenarios/v-electric/omnetpp.ini when "make run_electric" is invoked and looks up *.ned in this directory too
# add_opp_run(electric NED_FOLDERS ${CMAKE_CURRENT_SOURCE_DIR})
Well, feel free to emit OMNeT++ signals when transmitting or receiving your VeMessage
just as the CA service does. You may also (temporarily) add some EV_INFO
(or alike) calls to print to the OMNeT++ log to validate your service's behaviour.
Is it possible to add messages in an already existing service or a new service has to be created for each new message?
At the moment, we use a 1:1 mapping between services and BTP ports, i.e. each service has only a single port number assigned (at most). Hence, you would need some application layer "magic" to distinguish different message types arriving at the same destination port. Long story short: I recommend creating a dedicated service for each message type. Our DEN service is somewhat special because it supports multiple use cases; however, all DEN use cases build upon the common DENM type.
Hi @riebl, I am working on electric vehicles, sumo module provides some information about, for example energy consumption, for the first step I want to establish a communication V2I where the vehicle send information about the battery state. Do I have to create a new service for that, and how I can customise my message to include this information.