vanetza icon indicating copy to clipboard operation
vanetza copied to clipboard

Get current speed and heading by GPS

Open laiketa6 opened this issue 4 years ago • 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.

laiketa6 avatar Jul 23 '21 14:07 laiketa6

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.

riebl avatar Jul 23 '21 15:07 riebl

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.

laiketa6 avatar Jul 23 '21 15:07 laiketa6

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?

riebl avatar Jul 23 '21 16:07 riebl

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

laiketa6 avatar Jul 26 '21 12:07 laiketa6

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

riebl avatar Jul 26 '21 13:07 riebl