Closed ansb5 closed 1 year ago
When you say "it doesn't work" you mean it does not even compile, right?
VehicleController::setSpeed
expects a Boost.Unit quantity, i.e. 0
is not sufficient. You need to pass 0.0 * boost::units::si::meter_per_second
, for example.
Thanks for your answer @riebl
Yes, I meant that it did not compile.
Now I tried these two things:
vehicle.setSpeed(0.0 * boost::units::si::meter_per_second);
static const vanetza::units::Velocity stop {0.0 * boost::units::si::meter_per_second};
vehicle.setSpeed(stop);
But I get the same error message:
Sorry I didn't meant to close the issue
You cannot call non-const methods on objects via const references. VehicleController::setSpeed
is a non-const method whereas getSpeed
is a const method. You can retrieve a non-const reference to VehicleController
by getFacilities().get_mutable<traci::VehicleController>()
.
Hello @riebl.
I'm trying to control vehicles via
VehicleController
. I'm callingVehicleController.h
functions inCaService
to stop a car. When I useget
function it works perfectly:auto& vehicle = getFacilities().get_const<traci::VehicleController>()
vehicle.getSpeed().value()
But when I try the same with
set
it doesn't work:vehicle.setSpeed(0) //Stop the vehicle
When I write the object
vehicle.
I get theget
functions in the suggestions but not theset
functions. And of course, when i simulate doesn't work. What can be the problem?