Browse Source

change map_lanetoxodr. add signal structure for opendrive. change ADCIntelligentShow_grpc, change ui.

yuchuli 4 years ago
parent
commit
6e3f061b76

+ 141 - 39
src/tool/map_lanetoxodr/OpenDrive/ObjectSignal.cpp

@@ -1,5 +1,6 @@
 #include "ObjectSignal.h"
 
+#include <iostream>
 
 signal_positionRoad::signal_positionRoad(double s, double t, double zOffset, double hOffset, double pitch, double roll)
 {
@@ -142,10 +143,36 @@ void signal_positionInertial::Setroll(double roll)
 }
 
 
+signal_laneValidity::signal_laneValidity(int fromLane,int toLane)
+{
+    mfromLane = fromLane;
+    mtoLane = toLane;
+}
+
+int signal_laneValidity::GetfromLane()
+{
+    return mfromLane;
+}
+
+int signal_laneValidity::GettoLane()
+{
+    return mtoLane;
+}
+
+void signal_laneValidity::SetfromLane(int fromLane)
+{
+    mfromLane = fromLane;
+}
+
+void signal_laneValidity::SettoLane(int toLane)
+{
+    mtoLane = toLane;
+}
+
 
 Signal::Signal(double s, double t, std::string id, std::string name, bool dynamic,string orientation,
-               double zOffset, int type, std::string country, std::string countryRevision,
-               int subtype, double hOffset, double pitch, double roll, double height, double width)
+               double zOffset, string type, std::string country, std::string countryRevision,
+               string subtype, double hOffset, double pitch, double roll, double height, double width)
 {
     ms = s;
     mt = t;
@@ -163,45 +190,102 @@ Signal::Signal(double s, double t, std::string id, std::string name, bool dynami
     mroll = roll;
     mheight = height;
     mwidth = width;
+    mpsignal_laneValidity = 0;
     mpsignal_positionInertial = 0;
     mpsignal_positionRoad = new signal_positionRoad(s,t,zOffset,hOffset,pitch,roll);
 }
 
+Signal::Signal()
+{
+    mpsignal_positionInertial = 0;
+    mpsignal_positionRoad = 0;
+    mpsignal_laneValidity = 0;
+
+}
 Signal::~Signal()
 {
-//    if(mpsignal_positionInertial != 0)delete mpsignal_positionInertial;
-//    if(mpsignal_positionRoad != 0)delete mpsignal_positionRoad;
-}
-
-//Signal& Signal::operator=(const Signal& x)
-//{
-//    if (this != &x)
-//    {
-//        this->Sets(x.Gets());
-//        ms = x.Gets();
-//        mt = x.Gett();
-//        mid = x.Getid();
-//        mname = x.Getname();
-//        mdynamic = x.Getdynamic();
-//        morientation = x.Getorientation();
-//        mzOffset = x.GetzOffset();
-//        mtype = x.Gettype();
-//        mcountry = x.Getcountry();
-//        mcountryRevision = x.GetcountryRevision();
-//        msubtype = x.Getsubtype();
-//        mhOffset = x.GethOffset();
-//        mpitch = x.Getpitch();
-//        mroll = x.Getroll();
-//        mheight = x.Getheight();
-//        mwidth = x.Getwidth();
-//        mpsignal_positionInertial = 0;
-//        signal_positionRoad * p = x.GetpositionRoad();
-//        mpsignal_positionRoad = new signal_positionRoad(p->Gets(),p->Gett(),
-//                                                        p->GetzOffset(),p->GethOffset(),
-//                                                        p->Getpitch(),p->Getroll());
-//    }
-//    return *this;
-//}
+    if(mpsignal_laneValidity != 0)delete mpsignal_laneValidity;
+    if(mpsignal_positionInertial != 0)delete mpsignal_positionInertial;
+    if(mpsignal_positionRoad != 0)delete mpsignal_positionRoad;
+}
+
+Signal& Signal::operator=(const Signal& x)
+{
+    if (this != &x)
+    {
+        this->ms = x.ms;
+        this->mt = x.mt;
+        this->mid = x.mid;
+        this->mname = x.mname;
+        this->mdynamic = x.mdynamic;
+        this->morientation = x.morientation;
+        this->mzOffset = x.mzOffset;
+        this->mtype = x.mtype;
+        this->mcountry = x.mcountry;
+        this->mcountryRevision = x.mcountryRevision;
+        this->msubtype = x.msubtype;
+        this->mhOffset = x.mhOffset;
+        this->mpitch = x.mpitch;
+        this->mroll = x.mroll;
+        this->mheight = x.mheight;
+        this->mwidth = x.mwidth;
+        this->mpsignal_positionInertial = 0;
+        if(x.mpsignal_positionInertial != 0)
+        {
+            this->mpsignal_positionInertial = new signal_positionInertial(x.mpsignal_positionInertial->Getx(),
+                                                                      x.mpsignal_positionInertial->Gety(),
+                                                                      x.mpsignal_positionInertial->Getz(),
+                                                                      x.mpsignal_positionInertial->Gethdg(),
+                                                                      x.mpsignal_positionInertial->Getpitch(),
+                                                                      x.mpsignal_positionInertial->Getroll());
+        }
+        this->mpsignal_laneValidity = 0;
+        if(x.mpsignal_laneValidity != 0)
+        {
+            this->mpsignal_laneValidity = new signal_laneValidity(x.mpsignal_laneValidity->GetfromLane(),
+                                                              x.mpsignal_laneValidity->GettoLane());
+        }
+        this->mpsignal_positionRoad = new signal_positionRoad(ms,mt,mzOffset,mhOffset,mpitch,mroll);
+    }
+    return *this;
+}
+
+Signal::Signal(const Signal &x)
+{
+    ms = x.ms;
+    mt = x.mt;
+    mid = x.mid;
+    mname = x.mname;
+    mdynamic = x.mdynamic;
+    morientation = x.morientation;
+    mzOffset = x.mzOffset;
+    mtype = x.mtype;
+    mcountry = x.mcountry;
+    mcountryRevision = x.mcountryRevision;
+    msubtype = x.msubtype;
+    mhOffset = x.mhOffset;
+    mpitch = x.mpitch;
+    mroll = x.mroll;
+    mheight = x.mheight;
+    mwidth = x.mwidth;
+    this->mpsignal_positionInertial = 0;
+    if(x.mpsignal_positionInertial != 0)
+    {
+        this->mpsignal_positionInertial = new signal_positionInertial(x.mpsignal_positionInertial->Getx(),
+                                                                  x.mpsignal_positionInertial->Gety(),
+                                                                  x.mpsignal_positionInertial->Getz(),
+                                                                  x.mpsignal_positionInertial->Gethdg(),
+                                                                  x.mpsignal_positionInertial->Getpitch(),
+                                                                  x.mpsignal_positionInertial->Getroll());
+    }
+    this->mpsignal_laneValidity = 0;
+    if(x.mpsignal_laneValidity != 0)
+    {
+        this->mpsignal_laneValidity = new signal_laneValidity(x.mpsignal_laneValidity->GetfromLane(),
+                                                          x.mpsignal_laneValidity->GettoLane());
+    }
+    mpsignal_positionRoad = new signal_positionRoad(ms,mt,mzOffset,mhOffset,mpitch,mroll);
+}
 
 double Signal::Gets()
 {
@@ -238,7 +322,7 @@ double Signal::GetzOffset()
     return mzOffset;
 }
 
-int Signal::Gettype()
+string Signal::Gettype()
 {
     return mtype;
 }
@@ -253,7 +337,7 @@ string Signal::GetcountryRevision()
     return mcountryRevision;
 }
 
-int Signal::Getsubtype()
+string Signal::Getsubtype()
 {
     return msubtype;
 }
@@ -328,7 +412,7 @@ void Signal::SetzOffset(double zOffset)
     mzOffset = zOffset;
 }
 
-void Signal::Settype(int type)
+void Signal::Settype(string type)
 {
     mtype = type;
 }
@@ -343,7 +427,7 @@ void Signal::SetcountryRevision(std::string countryRevision)
     mcountryRevision = countryRevision;
 }
 
-void Signal::Setsubtype(int subtype)
+void Signal::Setsubtype(string subtype)
 {
     msubtype = subtype;
 }
@@ -373,6 +457,19 @@ void Signal::Setwidth(double width)
     mwidth = width;
 }
 
+void Signal::SetlaneValidity(int fromLane, int toLane)
+{
+    if(mpsignal_laneValidity == 0)
+    {
+        mpsignal_laneValidity = new signal_laneValidity(fromLane,toLane);
+    }
+    else
+    {
+        mpsignal_laneValidity->SetfromLane(fromLane);
+        mpsignal_laneValidity->SettoLane(toLane);
+    }
+}
+
 void Signal::SetpositionRoad(double s, double t, double zOffset, double hOffset, double pitch,double roll)
 {
     if(mpsignal_positionRoad == 0)
@@ -407,6 +504,11 @@ void Signal::SetpositionInertial(double x, double y, double z, double hdg, doubl
     }
 }
 
+signal_laneValidity * Signal::GetlaneValidity()
+{
+    return mpsignal_laneValidity;
+}
+
 
 
 

+ 26 - 9
src/tool/map_lanetoxodr/OpenDrive/ObjectSignal.h

@@ -70,6 +70,18 @@ public:
     void Setroll(double roll);
 };
 
+class signal_laneValidity
+{
+private:
+    int mfromLane;
+    int mtoLane;
+public:
+    signal_laneValidity(int fromLane,int toLane);
+    int GetfromLane();
+    int GettoLane();
+    void SetfromLane(int fromLane);
+    void SettoLane(int toLane);
+};
 
 
 //***********************************************************************************
@@ -85,10 +97,10 @@ private:
     bool mdynamic;
     string morientation;
     double mzOffset;
-    int mtype;
+    string mtype;
     string mcountry;
     string mcountryRevision;
-    int msubtype;
+    string msubtype;
     double mhOffset;
     double mpitch;
     double mroll;
@@ -96,11 +108,14 @@ private:
     double mwidth;
     signal_positionRoad * mpsignal_positionRoad;
     signal_positionInertial * mpsignal_positionInertial;
+    signal_laneValidity * mpsignal_laneValidity;
 public:
-    Signal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,int type,string country,string countryRevision,
-           int subtype,double hOffset,double pitch,double roll ,double height,double width);
+    Signal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,string type,string country,string countryRevision,
+           string subtype,double hOffset,double pitch,double roll ,double height,double width);
+    Signal();
     ~Signal();
-//    Signal& operator=(const Signal& x);
+    Signal& operator=(const Signal& x);
+    Signal(const Signal & x);
     double Gets();
     double Gett();
     string Getid();
@@ -108,10 +123,10 @@ public:
     bool Getdynamic();
     string Getorientation();
     double GetzOffset();
-    int Gettype();
+    string Gettype();
     string Getcountry();
     string GetcountryRevision();
-    int Getsubtype();
+    string Getsubtype();
     double GethOffset();
     double Getpitch();
     double Getroll();
@@ -119,6 +134,7 @@ public:
     double Getwidth();
     signal_positionRoad * GetpositionRoad();
     signal_positionInertial * GetpositionInertial();
+    signal_laneValidity * GetlaneValidity();
     void Sets(double s);
     void Sett(double t);
     void Setid(string id);
@@ -126,15 +142,16 @@ public:
     void Setdynamic(bool dynamic);
     void Setorientation(string orientation);
     void SetzOffset(double zOffset);
-    void Settype(int type);
+    void Settype(string type);
     void Setcountry(string country);
     void SetcountryRevision(string countryRevision);
-    void Setsubtype(int subtype);
+    void Setsubtype(string subtype);
     void SethOffset(double hOffset);
     void Setpitch(double pitch);
     void Setroll(double roll);
     void Setheight(double height);
     void Setwidth(double width);
+    void SetlaneValidity(int fromLane, int toLane);
     void SetpositionRoad(double s,double t, double zOffset,double hOffset,double pitch,double roll);
     void SetpositionInertial(double x,double y, double z, double hdg,double pitch,double roll);
 

+ 55 - 4
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlParser.cpp

@@ -937,10 +937,10 @@ bool OpenDriveXmlParser::ReadSignal(Road *road, TiXmlElement *node)
     string strdynamic;
     string orientation;
     double zOffset;
-    int type;
+    string type;
     string country;
     string countryRevision;
-    int subtype;
+    string subtype;
     double hOffset;
     double pitch;
     double roll;
@@ -955,10 +955,10 @@ bool OpenDriveXmlParser::ReadSignal(Road *road, TiXmlElement *node)
     checker+=node->QueryStringAttribute("dynamic",&strdynamic);
     checker+=node->QueryStringAttribute("orientation",&orientation);
     checker+=node->QueryDoubleAttribute("zOffset",&zOffset);
-    checker+=node->QueryIntAttribute("type",&type);
+    checker+=node->QueryStringAttribute("type",&type);
     checker+=node->QueryStringAttribute("country",&country);
     checker+=node->QueryStringAttribute("countryRevision",&countryRevision);
-    checker+=node->QueryIntAttribute("subtype",&subtype);
+    checker+=node->QueryStringAttribute("subtype",&subtype);
     checker+=node->QueryDoubleAttribute("hOffset",&hOffset);
     checker+=node->QueryDoubleAttribute("pitch",&pitch);
     checker+=node->QueryDoubleAttribute("roll",&roll);
@@ -973,8 +973,59 @@ bool OpenDriveXmlParser::ReadSignal(Road *road, TiXmlElement *node)
     else dynamic = true;
     road->AddSignal(s,t,id,name,dynamic,orientation,zOffset,type,country,countryRevision,subtype,hOffset,
                     pitch,roll,height,width);
+
+    Signal * pSignal = road->GetSignal(road->GetSignalCount() - 1);
+    TiXmlElement * subNode;
+    //Proceed to Signals
+    subNode=node->FirstChildElement("validity");
+    if (subNode)
+    {
+        ReadSignal_laneValidity(pSignal, subNode);
+    }
+    subNode=node->FirstChildElement("positionInertial");
+    if(subNode)
+    {
+        ReadSignal_positionInertial(pSignal,subNode);
+    }
+    return true;
+}
+
+bool OpenDriveXmlParser::ReadSignal_laneValidity(Signal *pSignal, TiXmlElement *node)
+{
+    int fromLane;
+    int toLane;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryIntAttribute("fromLane",&fromLane);
+    checker+=node->QueryIntAttribute("toLane",&toLane);
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing laneValidity attributes"<<endl;
+        return false;
+    }
+    pSignal->SetlaneValidity(fromLane,toLane);
     return true;
 }
+
+bool OpenDriveXmlParser::ReadSignal_positionInertial(Signal *pSignal, TiXmlElement *node)
+{
+    double x,y,z,hdg,pitch,roll;
+    int checker=TIXML_SUCCESS;
+    checker+=node->QueryDoubleAttribute("x",&x);
+    checker+=node->QueryDoubleAttribute("y",&y);
+    checker+=node->QueryDoubleAttribute("z",&z);
+    checker+=node->QueryDoubleAttribute("hdg",&hdg);
+    checker+=node->QueryDoubleAttribute("pitch",&pitch);
+    checker+=node->QueryDoubleAttribute("roll",&roll);
+    if (checker!=TIXML_SUCCESS)
+    {
+        cout<<"Error parsing positionInertial attributes"<<endl;
+        return false;
+    }
+    pSignal->SetpositionInertial(x,y,z,hdg,pitch,roll);
+    return true;
+}
+
+
 //--------------
 
 bool OpenDriveXmlParser::ReadSurface (Road* road, TiXmlElement *node)

+ 2 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlParser.h

@@ -65,6 +65,8 @@ public:
 	bool ReadObjects (Road* road, TiXmlElement *node);
 	bool ReadSignals (Road* road, TiXmlElement *node);
     bool ReadSignal(Road * road,TiXmlElement * node);
+    bool ReadSignal_positionInertial(Signal * pSignal, TiXmlElement *node);
+    bool ReadSignal_laneValidity(Signal * pSignal,TiXmlElement * node);
 	//--------------
 
 	bool ReadSurface (Road* road, TiXmlElement *node);

+ 41 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.cpp

@@ -953,8 +953,49 @@ bool OpenDriveXmlWriter::WriteSignal(TiXmlElement *node, Signal * pSignal)
     nodeSignal->SetAttribute("height",pSignal->Getheight());
     nodeSignal->SetAttribute("width",pSignal->Getwidth());
 
+    signal_laneValidity * psignal_lanevalidity = pSignal->GetlaneValidity();
+    if(psignal_lanevalidity != 0)
+    {
+        WriteSignal_laneValidity(nodeSignal,psignal_lanevalidity);
+    }
+
+    signal_positionInertial * psignal_positionInertial = pSignal->GetpositionInertial();
+    if(psignal_positionInertial != 0)
+    {
+        WriteSignal_positionInertial(nodeSignal,psignal_positionInertial);
+    }
+
     return true;
 }
+
+bool OpenDriveXmlWriter::WriteSignal_positionInertial(TiXmlElement *node, signal_positionInertial *pSignal_positionInertial)
+{
+    TiXmlElement* nodepositionInertial = new TiXmlElement("positionInertial");
+
+    node->LinkEndChild(nodepositionInertial);
+
+    nodepositionInertial->SetAttribute("x",pSignal_positionInertial->Getx());
+    nodepositionInertial->SetAttribute("y",pSignal_positionInertial->Gety());
+    nodepositionInertial->SetAttribute("z",pSignal_positionInertial->Getz());
+    nodepositionInertial->SetAttribute("hdg",pSignal_positionInertial->Gethdg());
+    nodepositionInertial->SetAttribute("pitch",pSignal_positionInertial->Getpitch());
+    nodepositionInertial->SetAttribute("roll",pSignal_positionInertial->Getroll());
+
+    return true;
+}
+
+bool OpenDriveXmlWriter::WriteSignal_laneValidity(TiXmlElement *node, signal_laneValidity *pSignal_laneValidity)
+{
+    TiXmlElement* nodelaneValidity = new TiXmlElement("validity");
+
+    node->LinkEndChild(nodelaneValidity);
+
+    nodelaneValidity->SetAttribute("x",pSignal_laneValidity->GetfromLane());
+    nodelaneValidity->SetAttribute("y",pSignal_laneValidity->GettoLane());
+
+    return true;
+}
+
 //--------------
 
 bool OpenDriveXmlWriter::WriteSurface (TiXmlElement *node, Road* road)

+ 2 - 0
src/tool/map_lanetoxodr/OpenDrive/OpenDriveXmlWriter.h

@@ -66,6 +66,8 @@ public:
 	bool WriteObjects (TiXmlElement *node, Road* road);
 	bool WriteSignals (TiXmlElement *node, Road* road);
     bool WriteSignal(TiXmlElement * node, Signal * pSignal);
+    bool WriteSignal_positionInertial(TiXmlElement * node, signal_positionInertial * pSignal_positionInertial);
+    bool WriteSignal_laneValidity(TiXmlElement * node, signal_laneValidity * pSignal_laneValidity);
 	//--------------
 
 	bool WriteSurface (TiXmlElement *node, Road* road);

+ 2 - 2
src/tool/map_lanetoxodr/OpenDrive/Road.cpp

@@ -610,8 +610,8 @@ unsigned int Road::AddObject()
 	return index;
 }
 //-------------
-unsigned int Road::AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,int type,string country,string countryRevision,
-                             int subtype,double hOffset,double pitch,double roll ,double height,double width)
+unsigned int Road::AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,string type,string country,string countryRevision,
+                             string subtype,double hOffset,double pitch,double roll ,double height,double width)
 {
 	// Check the first method in the group for details
 

+ 2 - 2
src/tool/map_lanetoxodr/OpenDrive/Road.h

@@ -229,8 +229,8 @@ public:
 	unsigned int AddCrossfall (string side, double s, double a, double b, double c, double d);
 	unsigned int AddLaneSection(double s);
 	unsigned int AddObject();
-    unsigned int AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,int type,string country,string countryRevision,
-                           int subtype,double hOffset,double pitch,double roll ,double height,double width);
+    unsigned int AddSignal(double s,double t,string id,string name,bool dynamic,string orientation,double zOffset,string type,string country,string countryRevision,
+                           string subtype,double hOffset,double pitch,double roll ,double height,double width);
 
 	/**
 	 * Methods used to clone child records in the respective vectors

+ 7 - 0
src/ui/ADCIntelligentShow_grpc/adcintelligentshow.cpp

@@ -325,6 +325,13 @@ void ADCIntelligentShow::resizeEvent(QResizeEvent *event)
     ui->pushButton_nextstation->setGeometry(380,30,100,50);
     ui->pushButton_go->setGeometry(490,30,100,50);
 #else
+
+//    ui->pushButton_prestation->setGeometry(30,30,150,100);
+//    ui->label_station->setGeometry(190,30,260,100);
+//    ui->pushButton_nextstation->setGeometry(460,30,150,100);
+//    ui->pushButton_go->setGeometry(630,30,150,100);
+
+
     ui->pushButton_prestation->setGeometry(50,30,200,100);
     ui->label_station->setGeometry(260,30,400,100);
     ui->pushButton_nextstation->setGeometry(680,30,200,100);

+ 14 - 4
src/ui/ADCIntelligentShow_grpc/adcintelligentshow.ui

@@ -788,14 +788,14 @@ color: rgb(200, 200, 200);</string>
      </property>
      <property name="font">
       <font>
-       <pointsize>15</pointsize>
+       <pointsize>8</pointsize>
       </font>
      </property>
      <property name="styleSheet">
       <string notr="true">color: rgb(255, 255, 255);</string>
      </property>
      <property name="text">
-      <string>北京汽车技师学院</string>
+      <string>中国汽车技术研究中心</string>
      </property>
      <property name="alignment">
       <set>Qt::AlignCenter</set>
@@ -804,12 +804,17 @@ color: rgb(200, 200, 200);</string>
     <widget class="QLabel" name="label_3">
      <property name="geometry">
       <rect>
-       <x>1480</x>
+       <x>1500</x>
        <y>6</y>
        <width>101</width>
        <height>31</height>
       </rect>
      </property>
+     <property name="font">
+      <font>
+       <pointsize>8</pointsize>
+      </font>
+     </property>
      <property name="styleSheet">
       <string notr="true">color: rgb(255, 255, 255);</string>
      </property>
@@ -823,12 +828,17 @@ color: rgb(200, 200, 200);</string>
     <widget class="QLabel" name="label_4">
      <property name="geometry">
       <rect>
-       <x>1360</x>
+       <x>1680</x>
        <y>6</y>
        <width>101</width>
        <height>31</height>
       </rect>
      </property>
+     <property name="font">
+      <font>
+       <pointsize>8</pointsize>
+      </font>
+     </property>
      <property name="styleSheet">
       <string notr="true">color: rgb(255, 255, 255);</string>
      </property>