riebl/vanetza

Get current speed and heading by GPS

Closed this issue · 5 comments

Hello @riebl,

I've seen that in the function CamApplication::on_timer(Clock::time_point) inside cam_application.cpp, when the cam message is generated, the values of speed and heading are set to 0:

image

To get the current speed and heading correctly I've tried to set these variables in this way:

auto position = positioning_.position_fix();

bvc.heading.headingValue = position.course.value();
bvc.heading.headingConfidence = HeadingConfidence_equalOrWithinOneDegree;

bvc.speed.speedValue = position.speed.value();
bvc.speed.speedConfidence = SpeedConfidence_equalOrWithinOneCentimeterPerSec;

But in the generated cam, the heading and the speed are still 0.

Could you explain me how to get the current speed and heading correctly?

Thank you.

riebl commented

Have you built socktap with GPS support, i.e. is the CMake option SOCKTAP_WITH_GPSD set to ON? Otherwise, the static position provider is used, which is simply a fixed position without any speed or heading.

Hi @riebl ,

Yes, the flag SOCKTAP_WITH_GPSD is set to ON and I have te position (Latitude and longitude) correctly and is not the static one, but the heading and speed are 0.

riebl commented

Can you verify (e.g. by setting a breakpoint in your debugger) that the speed and course attributes are set to non-zero values at all, when the lines 124 and 125 are hit in gps_position_provider.cpp? Does the gps_data.fix structure contain non-zero speed and track values?

Hello @riebl,

Now I have the device fixed (with no movement). Setting a breakpoint in line 131 in gps_position_provider.cpp I have the following values:

  • For the fetched_position_fix structure:

image

So, it seems apparently OK.

  • For gps_data.fix structure:

image

It seems OK too.

But then, inside cam_application.cpp, although I have the correct position (image below), I have a zero in course (Teorically it is 198) and a zero in speed (In this case the speed is 0, but trying this with the device in movement still in zero) (Second image below).

image

image

riebl commented

I have trouble reproducing your issue. My position object at cam_application.cpp:80 shows a non-zero course.