Selaa lähdekoodia

cpp_pkgs add basicTest and some other cpp test files. cv_test minor changes. move wit_motion imu ros encryption. pcl_eigen_test add a basic pcl cloud transformation to check the calibration result.

youchen 5 vuotta sitten
vanhempi
commit
c489203f9f
100 muutettua tiedostoa jossa 5713 lisäystä ja 58 poistoa
  1. 36 3
      cpp_pkgs/CMakeLists.txt
  2. 106 55
      cpp_pkgs/src/basicTest.cpp
  3. 119 0
      cpp_pkgs/src/file_manager.cpp
  4. 2949 0
      cpp_pkgs/src/globalmsg.pb.cc
  5. 2144 0
      cpp_pkgs/src/globalmsg.pb.h
  6. 89 0
      cpp_pkgs/src/hw.cpp
  7. 74 0
      cpp_pkgs/src/inheritance.cpp
  8. 31 0
      cpp_pkgs/src/nnxx_testA.cpp
  9. 69 0
      cpp_pkgs/src/nnxx_testB.cpp
  10. 48 0
      cpp_pkgs/src/sharedMemoryA.cpp
  11. 46 0
      cpp_pkgs/src/sharedMemoryB.cpp
  12. 2 0
      cv_test/CMakeLists.txt
  13. BIN
      cv_test/oxygen/清凉的外世_cycle_0000.png
  14. BIN
      cv_test/oxygen/清凉的外世_cycle_0001.png
  15. BIN
      cv_test/oxygen/清凉的外世_cycle_0002.png
  16. BIN
      cv_test/oxygen/清凉的外世_cycle_0003.png
  17. BIN
      cv_test/oxygen/清凉的外世_cycle_0004.png
  18. BIN
      cv_test/oxygen/清凉的外世_cycle_0005.png
  19. BIN
      cv_test/oxygen/清凉的外世_cycle_0006.png
  20. BIN
      cv_test/oxygen/清凉的外世_cycle_0007.png
  21. BIN
      cv_test/oxygen/清凉的外世_cycle_0008.png
  22. BIN
      cv_test/oxygen/清凉的外世_cycle_0009.png
  23. BIN
      cv_test/oxygen/清凉的外世_cycle_0010.png
  24. BIN
      cv_test/oxygen/清凉的外世_cycle_0011.png
  25. BIN
      cv_test/oxygen/清凉的外世_cycle_0012.png
  26. BIN
      cv_test/oxygen/清凉的外世_cycle_0013.png
  27. BIN
      cv_test/oxygen/清凉的外世_cycle_0014.png
  28. BIN
      cv_test/oxygen/清凉的外世_cycle_0015.png
  29. BIN
      cv_test/oxygen/清凉的外世_cycle_0016.png
  30. BIN
      cv_test/oxygen/清凉的外世_cycle_0017.png
  31. BIN
      cv_test/oxygen/清凉的外世_cycle_0018.png
  32. BIN
      cv_test/oxygen/清凉的外世_cycle_0019.png
  33. BIN
      cv_test/oxygen/清凉的外世_cycle_0020.png
  34. BIN
      cv_test/oxygen/清凉的外世_cycle_0021.png
  35. BIN
      cv_test/oxygen/清凉的外世_cycle_0022.png
  36. BIN
      cv_test/oxygen/清凉的外世_cycle_0023.png
  37. BIN
      cv_test/oxygen/清凉的外世_cycle_0024.png
  38. BIN
      cv_test/oxygen/清凉的外世_cycle_0025.png
  39. BIN
      cv_test/oxygen/清凉的外世_cycle_0026.png
  40. BIN
      cv_test/oxygen/清凉的外世_cycle_0027.png
  41. BIN
      cv_test/oxygen/清凉的外世_cycle_0028.png
  42. BIN
      cv_test/oxygen/清凉的外世_cycle_0029.png
  43. BIN
      cv_test/oxygen/清凉的外世_cycle_0030.png
  44. BIN
      cv_test/oxygen/清凉的外世_cycle_0031.png
  45. BIN
      cv_test/oxygen/清凉的外世_cycle_0032.png
  46. BIN
      cv_test/oxygen/清凉的外世_cycle_0033.png
  47. BIN
      cv_test/oxygen/清凉的外世_cycle_0034.png
  48. BIN
      cv_test/oxygen/清凉的外世_cycle_0035.png
  49. BIN
      cv_test/oxygen/清凉的外世_cycle_0036.png
  50. BIN
      cv_test/oxygen/清凉的外世_cycle_0037.png
  51. BIN
      cv_test/oxygen/清凉的外世_cycle_0038.png
  52. BIN
      cv_test/oxygen/清凉的外世_cycle_0039.png
  53. BIN
      cv_test/oxygen/清凉的外世_cycle_0040.png
  54. BIN
      cv_test/oxygen/清凉的外世_cycle_0041.png
  55. BIN
      cv_test/oxygen/清凉的外世_cycle_0042.png
  56. BIN
      cv_test/oxygen/清凉的外世_cycle_0043.png
  57. BIN
      cv_test/oxygen/清凉的外世_cycle_0044.png
  58. BIN
      cv_test/oxygen/清凉的外世_cycle_0045.png
  59. BIN
      cv_test/oxygen/清凉的外世_cycle_0046.png
  60. BIN
      cv_test/oxygen/清凉的外世_cycle_0047.png
  61. BIN
      cv_test/oxygen/清凉的外世_cycle_0048.png
  62. BIN
      cv_test/oxygen/清凉的外世_cycle_0049.png
  63. BIN
      cv_test/oxygen/清凉的外世_cycle_0050.png
  64. BIN
      cv_test/oxygen/清凉的外世_cycle_0055.png
  65. BIN
      cv_test/oxygen/清凉的外世_cycle_0060.png
  66. BIN
      cv_test/oxygen/清凉的外世_cycle_0062.png
  67. BIN
      cv_test/oxygen/清凉的外世_cycle_0065.png
  68. BIN
      cv_test/oxygen/清凉的外世_cycle_0070.png
  69. BIN
      cv_test/oxygen/清凉的外世_cycle_0075.png
  70. BIN
      cv_test/oxygen/清凉的外世_cycle_0080.png
  71. BIN
      cv_test/oxygen/清凉的外世_cycle_0084.png
  72. BIN
      cv_test/oxygen/清凉的外世_cycle_0085.png
  73. BIN
      cv_test/oxygen/清凉的外世_cycle_0090.png
  74. BIN
      cv_test/oxygen/清凉的外世_cycle_0095.png
  75. BIN
      cv_test/oxygen/清凉的外世_cycle_0099.png
  76. BIN
      cv_test/oxygen/清凉的外世_cycle_0100.png
  77. BIN
      cv_test/oxygen/清凉的外世_cycle_0110.png
  78. BIN
      cv_test/oxygen/清凉的外世_cycle_0116.png
  79. BIN
      cv_test/oxygen/清凉的外世_cycle_0120.png
  80. BIN
      cv_test/oxygen/清凉的外世_cycle_0127.png
  81. BIN
      cv_test/oxygen/清凉的外世_cycle_0130.png
  82. BIN
      cv_test/oxygen/清凉的外世_cycle_0133.png
  83. BIN
      cv_test/oxygen/清凉的外世_cycle_0140.png
  84. BIN
      cv_test/oxygen/清凉的外世_cycle_0146.png
  85. BIN
      cv_test/oxygen/清凉的外世_cycle_0150.png
  86. BIN
      cv_test/oxygen/清凉的外世_cycle_0160.png
  87. BIN
      cv_test/oxygen/清凉的外世_cycle_0165.png
  88. BIN
      cv_test/oxygen/清凉的外世_cycle_0170.png
  89. BIN
      cv_test/oxygen/清凉的外世_cycle_0180.png
  90. BIN
      cv_test/oxygen/清凉的外世_cycle_0190.png
  91. BIN
      cv_test/oxygen/清凉的外世_cycle_0200.png
  92. BIN
      cv_test/oxygen/清凉的外世_cycle_0203.png
  93. BIN
      cv_test/oxygen/清凉的外世_cycle_0210.png
  94. BIN
      cv_test/oxygen/清凉的外世_cycle_0220.png
  95. BIN
      cv_test/oxygen/清凉的外世_cycle_0230.png
  96. BIN
      cv_test/oxygen/清凉的外世_cycle_0240.png
  97. BIN
      cv_test/oxygen/清凉的外世_cycle_0250.png
  98. BIN
      cv_test/oxygen/清凉的外世_cycle_0260.png
  99. BIN
      cv_test/oxygen/清凉的外世_cycle_0270.png
  100. 0 0
      cv_test/oxygen/清凉的外世_cycle_0280.png

+ 36 - 3
cpp_pkgs/CMakeLists.txt

@@ -2,12 +2,16 @@ cmake_minimum_required(VERSION 2.8.3)
 project(cpp_pkgs)
 
 ## Compile as C++11, supported in ROS Kinetic and newer
-# add_compile_options(-std=c++11)
+add_compile_options(-std=c++11)
 
 ## Find catkin macros and libraries
 ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
 ## is used, also find other catkin packages
+FIND_PACKAGE(Protobuf REQUIRED)
+FIND_PACKAGE(Glog REQUIRED)
 find_package(catkin REQUIRED)
+find_package(Boost REQUIRED COMPONENTS system thread)
+find_package(PCL REQUIRED)
 
 ## System dependencies are found with CMake's conventions
 # find_package(Boost REQUIRED COMPONENTS system)
@@ -112,8 +116,12 @@ catkin_package(
 ## Specify additional locations of header files
 ## Your package locations should be listed before other locations
 include_directories(
-# include
-# ${catkin_INCLUDE_DIRS}
+include
+${catkin_INCLUDE_DIRS}
+${Boost_INCLUDE_DIRS}
+${PCL_INCLUDE_DIRS}
+/usr/local/include
+./
 )
 
 ## Declare a C++ library
@@ -130,8 +138,33 @@ include_directories(
 ## With catkin_make all packages are built within a single CMake context
 ## The recommended prefix ensures that target names across packages don't collide
 # add_executable(${PROJECT_NAME}_node src/cpp_pkgs_node.cpp)
+
+link_directories(/usr/local/lib/)
+
 add_executable(basicTest src/basicTest.cpp)
 
+add_executable(inheritance src/inheritance.cpp)
+
+add_executable(shmA src/sharedMemoryA.cpp)
+target_link_libraries(shmA ${catkin_LIBRARIES} ${Boost_LIBRARIES})
+
+add_executable(shmB src/sharedMemoryB.cpp)
+target_link_libraries(shmB ${catkin_LIBRARIES} ${Boost_LIBRARIES})
+
+# nnxx rep-req tests
+add_executable(nnxx_server src/nnxx_testA.cpp)
+target_link_libraries(nnxx_server ${catkin_LIBRARIES} ${Boost_LIBRARIES} libnnxx.a libnanomsg.so)
+
+add_executable(nnxx_client src/nnxx_testB.cpp src/globalmsg.pb.cc)
+target_link_libraries(nnxx_client ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${PROTOBUF_LIBRARIES} libnnxx.a libnanomsg.so)
+
+
+add_executable(hw src/hw.cpp)
+target_link_libraries(hw ${catkin_LIBRARIES})
+
+add_executable(file_manager src/file_manager.cpp)
+target_link_libraries(file_manager ${catkin_LIBRARIES} ${PCL_LIBRARIES})
+
 ## Rename C++ executable without prefix
 ## The above recommended prefix causes long target names, the following renames the
 ## target back to the shorter version for ease of user use

+ 106 - 55
cpp_pkgs/src/basicTest.cpp

@@ -2,6 +2,7 @@
 #ifndef __BASICTEST_CPP__
 #define __BASICTEST_CPP__
 #include <iostream>
+#include <iomanip>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -19,69 +20,119 @@ void _assert(char * cond, char *fname, long lineno){
     abort();
 }
 
-int main(){
-    int mmm = 10;
-    assert((mmm<11));
-    int a[] = {0,1,2,3,4};
-    // traverse
-    size_t n = sizeof a / sizeof a[0];
-    for (size_t i = 0; i < n; i++)
+bool GetMemory(char **p)
+{
+    *p = (char *)malloc(20);
+    if(*p == NULL) return false;
+    else return true;
+}
+ 
+void Test1(void)
+{
+    char *str = NULL;
+    GetMemory(&str);
+    strcpy(str, "hello world\n");
+    printf("%s",str);
+    free(str);
+    if (str != NULL)
     {
-        std::cout<<a[i]<<' ';
+        str = NULL;
     }
-    std::cout<<std::endl;
+}
 
-    //pointer
-    int *ppp = a+n-1;
-    // inverse traverse
-    while(ppp>=a){
-        std::cout << *ppp--<<' ';
-    }
-    std::cout<<std::endl;
-    ppp = a+n-1;
-    for (size_t i = 0; i < n; i++)
-    {
-        std::cout << ppp[-i]<<' ';
-    }
-    std::cout<<std::endl;
+char * GetString()
+{
+    char *p = "hello world\n";
+    return p;
+}
 
-    //test 2.2
-    char s[] = "desolate", *p = s;
-    std::cout<<*p++<<std::endl;//d
-    std::cout<<*p<<std::endl;//e
-    std::cout<<*(p++)<<std::endl;//e
-    std::cout<<*p<<std::endl;//s
-    std::cout<<(*p)++<<std::endl;//s
-    std::cout<<*p<<std::endl;//t
-    std::cout<<*++p<<std::endl;//o
-    std::cout<<*p<<std::endl;//o
-    std::cout<<*(++p)<<std::endl;//l
-    std::cout<<*p<<std::endl;//l
-    std::cout<<++*p<<std::endl;//m
-    std::cout<<++(*p)<<std::endl;//n
-    std::cout<<strcmp(s, "detonate")<<std::endl;//0
+void Test5(){
+    char *str = NULL;
+    str = GetString();
+    std::cout<<str<<std::endl;
+}
+
+int main(){
+    { // origin
+        int mmm = 10;
+        assert((mmm < 11));
+        int a[] = {0, 1, 2, 3, 4};
+        // traverse
+        size_t n = sizeof a / sizeof a[0];
+        for (size_t i = 0; i < n; i++)
+        {
+            std::cout << a[i] << ' ';
+        }
+        std::cout << std::endl;
+
+        //pointer
+        int *ppp = a + n - 1;
+        // inverse traverse
+        while (ppp >= a)
+        {
+            std::cout << *ppp-- << ' ';
+        }
+        std::cout << std::endl;
+        ppp = a + n - 1;
+        for (size_t i = 0; i < n; i++)
+        {
+            std::cout << ppp[-i] << ' ';
+        }
+        std::cout << std::endl;
 
-    int arr[][2][3] = {{{0,1},{2,3}},{{4,5},{6,7}},{{8,9},{10,11}}};
-    int (*par)[2][3] = arr;
-    void *vp;
-    std::cout<<sizeof par<<' '<<sizeof vp<<std::endl;//8
-    vp = (char *)arr[0][0];
-    std::cout<<sizeof (*par) <<std::endl;//24
-    std::cout<<sizeof vp<<std::endl;//8
+        //test 2.2
+        char s[] = "desolate", *p = s;
+        std::cout << *p++ << std::endl;                  //d
+        std::cout << *p << std::endl;                    //e
+        std::cout << *(p++) << std::endl;                //e
+        std::cout << *p << std::endl;                    //s
+        std::cout << (*p)++ << std::endl;                //s
+        std::cout << *p << std::endl;                    //t
+        std::cout << *++p << std::endl;                  //o
+        std::cout << *p << std::endl;                    //o
+        std::cout << *(++p) << std::endl;                //l
+        std::cout << *p << std::endl;                    //l
+        std::cout << ++*p << std::endl;                  //m
+        std::cout << ++(*p) << std::endl;                //n
+        std::cout << strcmp(s, "detonate") << std::endl; //0
 
+        int arr[][2][3] = {{{0, 1}, {2, 3}}, {{4, 5}, {6, 7}}, {{8, 9}, {10, 11}}};
+        int(*par)[2][3] = arr;
+        void *vp;
+        std::cout << sizeof par << ' ' << sizeof vp << std::endl; //8
+        vp = (char *)arr[0][0];
+        std::cout << sizeof(*par) << std::endl; //24
+        std::cout << sizeof vp << std::endl;    //8
 
-    std::cout<<"__DATE__: "<<__DATE__<<std::endl;
-    std::cout<<"__FILE__: "<<__FILE__<<std::endl;
-    std::cout<<"__LINE__: "<<__LINE__<<std::endl;
-    std::cout<<"__TIME__: "<<__TIME__<<std::endl;
+        std::cout << "__DATE__: " << __DATE__ << std::endl;
+        std::cout << "__FILE__: " << __FILE__ << std::endl;
+        std::cout << "__LINE__: " << __LINE__ << std::endl;
+        std::cout << "__TIME__: " << __TIME__ << std::endl;
 
-    int x = 66, x1=12;
-    trace(x, c);
-    trace2(1);
-    std::cout<<int(-2.5)<<std::endl;
-    //std::cout.setf(std::ios::hex, std::ios::basefield);
-    std::cout<< atan2(sin(1.58),cos(1.58))<<std::endl;
-    std::cout<< atan2(sin(-1.58),cos(-1.58))<<std::endl;
+        int x = 66, x1 = 12;
+        trace(x, c);
+        trace2(1);
+        std::cout << int(-2.5) << std::endl;
+        //std::cout.setf(std::ios::hex, std::ios::basefield);
+        std::cout << atan2(sin(1.58), cos(1.58)) << std::endl;
+        std::cout << atan2(sin(-1.58), cos(-1.58)) << std::endl;
+    }
+
+    // int => char[3] char[2] char[1] char[0]
+    union {
+        int test;
+        char c[3];
+    };
+    c[0] = 'a';
+    c[1] = 'b';
+    test = 5;
+    c[2] = 'c';
+    // 6488069(dec)=>0c05=>630005(hex)
+    std::cout << "" << std::dec << test << std::endl;
+    Test1();
+    Test5();
+    
 }
 
+
 #endif

+ 119 - 0
cpp_pkgs/src/file_manager.cpp

@@ -0,0 +1,119 @@
+/*
+ * @Description: basic file read and write class
+ * @Author: yct
+ * @Date: 2020-03-30 17:30:36
+ * @LastEditTime: 2020-03-30 23:15:43
+ * @LastEditors: yct
+ */
+#include <fstream>
+#include <iostream>
+#include <mutex>
+#include <string>
+#include <ctime>
+#include <pcl/point_types.h>
+#include <pcl/point_cloud.h>
+
+class File_manager
+{
+public:
+    // constructor
+    File_manager(){}
+    // destrutor
+    ~File_manager(){}
+    /**
+     * @description: read point cloud from a file
+     * @param filename: name of the file storing the point cloud
+     * @param pointcloud: pointcloud that store points read from the file
+     * @return: whether successfully get the points
+     */
+    bool read_pointcloud(std::string filename, pcl::PointCloud<pcl::PointXYZ>::Ptr &pointcloud)
+    {
+        // std::lock_guard<std::mutex> lck(m_cloud_mutex);
+        pointcloud->clear();
+        std::ifstream in(filename);
+        if (!in.is_open())
+        {
+            std::cout << "failed to open file " << filename << std::endl;
+            return false;
+        }
+        while (!in.eof())
+        {
+            std::string t_linestr;
+            if (getline(in, t_linestr))
+            {
+                std::vector<std::string> str_vector;
+                std::stringstream ss(t_linestr);
+                std::string num_str;
+                while (getline(ss, num_str, ' '))
+                {
+                    str_vector.push_back(num_str);
+                }
+                if (str_vector.size() != 3)
+                {
+                    std::cout << "unsupported point cloud / cannot find point x y z value: " << filename << std::endl;
+                    return false;
+                }
+                pcl::PointXYZ t_cloud;
+                t_cloud.x = stod(str_vector[0]);
+                t_cloud.y = stod(str_vector[1]);
+                t_cloud.z = stod(str_vector[2]);
+                pointcloud->push_back(t_cloud);
+            }
+        }
+        in.close();
+        std::cout << "file read finished with points " << pointcloud->size() << std::endl;
+        return true;
+    }
+    /**
+     * @description: record points to file
+     * @param pointcloud: point cloud that need to be saved in file
+     * @param filename: empty string by default, so that the filename will be auto-filled with current time 
+     * @return: whether successfully record points into the file
+     */
+    bool write_pointcloud(pcl::PointCloud<pcl::PointXYZ>::Ptr pointcloud, std::string filename="")
+    {
+        if(pointcloud->size() <= 0){
+            std::cout << "empty cloud."<< std::endl;
+            return false;
+        }
+        std::ofstream out;
+        time_t tt = time(0);
+        struct tm *tc = localtime(&tt);
+        char buf[255] = {0};
+        memset(buf, 0, 255);
+        sprintf(buf, "%d-%02d-%02d_%02d:%02d:%02d.txt", tc->tm_year + 1900,
+                tc->tm_mon + 1, tc->tm_mday, tc->tm_hour, tc->tm_min, tc->tm_sec);
+        if(filename == ""){
+            filename = std::string(buf);
+        }
+        out.open(filename, std::ios::out);
+        if(!out.is_open()){
+            std::cout << "cannot open file."<< std::endl;
+            return false;
+        }
+        for (size_t i = 0; i < pointcloud->size(); i++)
+        {
+            memset(buf, 0, 255);
+            sprintf(buf, "%f %f %f\n", pointcloud->points[i].x, pointcloud->points[i].y, pointcloud->points[i].z);
+            out.write(buf, strlen(buf));
+        }
+        out.close();
+        memset(buf, 0, 255);
+        getcwd(buf, 100);
+        std::cout << "write file successfully in "<< buf << std::endl;
+        return true;
+    }
+
+private:
+    pcl::PointCloud<pcl::PointXYZ>::Ptr m_pointcloud;
+    std::mutex m_cloud_mutex;
+};
+
+int main()
+{
+    pcl::PointCloud<pcl::PointXYZ>::Ptr t_pointcloud = pcl::PointCloud<pcl::PointXYZ>::Ptr(new pcl::PointCloud<pcl::PointXYZ>);
+    // std::cout<<"111"<<std::endl;
+    File_manager fm;
+    fm.read_pointcloud("/home/youchen/Documents/cp_cv_ws/src/cpp_pkgs/data/cloud_needed.txt", t_pointcloud);
+    fm.write_pointcloud(t_pointcloud);
+}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 2949 - 0
cpp_pkgs/src/globalmsg.pb.cc


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 2144 - 0
cpp_pkgs/src/globalmsg.pb.h


+ 89 - 0
cpp_pkgs/src/hw.cpp

@@ -0,0 +1,89 @@
+/*
+ * @Description: cpp format/regex test 
+ * @Author: yct
+ * @Date: 2020-03-30 11:23:51
+ * @LastEditTime: 2020-03-30 12:20:33
+ * @LastEditors: yct
+ */
+#define __STDC_WANT_LIB_EXT1__ 1
+#include <iostream>
+#include <ctime>
+#include <string>
+#include <regex>
+using namespace std;
+
+class Date
+{
+private:
+    string time1;
+
+public:
+    void show1() { cout << "一年中的第"; }
+    Date(string a) { time1 = a; }
+    Date() { time1 = ""; }
+    void Show() { cout << time1 << endl; }
+    void Shownow();
+};
+
+void Input();
+
+int main(void)
+{
+    Input();
+}
+
+void Date::Shownow()
+{
+    std::time_t now = std::time(nullptr);
+    char dt[26] = {0};
+    sprintf(dt, "%s", ctime(&now));
+    Date a(dt);
+    cout << "当前时间: ";
+    a.Show();
+}
+
+void Input()
+{
+    cout << "按如下格式输入日期: DDD/YYYY(一年中第几天), MM/DD/YY, June/DD/YYYY"<<endl;
+    regex reg1("(\\d{3})(.)(\\d{4,5})");
+    regex reg2("(\\d{2}(.)\\d{2}(.)(\\d{2}))");
+    regex reg3("([A-Za-z]{3,9})(.)(\\d{2})(.)(\\d{4,5})");
+    string k;
+    int i = 0, k1 = 0, k2 = 0;
+    int p1, p2 = 0, p3 = 0;
+    while (i != 1)
+    {
+        cin >> k;
+        if (regex_search(k, reg1))
+        {
+            string o1 = k.substr(0, 3);
+            string o2 = k.substr(4, 4);
+            p1 = stoi(o1);
+            p2 = stoi(o2);
+            cout << p1 << " " << p2;
+            break;
+        }
+        if (regex_search(k, reg2))
+        {
+            string o1 = k.substr(0, 2);
+            string o2 = k.substr(3, 2);
+            string o3 = k.substr(6, 4);
+            p1 = stoi(o1);
+            p2 = stoi(o2);
+            p3 = stoi(o3);
+            cout << p1 << " " << p2 << " " << p3;
+            break;
+        }
+        if (regex_search(k, reg3))
+        { 
+            string o1 = k.substr(0, k.length()-8);
+            string o2 = k.substr(k.length()-7, 2);
+            string o3 = k.substr(k.length()-4, 4);
+            p2 = stoi(o2);
+            p3 = stoi(o3);
+            cout << o1 << " " << p2 << " " << p3;
+            break;
+        }
+        cout<<"请重新输入"<<endl;
+    }
+}

+ 74 - 0
cpp_pkgs/src/inheritance.cpp

@@ -0,0 +1,74 @@
+#include <iostream>
+
+/**
+ * c->A->D
+ *  ->B->
+ */
+using namespace std;
+//基类
+class D
+{
+public:
+    D(){cout<<"D()"<<endl;}
+    ~D(){cout<<"~D()"<<endl;}
+    void print(){cout<<"print d"<<endl;}
+    virtual void print_virtual() = 0;//{cout<<"print virtual d"<<endl;}
+protected:
+    int d;
+};
+
+class B:public D
+{
+public:
+    B(){cout<<"B()"<<endl;}
+    ~B(){cout<<"~B()"<<endl;}
+    void print(){cout<<"print b"<<endl;}
+    virtual void print_virtual(){cout<<"print virtual b"<<endl;}
+protected:
+    int b;
+};
+
+class A:public D
+{
+public:
+    A(){cout<<"A()"<<endl;}
+    ~A(){cout<<"~A()"<<endl;}
+    void print(){cout<<"print a"<<endl;}
+    virtual void print_virtual(){cout<<"print virtual a"<<endl;}
+protected:
+    int a;
+};
+
+class C:public B, public A
+{
+public:
+    C(){cout<<"C()"<<endl;}
+    ~C(){cout<<"~C()"<<endl;}
+    void print(){cout<<"print c"<<endl;}
+    virtual void print_virtual(){cout<<"print virtual c"<<endl;}
+protected:
+    int c;
+};
+
+void global_print(D& s){
+    s.print();
+    s.print_virtual();
+}
+
+int main()
+{
+    cout << "Hello World!" << endl;
+    //D d; //抽象类,含纯虚函数
+    B b;
+    A a;
+    C c;   //D, B, A ,C
+    //cout<<sizeof(d)<<endl;
+    cout<<sizeof(b)<<endl;
+    cout<<sizeof(a)<<endl;
+    cout<<sizeof(c)<<endl;
+    //global_print(d);
+    global_print(b);
+    global_print(a);
+    // global_print(c); // 多继承,重构二义性
+    return 0;
+}

+ 31 - 0
cpp_pkgs/src/nnxx_testA.cpp

@@ -0,0 +1,31 @@
+#include <nnxx/message.h>
+#include <nnxx/message_control.h>
+#include <nnxx/socket.h>
+#include <nnxx/reqrep.h>
+//#include <nnxx/unittest.h>
+#include <nnxx/timeout.h>
+#include <nnxx/error.h>
+#include <thread>
+#include <unistd.h>
+#include <string.h>
+#include <iostream>
+
+int main()
+{
+    nnxx::socket s1{nnxx::SP_RAW, nnxx::REP};
+    s1.bind("tcp://127.0.0.1:9000");
+
+    while(true){
+        nnxx::message_control c1;
+        auto m1 = s1.recv(1, c1);
+        // char buf[255]={0};
+        // memset(buf, 0, 255);
+        // sprintf(buf, "%s", nnxx::to_string(m1));
+        
+        if(!m1.empty()){
+            std::cout<<to_string(m1)<<std::endl;
+            s1.send(std::move(m1), 0, std::move(c1));
+        }
+        // usleep(100 * 1000);
+    }
+}

+ 69 - 0
cpp_pkgs/src/nnxx_testB.cpp

@@ -0,0 +1,69 @@
+#include <nnxx/message.h>
+#include <nnxx/message_control.h>
+#include <nnxx/socket.h>
+#include <nnxx/reqrep.h>
+//#include <nnxx/unittest.h>
+#include <nnxx/timeout.h>
+#include <nnxx/error.h>
+
+#include <google/protobuf/io/coded_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
+#include <google/protobuf/text_format.h>
+using google::protobuf::io::FileInputStream;
+using google::protobuf::io::FileOutputStream;
+using google::protobuf::io::ZeroCopyInputStream;
+using google::protobuf::io::CodedInputStream;
+using google::protobuf::io::ZeroCopyOutputStream;
+using google::protobuf::io::CodedOutputStream;
+using google::protobuf::Message;
+
+#include "globalmsg.pb.h"
+
+#include <thread>
+#include <unistd.h>
+#include <string.h>
+#include <iostream>
+#include <mutex>
+
+std::mutex m_mutex;
+
+static void request_thread(int index){
+    nnxx::socket s2{nnxx::SP, nnxx::REQ};
+    s2.connect("tcp://127.0.0.1:9000");
+
+    while (true)
+    {
+        m_mutex.lock();
+        char buf[30] = {0};
+        memset(buf, 0, 30);
+        sprintf(buf, "Terminal%d", index);
+        s2.send(buf);
+        std::cout<<"msg sent: "<<buf<<std::endl;
+
+        globalmsg::resultInfo result;
+        result.ParseFromString(to_string(s2.recv()));
+        char buff[255] = {0};
+        memset(buff, 0, 255);
+        sprintf(buff, "time: %s\ncorrectness: %s\nx: %.3f, y: %.3f, c: %.3f\nwheelbase: %.3f, width: %.3f", 
+                result.time(), result.correctness()?"True":"False", result.x(), result.y(), result.c(),
+                result.wheel_base(), result.width());
+
+        std::cout<<"client "<< index << " get msg from server\n"<<buff<<std::endl;
+        m_mutex.unlock();
+        usleep(1000 * 1000);
+    }
+}
+
+int main() {
+    std::thread* th1 = new std::thread(request_thread, 0);
+    // std::thread* th2 = new std::thread(request_thread, 1);
+    th1->detach();
+    // th2->detach();
+
+    while('q' != getchar()){
+        usleep(200 * 1000);
+    }
+    delete th1;
+    // delete th2;
+    th1 = 0; //th2 = 0;
+}

+ 48 - 0
cpp_pkgs/src/sharedMemoryA.cpp

@@ -0,0 +1,48 @@
+#include <sys/types.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <boost/thread/thread.hpp>
+
+#define SHMKEY 75
+int shmid;
+int *addr;
+
+void client(void)
+{
+    int i;
+    shmid = shmget(SHMKEY, 1024, 0777); /*打开共享存储区*/
+    addr = (int *)shmat(shmid, 0, 0);   /*获得共享存储区首地址*/
+    for (i = 999; i >= 0; i--)
+    {
+        while (*addr != -1);
+        printf("(client) sent %d \n", i);
+        *addr = i;
+        usleep(1000*1000);
+    }
+    exit(0);
+}
+
+int main(void)
+{
+    boost::thread th(&client);
+    th.join();
+    return 0;
+
+    // std::thread th(client);
+    // th.join();
+
+    // while ((i = fork()) == -1)
+    //     ;
+    // if (!i)
+    //     server();
+    // system("ipcs  -m");
+    // while ((i = fork()) == -1)
+    //     ;
+    // if (!i)
+    //     client();
+}

+ 46 - 0
cpp_pkgs/src/sharedMemoryB.cpp

@@ -0,0 +1,46 @@
+#include <sys/types.h>
+#include <sys/shm.h>
+#include <sys/ipc.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <iostream>
+#include <boost/thread/thread.hpp>
+
+#define  SHMKEY  75
+int  shmid;
+int *addr;
+
+void server()
+{
+    shmid = shmget(SHMKEY, 1024*1, 0777 | IPC_CREAT); /*创建共享存储区*/
+    addr = (int *)shmat(shmid, 0, 0); /*获取首地址*/
+    do
+    {
+        *addr = -1;
+        while (*addr == -1);
+        if(*addr == 0)
+            break;
+        printf("(server) received %d \n", *addr);
+    } while (*addr);
+    shmctl(shmid, IPC_RMID, 0); /*撤消共享存储区,归还资源*/
+    exit(0);
+}
+
+int main()
+{
+    boost::thread th(&server);
+    th.join();
+    return 0;
+
+    // while ((i = fork()) == -1)
+    //     ;
+    // if (!i)
+    //     server();
+    // system("ipcs  -m");
+    // while ((i = fork()) == -1)
+    //     ;
+    // if (!i)
+    //     client();
+}

+ 2 - 0
cv_test/CMakeLists.txt

@@ -10,7 +10,9 @@ add_compile_options(-std=c++11)
 find_package(catkin REQUIRED COMPONENTS
   roscpp
 )
+#set(OpenCV_DIR  "/usr/local/opencv-2.4/share/OpenCV/")
 find_package(OpenCV REQUIRED)
+
 # MESSAGE( STATUS " ${OpenCV_DIR} ${OpenCV_INCLUDE_DIRS} ${OpenCV_LIBS}")
 ## System dependencies are found with CMake's conventions
 # find_package(Boost REQUIRED COMPONENTS system)

BIN
cv_test/oxygen/清凉的外世_cycle_0000.png


BIN
cv_test/oxygen/清凉的外世_cycle_0001.png


BIN
cv_test/oxygen/清凉的外世_cycle_0002.png


BIN
cv_test/oxygen/清凉的外世_cycle_0003.png


BIN
cv_test/oxygen/清凉的外世_cycle_0004.png


BIN
cv_test/oxygen/清凉的外世_cycle_0005.png


BIN
cv_test/oxygen/清凉的外世_cycle_0006.png


BIN
cv_test/oxygen/清凉的外世_cycle_0007.png


BIN
cv_test/oxygen/清凉的外世_cycle_0008.png


BIN
cv_test/oxygen/清凉的外世_cycle_0009.png


BIN
cv_test/oxygen/清凉的外世_cycle_0010.png


BIN
cv_test/oxygen/清凉的外世_cycle_0011.png


BIN
cv_test/oxygen/清凉的外世_cycle_0012.png


BIN
cv_test/oxygen/清凉的外世_cycle_0013.png


BIN
cv_test/oxygen/清凉的外世_cycle_0014.png


BIN
cv_test/oxygen/清凉的外世_cycle_0015.png


BIN
cv_test/oxygen/清凉的外世_cycle_0016.png


BIN
cv_test/oxygen/清凉的外世_cycle_0017.png


BIN
cv_test/oxygen/清凉的外世_cycle_0018.png


BIN
cv_test/oxygen/清凉的外世_cycle_0019.png


BIN
cv_test/oxygen/清凉的外世_cycle_0020.png


BIN
cv_test/oxygen/清凉的外世_cycle_0021.png


BIN
cv_test/oxygen/清凉的外世_cycle_0022.png


BIN
cv_test/oxygen/清凉的外世_cycle_0023.png


BIN
cv_test/oxygen/清凉的外世_cycle_0024.png


BIN
cv_test/oxygen/清凉的外世_cycle_0025.png


BIN
cv_test/oxygen/清凉的外世_cycle_0026.png


BIN
cv_test/oxygen/清凉的外世_cycle_0027.png


BIN
cv_test/oxygen/清凉的外世_cycle_0028.png


BIN
cv_test/oxygen/清凉的外世_cycle_0029.png


BIN
cv_test/oxygen/清凉的外世_cycle_0030.png


BIN
cv_test/oxygen/清凉的外世_cycle_0031.png


BIN
cv_test/oxygen/清凉的外世_cycle_0032.png


BIN
cv_test/oxygen/清凉的外世_cycle_0033.png


BIN
cv_test/oxygen/清凉的外世_cycle_0034.png


BIN
cv_test/oxygen/清凉的外世_cycle_0035.png


BIN
cv_test/oxygen/清凉的外世_cycle_0036.png


BIN
cv_test/oxygen/清凉的外世_cycle_0037.png


BIN
cv_test/oxygen/清凉的外世_cycle_0038.png


BIN
cv_test/oxygen/清凉的外世_cycle_0039.png


BIN
cv_test/oxygen/清凉的外世_cycle_0040.png


BIN
cv_test/oxygen/清凉的外世_cycle_0041.png


BIN
cv_test/oxygen/清凉的外世_cycle_0042.png


BIN
cv_test/oxygen/清凉的外世_cycle_0043.png


BIN
cv_test/oxygen/清凉的外世_cycle_0044.png


BIN
cv_test/oxygen/清凉的外世_cycle_0045.png


BIN
cv_test/oxygen/清凉的外世_cycle_0046.png


BIN
cv_test/oxygen/清凉的外世_cycle_0047.png


BIN
cv_test/oxygen/清凉的外世_cycle_0048.png


BIN
cv_test/oxygen/清凉的外世_cycle_0049.png


BIN
cv_test/oxygen/清凉的外世_cycle_0050.png


BIN
cv_test/oxygen/清凉的外世_cycle_0055.png


BIN
cv_test/oxygen/清凉的外世_cycle_0060.png


BIN
cv_test/oxygen/清凉的外世_cycle_0062.png


BIN
cv_test/oxygen/清凉的外世_cycle_0065.png


BIN
cv_test/oxygen/清凉的外世_cycle_0070.png


BIN
cv_test/oxygen/清凉的外世_cycle_0075.png


BIN
cv_test/oxygen/清凉的外世_cycle_0080.png


BIN
cv_test/oxygen/清凉的外世_cycle_0084.png


BIN
cv_test/oxygen/清凉的外世_cycle_0085.png


BIN
cv_test/oxygen/清凉的外世_cycle_0090.png


BIN
cv_test/oxygen/清凉的外世_cycle_0095.png


BIN
cv_test/oxygen/清凉的外世_cycle_0099.png


BIN
cv_test/oxygen/清凉的外世_cycle_0100.png


BIN
cv_test/oxygen/清凉的外世_cycle_0110.png


BIN
cv_test/oxygen/清凉的外世_cycle_0116.png


BIN
cv_test/oxygen/清凉的外世_cycle_0120.png


BIN
cv_test/oxygen/清凉的外世_cycle_0127.png


BIN
cv_test/oxygen/清凉的外世_cycle_0130.png


BIN
cv_test/oxygen/清凉的外世_cycle_0133.png


BIN
cv_test/oxygen/清凉的外世_cycle_0140.png


BIN
cv_test/oxygen/清凉的外世_cycle_0146.png


BIN
cv_test/oxygen/清凉的外世_cycle_0150.png


BIN
cv_test/oxygen/清凉的外世_cycle_0160.png


BIN
cv_test/oxygen/清凉的外世_cycle_0165.png


BIN
cv_test/oxygen/清凉的外世_cycle_0170.png


BIN
cv_test/oxygen/清凉的外世_cycle_0180.png


BIN
cv_test/oxygen/清凉的外世_cycle_0190.png


BIN
cv_test/oxygen/清凉的外世_cycle_0200.png


BIN
cv_test/oxygen/清凉的外世_cycle_0203.png


BIN
cv_test/oxygen/清凉的外世_cycle_0210.png


BIN
cv_test/oxygen/清凉的外世_cycle_0220.png


BIN
cv_test/oxygen/清凉的外世_cycle_0230.png


BIN
cv_test/oxygen/清凉的外世_cycle_0240.png


BIN
cv_test/oxygen/清凉的外世_cycle_0250.png


BIN
cv_test/oxygen/清凉的外世_cycle_0260.png


BIN
cv_test/oxygen/清凉的外世_cycle_0270.png


+ 0 - 0
cv_test/oxygen/清凉的外世_cycle_0280.png


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä