Program Listing for File SimOneHDMapAPI.h

Return to documentation for file ( api\Cpp_API_Reference\SimOneHDMapAPI.h )

// ==========================================================================
// Copyright (C) 2018 - 2021 Beijing 51WORLD Digital Twin Technology Co., Ltd.
// , and/or its licensors.  All rights reserved.
//
// The coded instructions, statements, computer programs, and/or related
// material (collectively the "Data") in these files contain unpublished
// information proprietary to Beijing 51WORLD Digital Twin Technology Co., Ltd.
// ("51WORLD") and/or its licensors,  which is protected by the People's
// Republic of China and/or other countries copyright law and by
// international treaties.
//
// The Data may not be disclosed or distributed to third parties or be
// copied or duplicated, in whole or in part, without the prior written
// consent of 51WORLD.
//
// The copyright notices in the Software and this entire statement,
// including the above license grant, this restriction and the following
// disclaimer, must be included in all copies of the Software, in whole
// or in part, and all derivative works of the Software, unless such copies
// or derivative works are solely in the form of machine-executable object
// code generated by a source language processor.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND.
// 51WORLD DOES NOT MAKE AND HEREBY DISCLAIMS ANY EXPRESS OR IMPLIED
// WARRANTIES INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF
// NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE,
// OR ARISING FROM A COURSE OF DEALING, USAGE, OR TRADE PRACTICE. IN NO
// EVENT WILL 51WORLD AND/OR ITS LICENSORS BE LIABLE FOR ANY LOST
// REVENUES, DATA, OR PROFITS, OR SPECIAL, DIRECT, INDIRECT, OR
// CONSEQUENTIAL DAMAGES, EVEN IF 51WORLD AND/OR ITS LICENSORS HAS
// BEEN ADVISED OF THE POSSIBILITY OR PROBABILITY OF SUCH DAMAGES.
// ==========================================================================
#pragma once
#pragma warning(disable:4819)
#pragma warning(disable:4190)
#ifndef WITHOUT_HDMAP
#ifdef BUILD_SIMONE_API
#if defined(WIN32) || defined(_WIN32)
#define SIMONE_API __declspec(dllexport)
#elif defined(__linux__) || defined(__linux)
#define SIMONE_API __attribute__((visibility("default")))
#endif
#else
#define SIMONE_API
#endif

#include <string>
#include "Service/SimOneIOStruct.h"

#include "public/common/MEnum.h"
#include "public/common/MLaneLink.h"
#include "public/common/MLaneInfo.h"
#include "public/common/MRoadMark.h"
#include "public/common/MSignal.h"
#include "public/common/MObject.h"
#include "public/common/MParkingSpace.h"
#include "public/common/MRoutePath.h"
#include "public/common/MTopoGraph.h"
#include "public/MHDMap.h"
#include "SSD/SimPoint3D.h"
#include "SSD/SimString.h"
#include "SSD/SimString.h"
#include "SSD/SimVector.h"

//namespace HDMapStandalone
//{
//    struct MLaneInfo;
//  struct MLaneLink;
//}

#ifdef __cplusplus
extern "C"
{
#endif


    namespace SimOneAPI {
        struct LaneSample
        {
            int laneCode;  //1, 2, ...
            bool inJunction = false;
            SSD::SimPoint3DVector leftBoundary;    //Left boundary sample data£ºlane_line_left_data
            SSD::SimPoint3DVector rightBoundary;  //Right boundary sample data£ºlane_line_right_data
        };

        struct LaneData
        {
            SSD::SimVector<LaneSample> laneSampleList;
            SSD::SimStringVector laneNameList;
            HDMapStandalone::MRoadMark leftRoadMark;
            HDMapStandalone::MRoadMark rightRoadMark;
        };

        struct LaneInfo
        {
            SSD::SimString currentLane;
            SSD::SimVector<LaneData> dataList;
        };

        struct TyrePosInfo
        {
            SSD::SimPoint3D frontLeft;
            SSD::SimPoint3D frontRight;
            SSD::SimPoint3D rearLeft;
            SSD::SimPoint3D rearRight;
        };

        enum EDirectionType_
        {
            Forward = 0,
            TurnLeft = 1,
            TurnRight = 2,
            TurnBack = 3,
            ForwardAndTurnLeft = 4,
            ForwardAndTurnRight = 5,
            ForwardAndTurnBack = 6,
            TurnLeftAndTurnBack = 7
        };

        enum ELaneLineType_
        {
            none = 0,
            whiteSolid = 1,
            whiteDotted = 2,
            yellowSolid = 3,
            yellowDotted = 4
        };

        struct LaneIndexInfo_
        {
            int currentIndex = -99;
            SSD::SimVector<int> indexList;
        };

        struct LaneSample_
        {
            int laneCode;  //1, 2, ...
            bool inJunction = false;
            SSD::SimPoint3DVector leftBoundary;    //Left boundary sample data:lane_line_left_data
            SSD::SimPoint3DVector rightBoundary;  //Right boundary sample data:lane_line_right_data
        };

        struct OverlapLaneInfo_
        {
            bool isOverlapLeftBoundary = false;
            bool isOverlapRightBoundary = false;
        };

        struct LaneLineTypeInfo_
        {
            ELaneLineType_ leftLaneLineType;
            ELaneLineType_ rightLaneLineType;
        };

        struct LaneData_
        {
            LaneIndexInfo_ laneIndexInfo;
            EDirectionType_ laneType;
            SSD::SimVector<LaneSample_> laneSampleList;
            OverlapLaneInfo_ overlapLaneInfo;
            LaneLineTypeInfo_ laneLineTypeInfo;
        };

        struct LaneInfo_
        {
            SSD::SimVector<LaneData_> dataList;
        };

        struct TyrePosInfo_
        {
            SSD::SimPoint3D frontLeft;
            SSD::SimPoint3D frontRight;
            SSD::SimPoint3D rearLeft;
            SSD::SimPoint3D rearRight;
        };

        SIMONE_API void setHdmapLoad();

        SIMONE_API bool LoadHDMap(int timeOutSeconds);

        SIMONE_API bool GetNearMostLane(const SSD::SimPoint3D& pos, SSD::SimString& id, double& s, double& t, double& s_toCenterLine, double& t_toCenterLine);

        SIMONE_API bool GetNearLanes(const SSD::SimPoint3D& pos, const double& distance, SSD::SimStringVector& nearLanes);

        SIMONE_API bool GetNearLanesWithAngle(const SSD::SimPoint3D& pos, const double& distance,
                                      const double& headingAngle, const double& angleShift, SSD::SimStringVector& nearLanes);

        SIMONE_API bool GetDistanceToLaneBoundary(const SSD::SimPoint3D& pos, SSD::SimString& id, double& distToLeft, double& distToRight, double& distToLeft2D, double& distToRight2D);

        SIMONE_API bool GetLaneSample(const SSD::SimString &id, HDMapStandalone::MLaneInfo& info);

        SIMONE_API bool GetLaneLink(const SSD::SimString& id, HDMapStandalone::MLaneLink& laneLink);

        SIMONE_API bool GetLaneType(const SSD::SimString& id, HDMapStandalone::MLaneType& laneType);

        SIMONE_API bool GetLaneWidth(const SSD::SimString& id, const SSD::SimPoint3D& pos, double& width);

        SIMONE_API bool GetLaneST(const SSD::SimString& id, const SSD::SimPoint3D& pos, double& s, double& t);

        SIMONE_API bool GetRoadST(const SSD::SimString& id, const SSD::SimPoint3D& pos, double& s, double& t, double& z);

        SIMONE_API bool GetInertialFromLaneST(const SSD::SimString& id, const double& s, const double& t, SSD::SimPoint3D& inertial, SSD::SimPoint3D& dir);

        SIMONE_API bool ContainsLane(const SSD::SimString& id);

        SIMONE_API void GetParkingSpaceList(SSD::SimVector<HDMapStandalone::MParkingSpace>& parkingSpaceList);

        SIMONE_API bool GenerateRoute(const SSD::SimPoint3DVector& inputPoints, SSD::SimVector<int>& indexOfValidPoints, SSD::SimPoint3DVector& route);

        SIMONE_API bool Navigate(const SSD::SimPoint3DVector& inputPoints, SSD::SimVector<int>& indexOfValidPoints, SSD::SimVector<long>& roadIdList);

        SIMONE_API bool GetRoadMark(const SSD::SimPoint3D& pos, const SSD::SimString& id, HDMapStandalone::MRoadMark& left, HDMapStandalone::MRoadMark& right);

        SIMONE_API void GetTrafficLightList(SSD::SimVector<HDMapStandalone::MSignal>& list);

        SIMONE_API void GetTrafficSignList(SSD::SimVector<HDMapStandalone::MSignal>& list);

        SIMONE_API void GetStoplineList(const HDMapStandalone::MSignal& light, const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MObject>& stoplineList);

        SIMONE_API void GetCrosswalkList(const HDMapStandalone::MSignal& light, const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MObject>& crosswalkList);

        SIMONE_API void GetCrossHatchList(const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MObject>& crossHatchList);

        SIMONE_API bool GetLaneMiddlePoint(const SSD::SimPoint3D& inputPt, const SSD::SimString& id, SSD::SimPoint3D& targetPoint, SSD::SimPoint3D& dir);

        SIMONE_API bool GetHeights(const SSD::SimPoint3D& inputPt, const double& radius, SSD::SimVector<double>& heights,
                          SSD::SimVector<long>& roadIds, SSD::SimVector<bool>& insideRoadStates);

        // %%%%%%%%%%%% V2 Add %%%%%%%%%%%%
        SIMONE_API void GetLaneData(SSD::SimVector<HDMapStandalone::MLaneInfo>& data);

        SIMONE_API void GetJunctionList(SSD::SimVector<long>& juncList);

        SIMONE_API double GetRoadLength(const long& roadId);

        SIMONE_API bool GetSectionLaneList(const SSD::SimString& laneId, SSD::SimStringVector& sectionLaneList);

        SIMONE_API bool IsTwoSideRoad(const long& roadId);

        SIMONE_API double GetLaneLength(const SSD::SimString& id);

        SIMONE_API bool IsDriving(const SSD::SimString& id);

        SIMONE_API bool IsInJunction(const SSD::SimString& id, long& juncId);

        SIMONE_API bool IsInsideLane(const SSD::SimPoint3D& inputPt, const SSD::SimString& laneName, HDMapStandalone::MSideState& sideState);

        // %%%%%%%%%%%% V3 Add %%%%%%%%%%%%
        SIMONE_API bool GetLaneSampleByLocation(const SSD::SimPoint3D& pos, HDMapStandalone::MLaneInfo& info);

        //%%%%%%%%%%%%%% V4 Add %%%%%%%%%%%%%%%

        SIMONE_API void GetLaneLineInfo(SSD::SimVector<HDMapStandalone::MLaneLineInfo> & data);

        SIMONE_API void GetSpecifiedLaneCrosswalkList(const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MObject>& crosswalkList);

        SIMONE_API void GetSpecifiedLaneStoplineList(const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MObject>& stoplineList);

        SIMONE_API void GetSpecifiedLaneTrafficSignalList(const SSD::SimString& id, SSD::SimVector<HDMapStandalone::MSignal>& list);

        SIMONE_API void GetSpecifiedLaneTrafficLightList(const SSD::SimString & id, SSD::SimVector<HDMapStandalone::MSignal>& list);

        SIMONE_API bool GetParkingSpaceIds(const SSD::SimPoint3D& inputPt, double distance, SSD::SimStringVector& ids);

        SIMONE_API bool GetForwardLaneSample(const SSD::SimPoint3D& inputPt, const SSD::SimString& id, const double& forward,
                                     SSD::SimVector<HDMapStandalone::MLaneInfo>& laneInfoList);

        SIMONE_API void GetSignalListOnLaneByType(const SSD::SimString& laneName, const SSD::SimString& type, SSD::SimVector<HDMapStandalone::MSignal> & signalInfo);

        SIMONE_API void GetLaneList(const long& roadId, SSD::SimStringVector &laneList);

        SIMONE_API void GetJunction(const long& junctionId, HDMapStandalone::MJunction &junction);

        SIMONE_API bool GenerateRoute_V2(const SSD::SimPoint3DVector& inputPoints, SSD::SimVector<int>& indexOfValidPoints,
                                HDMapStandalone::MRoutePath &path, SSD::SimVector<HDMapStandalone::MRoutePoint>& routePtList);

        //~~~~~~~~~~~~~~~~~~~ADD~~~~~~~~~~~~~~~~~~~~~
        SIMONE_API bool IsOverlapLaneLine(const SSD::SimPoint3D& pos, const double& radius, SSD::SimString& id);

        SIMONE_API LaneInfo GetForwardLaneInfo(const SSD::SimPoint3D& pos, const TyrePosInfo& tyrePosInfo, const double& forward);

        SIMONE_API bool GetTopoGraph(HDMapStandalone::MTopoGraph& topoGraph);

        SIMONE_API void GetSectionList(const long& roadId, SSD::SimStringVector& rightList, SSD::SimStringVector& leftList);
    }
#ifdef __cplusplus
}
#endif
#endif