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

Socktap - gps_position_provider #232

Closed
khevessy opened this issue Aug 20, 2024 · 5 comments
Closed

Socktap - gps_position_provider #232

khevessy opened this issue Aug 20, 2024 · 5 comments

Comments

@khevessy
Copy link
Contributor

Hi,
I encountered a GPSD server which does not send position confidence values, even though the position data is valid. After reading the 102-894 CDD

/**
 * This DE indicates the horizontal position confidence value which represents the estimated absolute position accuracy, in one of the axis direction as defined in a shape of ellipse with a 
 * confidence level of 95 %. 
 * 
 * The value shall be set to:
 * - `n` (`n > 0` and `n < 4 094`) if the accuracy is equal to or less than n * 0,01 metre,
 * - `4 094` if the accuracy is out of range, i.e. greater than 4,093 m,
 * - `4 095` if the accuracy information is unavailable.
 *
 * The value 0 shall not be used.
 * 
 * @note: The fact that a position coordinate value is received with confidence value set to `unavailable(4095)`.
 * can be caused by several reasons, such as:
 * - the sensor cannot deliver the accuracy at the defined confidence level because it is a low-end sensor,
 * - the sensor cannot calculate the accuracy due to lack of variables, or
 * - there has been a vehicle bus (e.g. CAN bus) error.
 * In all 3 cases above, the position coordinate value may be valid and used by the application.
 * If a position coordinate value is received and its confidence value is set to `outOfRange(4094)`, it means that
 * the position coordinate value is not valid and therefore cannot be trusted. Such value is not useful
 * for the application.

 * @unit 0,01 metre 
 * @category: GeoReference Information
 * @revision: Description revised in V2.1.1
 */
SemiAxisLength ::= INTEGER{
    doNotUse    (0),
    outOfRange  (4094), 
    unavailable (4095)
} (0..4095)

How about that if the value is not available, position provider sets it to unavailable, e.g.

        if (!std::isnan(gps_data.fix.epx) && !std::isnan(gps_data.fix.epy)) {
            if (gps_data.fix.epx > gps_data.fix.epy) {
                fetched_position_fix.confidence.semi_minor = gps_data.fix.epy * si::meter;
                fetched_position_fix.confidence.semi_major = gps_data.fix.epx * si::meter;
                fetched_position_fix.confidence.orientation = north + 90.0 * degree;
            } else {
                fetched_position_fix.confidence.semi_minor = gps_data.fix.epx * si::meter;
                fetched_position_fix.confidence.semi_major = gps_data.fix.epy * si::meter;
                fetched_position_fix.confidence.orientation = north;
            }
        } else {
            fetched_position_fix.confidence = vanetza::PositionConfidence();
            fetched_position_fix.confidence.semi_minor = 4.095 * si::meter;
            fetched_position_fix.confidence.semi_major = 4.095 * si::meter;
            fetched_position_fix.confidence.orientation = north;
        }

so that then the application can actually use the location? I am not sure how to determine when the location is valid and when it is not.

@riebl
Copy link
Owner

riebl commented Aug 21, 2024

Hi @khevessy,

the vanetza::PositionFix and vanetza::PositionConfidence data structures are not directly linked to CDD on purpose, so you can use them in other contexts too. The fields semi_minor and semi_major are set to infinity by default, i.e. you can check if they are set to a proper value using std::isinf. In the context of CDD, you can set SemiAxisLength to 4095 in that case.
To make socktap generate CAMs without position confidence, I suggest setting the latitude and longitude fields to NaN or infinity when no position fix is available and checking for these special values in CamApplication instead of the validity of position confidence.

khevessy added a commit to khevessy/vanetza that referenced this issue Aug 23, 2024
@khevessy
Copy link
Contributor Author

I tried to implement it as you say, seems to be working well.
GPSD: host 212.234.160.97 port 1971 (will be used in coming ETSI Plugtest)

riebl added a commit that referenced this issue Aug 23, 2024
Use GPSD position when confidence is not available (#232)
@riebl
Copy link
Owner

riebl commented Aug 23, 2024

Thanks, I have merged it. Are you going to join the upcoming ETSI Plugtest?

@khevessy
Copy link
Contributor Author

Sorry there were some mistakes in the code, fixed in the next pull request.
Yes, we are going to be there, I think you are participating too?

@riebl
Copy link
Owner

riebl commented Aug 23, 2024

Oops, have completely missed this issue; should work with glasses ;-)
Nice, then we will meet in Malaga!

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

2 participants