syntax = "proto2";

option optimize_for = SPEED;

import "osi_common.proto";
import "osi_roadmarking.proto";
import "osi_detectedobject.proto";

package osi3;

//
// \brief A road marking in the environment as detected by the sensor.
//
// \image html OSI_DetectedRoadMarking.svg
//
// The figure shows two STOP road markings (\c
// DetectedRoadMarking::CandidateRoadMarking::classification). STOP \c
// RoadMarking::Classification::type == \c
// RoadMarking::Classification::TYPE_TEXTUAL_TRAFFIC_SIGN is marked, STOP \c
// RoadMarking::Classification::type == \c
// RoadMarking::Classification::TYPE_SYMBOLIC_TRAFFIC_SIGN is not marked.
//
// The parent frame of a detected road marking is the virtual sensor coordinate
// system.
//
// /note The virtual sensor coordinate system is relative to the vehicle coordinate
// system which has its origin in the center of the rear axle of the ego
// vehicle. This means if virtual sensor mounting position and orientation are
// set to (0,0,0) the virtual sensor coordinate system coincides with the
// vehicle coordinate system.
//
message DetectedRoadMarking
{
    // Common information of one detected item.
    //
    optional DetectedItemHeader header = 1;

    // The base parameters of the road marking.
    //
    // The orientation of the bounding box \c #base
    // \c BaseStationary::orientation is defined as follows:
    // The z-axis of the \c BaseStationary::orientation is the vector from the
    // 'bottom' to the 'top' of the road marking's (i.e. painted traffic sign)
    // 2D image area.
    // (Normally it is in the ground truth xy-plain.)
    // The x-axis of the \c BaseStationary::orientation is the view normal of
    // the road marking's 2D image area.
    // Normally this x-axis points to the sky.
    //
    // \note If a valid unidirectional road marking is assigned to the host
    // vehicle's current lane and the driving direction of the latter roughly
    // matches the z-axis of the \c #base \c BaseStationary::orientation then
    // the road marking is of relevance to (i.e. in effect for) the host
    // vehicle.
    //
    optional BaseStationary base = 2;

    // The root mean squared error of the base parameters of the detected
    // road marking. \c RoadMarking::base has to be identical for
    // all \c #candidate road markings.
    //
    optional BaseStationary base_rmse = 3;

    // A list of candidates for this road marking as estimated by the
    // sensor.
    //
    repeated CandidateRoadMarking candidate = 4;

    // The visual color of the material of the road marking.
    //
    // \note This does not represent the semantic classification but the visual
    // appearance. For semantic classification of the road marking use the color
    // field in \c CandidateRoadMarking::classification.
    //
    optional ColorDescription color_description = 5;

    //
    // \brief A candidate for a detected road marking as estimated by the
    // sensor.
    //
    message CandidateRoadMarking
    {
        // The estimated probability that this candidate is the true value.
        //
        // \note The sum of all \c #probability must be one. This probability is
        // given under the condition of
        // \c DetectedItemHeader::existence_probability.
        //
        // \rules
        // is_less_than_or_equal_to: 1
        // is_greater_than_or_equal_to: 0
        // \endrules
        //
        optional double probability = 1;

        // The classification of the road marking.
        //
        // \note IDs, which are referenced in this message, usually
        // reference to \c DetectedXXX::tracking_id IDs.
        //
        optional RoadMarking.Classification classification = 2;
    }
}
