diff --git a/base.sh b/base.sh index 7e6280268ca7e5fde165a54937a47cc8735b035b..829f86be08bda9015eb3ce6734c233c2d5fd5b6f 100755 --- a/base.sh +++ b/base.sh @@ -9,6 +9,20 @@ GITEE_ORG=`grep GITEE_ORG config | cut -d'=' -f2` GITEE_DOMAIN=`grep GITEE_DOMAIN config | cut -d'=' -f2` OBS_DOMAIN=`grep OBS_DOMAIN config | cut -d'=' -f2` OBS_PROJECT=`grep OBS_PROJECT config | cut -d'=' -f2` +OPENEULER_BASE_VERSION=`grep OPENEULER_BASE_VERSION config | cut -d'=' -f2` +OPENEULER_SP_VERSION=`grep OPENEULER_SP_VERSION config | cut -d'=' -f2` + +OPENEULER_DEV_BRANCH=${ROS_DISTRO} +OPENEULER_ROS_DEP_NEXT_BRANCH=${OPENEULER_BASE_VERSION}-Next +OPENEULER_NEXT_BRANCH=Multi-Version_ros-${OPENEULER_DEV_BRANCH}_${OPENEULER_BASE_VERSION}-Next +if [ "$OPENEULER_SP_VERSION" == "" ] +then + OPENEULER_SP_BRANCH=Multi-Version_ros-${OPENEULER_DEV_BRANCH}_${OPENEULER_BASE_VERSION} + OPENEULER_ROS_DEP_PKG_BRANCH=${OPENEULER_BASE_VERSION} +else + OPENEULER_SP_BRANCH=Multi-Version_ros-${OPENEULER_DEV_BRANCH}_${OPENEULER_BASE_VERSION}-${OPENEULER_SP_VERSION} + OPENEULER_ROS_DEP_PKG_BRANCH=${OPENEULER_BASE_VERSION}-${OPENEULER_SP_VERSION} +fi OUTPUT=${ROOT}/output ROS_OUTPUT_TMP=${OUTPUT}/.tmp diff --git a/bb_fix/graphicsmagick/fix/APPENDS b/bb_fix/graphicsmagick/fix/APPENDS index 99f4d66e1577ed82a255f4c5193d28caa26ae8fa..4fe6567110f6fee8697721214641dae0b135c56c 100644 --- a/bb_fix/graphicsmagick/fix/APPENDS +++ b/bb_fix/graphicsmagick/fix/APPENDS @@ -1,7 +1,13 @@ inherit autotools -EXTRA_OECONF += "--enable-static=no --enable-shared=yes" -FILES:${PN}-dev += " \ - ${datadir}/GraphicsMagick-1.3.30 \ - ${libdir}/GraphicsMagick-1.3.30 \ +EXTRA_OECONF += "--enable-static=no --enable-shared=yes --with-png=yes" + +FILES:${PN}-dev:remove += " \ + ${datadir}/GraphicsMagick-${PV}/config \ + ${libdir}/GraphicsMagick-${PV}/config \ +" + +FILES:${PN} += " \ + ${datadir}/GraphicsMagick-${PV}/config \ + ${libdir}/GraphicsMagick-${PV}/config \ " diff --git a/bb_fix/graphicsmagick/fix/RDEPENDS b/bb_fix/graphicsmagick/fix/RDEPENDS index 67e3e876b0cc487d6d01f87cf05e5c29f96e5c86..f2d7daadc3f27d989aa43f501c8eff7e3bf33ea7 100644 --- a/bb_fix/graphicsmagick/fix/RDEPENDS +++ b/bb_fix/graphicsmagick/fix/RDEPENDS @@ -1 +1,2 @@ -urw-fonts ++libpng diff --git a/bb_fix/originbot-base/files/00-originbot-base-fix-error.patch b/bb_fix/originbot-base/files/00-originbot-base-fix-error.patch index 99e249fd81b5f98ff22371f7ec541e2d0abea24f..51595676e48c38d50381d252bad70f1b1cd237e7 100644 --- a/bb_fix/originbot-base/files/00-originbot-base-fix-error.patch +++ b/bb_fix/originbot-base/files/00-originbot-base-fix-error.patch @@ -1,26 +1,27 @@ ---- originbot_base/src/originbot_base.cpp_org 2023-05-30 11:12:44.857538312 +0800 -+++ originbot_base/src/originbot_base.cpp 2023-05-30 11:25:38.522997804 +0800 +diff -Naur originbot_base_org/src/originbot_base.cpp originbot_base/src/originbot_base.cpp +--- originbot_base_org/src/originbot_base.cpp 2023-05-31 12:01:13.355862106 +0800 ++++ originbot_base/src/originbot_base.cpp 2023-05-31 12:00:50.429723711 +0800 @@ -20,17 +20,17 @@ { // 加载参数 std::string port_name="ttyS3"; - this->declare_parameter("port_name"); //声明及获取串口号参数 -+ this->declare_parameter("port_name"); //声明及获取串口号参数 ++ this->declare_parameter("port_name", port_name); //声明及获取串口号参数 this->get_parameter_or("port_name", port_name, "ttyS3"); - this->declare_parameter("correct_factor_vx"); //声明及获取线速度校正参数 -+ this->declare_parameter("correct_factor_vx"); //声明及获取线速度校正参数 ++ this->declare_parameter("correct_factor_vx", 1.0); //声明及获取线速度校正参数 this->get_parameter_or("correct_factor_vx", correct_factor_vx_, 1.0); - this->declare_parameter("correct_factor_vth"); //声明及获取角速度校正参数 -+ this->declare_parameter("correct_factor_vth"); //声明及获取角速度校正参数 ++ this->declare_parameter("correct_factor_vth", 1.0); //声明及获取角速度校正参数 this->get_parameter_or("correct_factor_vth", correct_factor_vth_, 1.0); - this->declare_parameter("auto_stop_on"); //声明及获取自动停车功能的开关值 -+ this->declare_parameter("auto_stop_on"); //声明及获取自动停车功能的开关值 ++ this->declare_parameter("auto_stop_on", true); //声明及获取自动停车功能的开关值 this->get_parameter_or("auto_stop_on", auto_stop_on_, true); - this->declare_parameter("use_imu"); //声明是否使用imu -+ this->declare_parameter("use_imu"); //声明是否使用imu ++ this->declare_parameter("use_imu", false); //声明是否使用imu this->get_parameter_or("use_imu", use_imu_, false); - this->declare_parameter("pub_odom"); //声明是否发布odom的tf -+ this->declare_parameter("pub_odom"); //声明是否发布odom的tf ++ this->declare_parameter("pub_odom", false); //声明是否发布odom的tf this->get_parameter_or("pub_odom", pub_odom_, false); // 打印加载的参数值 diff --git a/bb_fix/originbot-navigation/files/01-originbot-navigation-fix-amcl-load-error.patch b/bb_fix/originbot-navigation/files/01-originbot-navigation-fix-amcl-load-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..0f289ba035588f6b40604dd12e683b42af6fcb8f --- /dev/null +++ b/bb_fix/originbot-navigation/files/01-originbot-navigation-fix-amcl-load-error.patch @@ -0,0 +1,11 @@ +--- originbot_navigation_org/param/originbot_nav2.yaml 2023-05-31 17:43:09.177335686 +0800 ++++ originbot_navigation/param/originbot_nav2.yaml 2023-05-31 17:44:06.069669453 +0800 +@@ -26,7 +26,7 @@ + recovery_alpha_fast: 0.0 + recovery_alpha_slow: 0.0 + resample_interval: 1 +- robot_model_type: "differential" ++ robot_model_type: "nav2_amcl::DifferentialMotionModel" + save_pose_rate: 0.5 + sigma_hit: 0.2 + tf_broadcast: true diff --git a/bb_fix/pcl/fix/APPENDS b/bb_fix/pcl/fix/APPENDS index 967803fbed42f839a1bb169aa84d201adcc4e3fe..0ac68e03e36de2de99510fd9ae3747e3e0abab46 100644 --- a/bb_fix/pcl/fix/APPENDS +++ b/bb_fix/pcl/fix/APPENDS @@ -40,3 +40,9 @@ SYSROOT_DIRS:append = " \ " INSANE_SKIP:${PN}-dev += "libdir" + +# compiling the pcl library requires a lot of memory and other resources, +# so multiple threads at the same time will cause a crash due to lack of resources, +# as a work around, it is restricted here. +OECMAKE_TARGET_COMPILE += " -j 2 " + diff --git a/bb_fix/yaml-cpp-vendor/fix/APPENDS b/bb_fix/yaml-cpp-vendor/fix/APPENDS new file mode 100644 index 0000000000000000000000000000000000000000..3703e92e263709ee34903002395773d8ffc73d56 --- /dev/null +++ b/bb_fix/yaml-cpp-vendor/fix/APPENDS @@ -0,0 +1,3 @@ +SRC_URI_remove = " \ + file://${OPENEULER_LOCAL_NAME}/00-yaml-cpp-vendor-fix-eulermaker-x86-build-error.patch \ +" diff --git a/bb_fix/ydlidar-ros2-driver/files/00-ydlidar-ros2-driver-fix-error.patch b/bb_fix/ydlidar-ros2-driver/files/00-ydlidar-ros2-driver-fix-error.patch index d1ab65d3346a8525d864e9957746349db5df4913..1b7284bed3d763b76f07b26280909e676e412a0c 100644 --- a/bb_fix/ydlidar-ros2-driver/files/00-ydlidar-ros2-driver-fix-error.patch +++ b/bb_fix/ydlidar-ros2-driver/files/00-ydlidar-ros2-driver-fix-error.patch @@ -1,12 +1,12 @@ diff -Naur ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp ydlidar_ros2_driver/src/ydlidar_ros2_driver_node.cpp ---- ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp 2023-05-30 11:30:17.993357651 +0800 -+++ ydlidar_ros2_driver/src/ydlidar_ros2_driver_node.cpp 2023-05-30 11:41:13.529049903 +0800 +--- ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp 2023-05-31 11:53:57.118227361 +0800 ++++ ydlidar_ros2_driver/src/ydlidar_ros2_driver_node.cpp 2023-05-31 11:12:13.690358220 +0800 @@ -41,45 +41,45 @@ CYdLidar laser; std::string str_optvalue = "/dev/ydlidar"; - node->declare_parameter("port"); -+ node->declare_parameter("port"); ++ node->declare_parameter("port", str_optvalue); node->get_parameter("port", str_optvalue); ///lidar port laser.setlidaropt(LidarPropSerialPort, str_optvalue.c_str(), str_optvalue.size()); @@ -14,44 +14,44 @@ diff -Naur ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp ydlidar_ros2 ///ignore array str_optvalue = ""; - node->declare_parameter("ignore_array"); -+ node->declare_parameter("ignore_array"); ++ node->declare_parameter("ignore_array", str_optvalue); node->get_parameter("ignore_array", str_optvalue); laser.setlidaropt(LidarPropIgnoreArray, str_optvalue.c_str(), str_optvalue.size()); std::string frame_id = "laser_frame"; - node->declare_parameter("frame_id"); -+ node->declare_parameter("frame_id"); ++ node->declare_parameter("frame_id", frame_id); node->get_parameter("frame_id", frame_id); //////////////////////int property///////////////// /// lidar baudrate int optval = 115200; - node->declare_parameter("baudrate"); -+ node->declare_parameter("baudrate"); ++ node->declare_parameter("baudrate", optval); node->get_parameter("baudrate", optval); laser.setlidaropt(LidarPropSerialBaudrate, &optval, sizeof(int)); /// tof lidar optval = TYPE_TRIANGLE; - node->declare_parameter("lidar_type"); -+ node->declare_parameter("lidar_type"); ++ node->declare_parameter("lidar_type", optval); node->get_parameter("lidar_type", optval); laser.setlidaropt(LidarPropLidarType, &optval, sizeof(int)); /// device type optval = YDLIDAR_TYPE_SERIAL; - node->declare_parameter("device_type"); -+ node->declare_parameter("device_type"); ++ node->declare_parameter("device_type", optval); node->get_parameter("device_type", optval); laser.setlidaropt(LidarPropDeviceType, &optval, sizeof(int)); /// sample rate optval = 9; - node->declare_parameter("sample_rate"); -+ node->declare_parameter("sample_rate"); ++ node->declare_parameter("sample_rate", optval); node->get_parameter("sample_rate", optval); laser.setlidaropt(LidarPropSampleRate, &optval, sizeof(int)); /// abnormal count optval = 4; - node->declare_parameter("abnormal_check_count"); -+ node->declare_parameter("abnormal_check_count"); ++ node->declare_parameter("abnormal_check_count", optval); node->get_parameter("abnormal_check_count", optval); laser.setlidaropt(LidarPropAbnormalCheckCount, &optval, sizeof(int)); @@ -60,42 +60,42 @@ diff -Naur ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp ydlidar_ros2 /// fixed angle resolution bool b_optvalue = false; - node->declare_parameter("fixed_resolution"); -+ node->declare_parameter("fixed_resolution"); ++ node->declare_parameter("fixed_resolution", b_optvalue); node->get_parameter("fixed_resolution", b_optvalue); laser.setlidaropt(LidarPropFixedResolution, &b_optvalue, sizeof(bool)); /// rotate 180 b_optvalue = true; - node->declare_parameter("reversion"); -+ node->declare_parameter("reversion"); ++ node->declare_parameter("reversion", b_optvalue); node->get_parameter("reversion", b_optvalue); laser.setlidaropt(LidarPropReversion, &b_optvalue, sizeof(bool)); /// Counterclockwise b_optvalue = true; - node->declare_parameter("inverted"); -+ node->declare_parameter("inverted"); ++ node->declare_parameter("inverted", b_optvalue); node->get_parameter("inverted", b_optvalue); laser.setlidaropt(LidarPropInverted, &b_optvalue, sizeof(bool)); b_optvalue = true; - node->declare_parameter("auto_reconnect"); -+ node->declare_parameter("auto_reconnect"); ++ node->declare_parameter("auto_reconnect", b_optvalue); node->get_parameter("auto_reconnect", b_optvalue); laser.setlidaropt(LidarPropAutoReconnect, &b_optvalue, sizeof(bool)); /// one-way communication b_optvalue = true; - node->declare_parameter("isSingleChannel"); -+ node->declare_parameter("isSingleChannel"); ++ node->declare_parameter("isSingleChannel", b_optvalue); node->get_parameter("isSingleChannel", b_optvalue); laser.setlidaropt(LidarPropSingleChannel, &b_optvalue, sizeof(bool)); /// intensity b_optvalue = false; - node->declare_parameter("intensity"); -+ node->declare_parameter("intensity"); ++ node->declare_parameter("intensity", b_optvalue); node->get_parameter("intensity", b_optvalue); laser.setlidaropt(LidarPropIntenstiy, &b_optvalue, sizeof(bool)); /// Motor DTR b_optvalue = false; - node->declare_parameter("support_motor_dtr"); -+ node->declare_parameter("support_motor_dtr"); ++ node->declare_parameter("support_motor_dtr", b_optvalue); node->get_parameter("support_motor_dtr", b_optvalue); laser.setlidaropt(LidarPropSupportMotorDtrCtrl, &b_optvalue, sizeof(bool)); @@ -103,35 +103,35 @@ diff -Naur ydlidar_ros2_driver_org/src/ydlidar_ros2_driver_node.cpp ydlidar_ros2 /// unit: ° float f_optvalue = 180.0f; - node->declare_parameter("angle_max"); -+ node->declare_parameter("angle_max"); ++ node->declare_parameter("angle_max", f_optvalue); node->get_parameter("angle_max", f_optvalue); laser.setlidaropt(LidarPropMaxAngle, &f_optvalue, sizeof(float)); f_optvalue = -180.0f; - node->declare_parameter("angle_min"); -+ node->declare_parameter("angle_min"); ++ node->declare_parameter("angle_min", f_optvalue); node->get_parameter("angle_min", f_optvalue); laser.setlidaropt(LidarPropMinAngle, &f_optvalue, sizeof(float)); /// unit: m f_optvalue = 64.f; - node->declare_parameter("range_max"); -+ node->declare_parameter("range_max"); ++ node->declare_parameter("range_max", f_optvalue); node->get_parameter("range_max", f_optvalue); laser.setlidaropt(LidarPropMaxRange, &f_optvalue, sizeof(float)); f_optvalue = 0.1f; - node->declare_parameter("range_min"); -+ node->declare_parameter("range_min"); ++ node->declare_parameter("range_min", f_optvalue); node->get_parameter("range_min", f_optvalue); laser.setlidaropt(LidarPropMinRange, &f_optvalue, sizeof(float)); /// unit: Hz f_optvalue = 10.f; - node->declare_parameter("frequency"); -+ node->declare_parameter("frequency"); ++ node->declare_parameter("frequency", f_optvalue); node->get_parameter("frequency", f_optvalue); laser.setlidaropt(LidarPropScanFrequency, &f_optvalue, sizeof(float)); bool invalid_range_is_inf = false; - node->declare_parameter("invalid_range_is_inf"); -+ node->declare_parameter("invalid_range_is_inf"); ++ node->declare_parameter("invalid_range_is_inf", invalid_range_is_inf); node->get_parameter("invalid_range_is_inf", invalid_range_is_inf); diff --git a/bb_fix/ydlidar-sdk/files/0001-GS2.patch b/bb_fix/ydlidar-sdk/files/0001-GS2.patch new file mode 100644 index 0000000000000000000000000000000000000000..535418f6b33e6bbd94b30c4ab84c27d08953338d --- /dev/null +++ b/bb_fix/ydlidar-sdk/files/0001-GS2.patch @@ -0,0 +1,117 @@ +From 0440c9fc2b88d89b3e082346e915ade384d51dc3 Mon Sep 17 00:00:00 2001 +From: zhanyiaini +Date: Mon, 29 Aug 2022 10:53:18 +0800 +Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9GS2=E6=97=A0=E6=97=B6?= + =?UTF-8?q?=E9=97=B4=E6=88=B3=E9=97=AE=E9=A2=98?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + samples/gs_test.cpp | 3 ++- + src/CYdLidar.cpp | 2 +- + src/GS2LidarDriver.cpp | 30 ++++++++++++++++++------------ + 3 files changed, 21 insertions(+), 14 deletions(-) + +diff --git a/samples/gs_test.cpp b/samples/gs_test.cpp +index b560f6b..3143666 100644 +--- a/samples/gs_test.cpp ++++ b/samples/gs_test.cpp +@@ -237,8 +237,9 @@ int main(int argc, char *argv[]) + { + if (laser.doProcessSimple(scan)) + { +- printf("[%lu] points module num [%d] env flag [0x%04X]\n", ++ printf("[%lu] points in [0x%016lX] module num [%d] env flag [0x%04X]\n", + scan.points.size(), ++ scan.stamp, + scan.moduleNum, + scan.envFlag); + +diff --git a/src/CYdLidar.cpp b/src/CYdLidar.cpp +index 1f11b0c..ec89bbf 100644 +--- a/src/CYdLidar.cpp ++++ b/src/CYdLidar.cpp +@@ -647,7 +647,7 @@ bool CYdLidar::doProcessSimple(LaserScan &outscan) + } + + outscan.config.angle_increment = math::from_degrees(m_field_of_view) / +- (all_node_count - 1); ++ (all_node_count - 1); + + float range = 0.0; + float intensity = 0.0; +diff --git a/src/GS2LidarDriver.cpp b/src/GS2LidarDriver.cpp +index 17ce6f2..d6193fc 100644 +--- a/src/GS2LidarDriver.cpp ++++ b/src/GS2LidarDriver.cpp +@@ -650,24 +650,25 @@ int GS2LidarDriver::cacheScanData() { + // printf("sync:%d,index:%d,moduleNum:%d\n",package_type,frameNum,moduleNum); + // fflush(stdout); + +- if(!isPrepareToSend){ ++ if (!isPrepareToSend) { + continue; + } + + size_t size = multi_package.size(); +- for(size_t i = 0;i < size; i++){ +- if(multi_package[i].frameNum == frameNum && multi_package[i].moduleNum == moduleNum){ +- memcpy(scan_node_buf,multi_package[i].all_points,sizeof (node_info) * 160); ++ for (size_t i = 0;i < size; i++) { ++ if (multi_package[i].frameNum == frameNum && ++ multi_package[i].moduleNum == moduleNum) { ++ memcpy(scan_node_buf, multi_package[i].all_points, sizeof(node_info) * 160); + break; + } + } + +- _lock.lock();//timeout lock, wait resource copys +- scan_node_buf[0].stamp = local_buf[count - 1].stamp; +- scan_node_buf[0].scan_frequence = local_buf[count - 1].scan_frequence; +- scan_node_buf[0].index = 0x03 & (moduleNum >> 1);//gs2: 1, 2, 4 ++ _lock.lock(); //timeout lock, wait resource copys ++ scan_node_buf[0].stamp = local_buf[0].stamp; ++ scan_node_buf[0].scan_frequence = local_buf[0].scan_frequence; ++ scan_node_buf[0].index = 0x03 & (moduleNum >> 1); //gs2: 1, 2, 4 + scan_node_count = 160; //一个包固定160个数据 +- // printf("send frameNum: %d,moduleNum: %d\n",frameNum,moduleNum); ++ // printf("count [%d] stamp [0x%016lX]\n", count, local_buf[count - 1].stamp); + // fflush(stdout); + _dataEvent.set(); + _lock.unlock(); +@@ -754,6 +755,11 @@ result_t GS2LidarDriver::waitPackage(node_info *node, uint32_t timeout) + break; + + case 4: ++ if (currentByte == LIDAR_ANS_SYNC_BYTE1) //如果出现超过4个包头标识的情况 ++ { ++ recvPos = 4; ++ continue; ++ } + moduleNum = currentByte; + CheckSumCal = currentByte; + break; +@@ -871,7 +877,7 @@ result_t GS2LidarDriver::waitPackage(node_info *node, uint32_t timeout) + } + } + +- (*node).stamp = 0; ++ (*node).stamp = getTime(); + + if (CheckSumResult) + { +@@ -1103,8 +1109,8 @@ result_t GS2LidarDriver::waitScanData( + } + addPointsToVec(nodebuffer, recvNodeCount); + +- nodebuffer[recvNodeCount - 1].stamp = size * trans_delay + delayTime; +- nodebuffer[recvNodeCount - 1].scan_frequence = node.scan_frequence; ++ // nodebuffer[recvNodeCount - 1].stamp = size * trans_delay + delayTime; ++ // nodebuffer[recvNodeCount - 1].scan_frequence = node.scan_frequence; + count = recvNodeCount; + return RESULT_OK; + } +-- +2.34.1 + diff --git a/bb_fix/ydlidar-sdk/files/0002-windows.patch b/bb_fix/ydlidar-sdk/files/0002-windows.patch new file mode 100644 index 0000000000000000000000000000000000000000..d65ccbdeb75cc0d278c03d4c3e6c015b7fbfa5fe --- /dev/null +++ b/bb_fix/ydlidar-sdk/files/0002-windows.patch @@ -0,0 +1,52 @@ +From 41e3cb93b6e08202a0f68e8a1cc5fc11ebf6ad5a Mon Sep 17 00:00:00 2001 +From: zhanyiaini +Date: Mon, 29 Aug 2022 17:03:46 +0800 +Subject: [PATCH 2/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9windows=E5=B9=B3=E5=8F=B0?= + =?UTF-8?q?=E5=9B=A0=E4=B8=AD=E6=96=87=E6=B3=A8=E9=87=8A=E6=97=A0=E6=B3=95?= + =?UTF-8?q?=E7=BC=96=E8=AF=91=E9=97=AE=E9=A2=98?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 10 ++++++++-- + README.md | 2 +- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index c35ca0a..0adc747 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -20,8 +20,14 @@ ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") + + ########################################################## +-# add -fPIC +-add_compile_options(-fPIC) ++IF (CMAKE_SYSTEM_NAME MATCHES "Linux") ++ MESSAGE(STATUS "Current platform: Linux") ++ #Linux add -fPIC ++ add_compile_options(-fPIC) ++ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows") ++ MESSAGE(STATUS "Current platform: Windows") ++ add_compile_options("/utf-8") ++ENDIF (CMAKE_SYSTEM_NAME MATCHES "Linux") + #or + #set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +diff --git a/README.md b/README.md +index 7343a8e..0440b95 100644 +--- a/README.md ++++ b/README.md +@@ -21,7 +21,7 @@ YDLidar SDK consists of YDLidar SDK communication protocol, YDLidar SDK core, YD + + ### Prerequisites + * Linux +-* Windows 7/10, Visual Studio 2015/2017 ++* Windows 7/10, Visual Studio 2015/2017(UTF-8 encoding) + * C++11 compiler + + ### Supported Languages +-- +2.34.1 + diff --git a/bb_fix/ydlidar-sdk/files/0003-GS1.patch b/bb_fix/ydlidar-sdk/files/0003-GS1.patch new file mode 100644 index 0000000000000000000000000000000000000000..26a643fa047e9b2360f065fda15fbc043cb404e2 --- /dev/null +++ b/bb_fix/ydlidar-sdk/files/0003-GS1.patch @@ -0,0 +1,2989 @@ +From 5c1a1aa92d3296405771b9ef05be1008b9b7148e Mon Sep 17 00:00:00 2001 +From: zhanyiaini +Date: Wed, 28 Sep 2022 19:01:33 +0800 +Subject: [PATCH 3/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=94=AF=E6=8C=81GS1?= + =?UTF-8?q?=E9=9B=B7=E8=BE=BE?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + core/common/DriverInterface.h | 1 + + core/common/ydlidar_def.h | 1 + + core/common/ydlidar_help.h | 33 +- + core/common/ydlidar_protocol.h | 35 +- + core/serial/impl/unix/list_ports_linux.cpp | 9 +- + samples/gs_test.cpp | 2 +- + samples/tri_test.cpp | 169 +- + src/CYdLidar.cpp | 15 +- + src/GS1LidarDriver.cpp | 1797 ++++++++++++++++++++ + src/GS1LidarDriver.h | 589 +++++++ + src/YDlidarDriver.cpp | 4 + + 11 files changed, 2561 insertions(+), 94 deletions(-) + create mode 100644 src/GS1LidarDriver.cpp + create mode 100644 src/GS1LidarDriver.h + +diff --git a/core/common/DriverInterface.h b/core/common/DriverInterface.h +index b22b098..e1e1e31 100644 +--- a/core/common/DriverInterface.h ++++ b/core/common/DriverInterface.h +@@ -473,6 +473,7 @@ class DriverInterface { + YDLIDAR_G7 = 21,/**< G7 LiDAR Model. */ + + YDLIDAR_GS2 = 51, //GS2雷达 ++ YDLIDAR_GS1 = 52, //GS1雷达 + + YDLIDAR_TG15 = 100,/**< TG15 LiDAR Model. */ + YDLIDAR_TG30 = 101,/**< T30 LiDAR Model. */ +diff --git a/core/common/ydlidar_def.h b/core/common/ydlidar_def.h +index 136dd46..f8bf961 100644 +--- a/core/common/ydlidar_def.h ++++ b/core/common/ydlidar_def.h +@@ -46,6 +46,7 @@ typedef enum { + TYPE_TRIANGLE = 1,/**< G4. G6. G2 LiDAR.*/ + TYPE_TOF_NET = 2,/**< T15 LiDAR.*/ + TYPE_GS = 3, //GS系列雷达(目前只有GS2) ++ TYPE_GS1 = 4, //GS1雷达 + TYPE_Tail, + } LidarTypeID; + +diff --git a/core/common/ydlidar_help.h b/core/common/ydlidar_help.h +index c96b2ef..35ac3ee 100644 +--- a/core/common/ydlidar_help.h ++++ b/core/common/ydlidar_help.h +@@ -168,6 +168,9 @@ inline std::string lidarModelToString(int model) { + name = "G7"; + break; + ++ case DriverInterface::YDLIDAR_GS1: ++ name = "GS1"; ++ break; + case DriverInterface::YDLIDAR_GS2: + name = "GS2"; + break; +@@ -368,6 +371,7 @@ inline bool hasScanFrequencyCtrl(int model) { + model == DriverInterface::YDLIDAR_S4B || + model == DriverInterface::YDLIDAR_S2 || + model == DriverInterface::YDLIDAR_X4 || ++ model == DriverInterface::YDLIDAR_GS1 || + model == DriverInterface::YDLIDAR_GS2) { + ret = false; + } +@@ -405,6 +409,7 @@ inline bool hasIntensity(int model) { + if (model == DriverInterface::YDLIDAR_G2B || + model == DriverInterface::YDLIDAR_G4B || + model == DriverInterface::YDLIDAR_S4B || ++ model == DriverInterface::YDLIDAR_GS1 || + model == DriverInterface::YDLIDAR_GS2) { + ret = true; + } +@@ -540,14 +545,30 @@ inline bool isTriangleLidar(int type) { + * @param type LiDAR type + * @return true if it is a Triangle type, otherwise false. + */ +-inline bool isGSLidar(int type) { +- bool ret = false; ++inline bool isGSLidar(int type) ++{ ++ return (type == TYPE_GS1 || ++ type == TYPE_GS); ++} + +- if (type == TYPE_GS) { +- ret = true; +- } ++/** ++ * @brief Whether it is a GS1 type LiDAR ++ * @param type LiDAR type ++ * @return true if it is a Triangle type, otherwise false. ++ */ ++inline bool isGS1Lidar(int type) ++{ ++ return (type == TYPE_GS1); ++} + +- return ret; ++/** ++ * @brief Whether it is a GS2 type LiDAR ++ * @param type LiDAR type ++ * @return true if it is a Triangle type, otherwise false. ++ */ ++inline bool isGS2Lidar(int type) ++{ ++ return (type == TYPE_GS); + } + + /** +diff --git a/core/common/ydlidar_protocol.h b/core/common/ydlidar_protocol.h +index d25ab73..68f21f4 100644 +--- a/core/common/ydlidar_protocol.h ++++ b/core/common/ydlidar_protocol.h +@@ -140,13 +140,14 @@ + #define Angle_Py 5.315 + #define Angle_PAngle 22.5 + #define PackageMaxModuleNums 0x03 +-#define PackageSampleMaxLngth_GS 0xA0 //160*2 ++#define MaxPointsPerPackge_GS2 160 //GS2固定160个点 ++#define MaxPointsPerPackge_GS1 216 //GS1固定216个点 + #define PackagePaidBytes_GS 8 + #define NORMAL_PACKAGE_SIZE 331 + + /// Maximuum number of samples in a packet + #define PackageSampleMaxLngth 0x100 +-#define MaximumNumberOfPackages 765 ++#define MaximumNumberOfPackages 765 //= 255 * 3 + + /// CT Package Type + typedef enum { +@@ -326,18 +327,36 @@ struct lidar_ans_header { + uint8_t type; + } __attribute__((packed)); + ++//GS1 ++struct GS1_Multi_Package { ++ int frameNum; ++ int moduleNum; ++ bool left = false; ++ bool right = false; ++ node_info all_points[MaxPointsPerPackge_GS1]; ++} __attribute__((packed)); + //GS2 + struct GS2_Multi_Package { + int frameNum; + int moduleNum; + bool left = false; + bool right = false; +- node_info all_points[160]; +-} __attribute__((packed)) ; ++ node_info all_points[MaxPointsPerPackge_GS2]; ++} __attribute__((packed)); + + struct GS2PackageNode { +- uint16_t PakageSampleDistance:9; +- uint16_t PakageSampleQuality:7; ++ uint16_t PakageSampleDistance : 9; ++ uint16_t PakageSampleQuality : 7; ++} __attribute__((packed)); ++ ++struct gs1_node_package { ++ uint32_t package_Head; ++ uint8_t address; ++ uint8_t package_CT; ++ uint16_t size; ++ uint16_t BackgroudLight; ++ GS2PackageNode packageSample[MaxPointsPerPackge_GS1]; ++ uint8_t checkSum; + } __attribute__((packed)); + + struct gs2_node_package { +@@ -346,9 +365,9 @@ struct gs2_node_package { + uint8_t package_CT; + uint16_t size; + uint16_t BackgroudLight; +- GS2PackageNode packageSample[PackageSampleMaxLngth_GS]; ++ GS2PackageNode packageSample[MaxPointsPerPackge_GS2]; + uint8_t checkSum; +-} __attribute__((packed)) ; ++} __attribute__((packed)); + + struct gs_lidar_ans_header { + uint8_t syncByte0; +diff --git a/core/serial/impl/unix/list_ports_linux.cpp b/core/serial/impl/unix/list_ports_linux.cpp +index ce571d2..d0877ed 100644 +--- a/core/serial/impl/unix/list_ports_linux.cpp ++++ b/core/serial/impl/unix/list_ports_linux.cpp +@@ -284,7 +284,8 @@ usb_sysfs_hw_string(const string &sysfs_path) { + } + + vector +-serial::list_ports() { ++serial::list_ports() ++{ + vector results; + + vector search_globs; +@@ -312,8 +313,8 @@ serial::list_ports() { + std::size_t found = hardware_id.find("10c4:ea60"); + std::size_t found1 = hardware_id.find("0483:5740"); + +- +- if (found != std::string::npos || found1 != std::string::npos) { ++ // if (found != std::string::npos || found1 != std::string::npos) ++ { + PortInfo device_entry; + device_entry.port = device; + device_entry.description = friendly_name; +@@ -322,8 +323,6 @@ serial::list_ports() { + results.push_back(device_entry); + } + +- +- + } + + return results; +diff --git a/samples/gs_test.cpp b/samples/gs_test.cpp +index 3143666..2bb7671 100644 +--- a/samples/gs_test.cpp ++++ b/samples/gs_test.cpp +@@ -153,7 +153,7 @@ int main(int argc, char *argv[]) + /// lidar baudrate + laser.setlidaropt(LidarPropSerialBaudrate, &baudrate, sizeof(int)); + /// gs lidar +- int optval = TYPE_GS; ++ int optval = TYPE_GS1; + laser.setlidaropt(LidarPropLidarType, &optval, sizeof(int)); + /// device type + optval = YDLIDAR_TYPE_SERIAL; +diff --git a/samples/tri_test.cpp b/samples/tri_test.cpp +index 3deb862..4e5f80c 100644 +--- a/samples/tri_test.cpp ++++ b/samples/tri_test.cpp +@@ -1,36 +1,36 @@ + /********************************************************************* +-* Software License Agreement (BSD License) +-* +-* Copyright (c) 2018, EAIBOT, Inc. +-* All rights reserved. +-* +-* Redistribution and use in source and binary forms, with or without +-* modification, are permitted provided that the following conditions +-* are met: +-* +-* * Redistributions of source code must retain the above copyright +-* notice, this list of conditions and the following disclaimer. +-* * Redistributions in binary form must reproduce the above +-* copyright notice, this list of conditions and the following +-* disclaimer in the documentation and/or other materials provided +-* with the distribution. +-* * Neither the name of the Willow Garage nor the names of its +-* contributors may be used to endorse or promote products derived +-* from this software without specific prior written permission. +-* +-* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +-* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +-* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +-* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +-* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +-* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +-* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +-* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +-* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +-* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +-* POSSIBILITY OF SUCH DAMAGE. +-*********************************************************************/ ++ * Software License Agreement (BSD License) ++ * ++ * Copyright (c) 2018, EAIBOT, Inc. ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above ++ * copyright notice, this list of conditions and the following ++ * disclaimer in the documentation and/or other materials provided ++ * with the distribution. ++ * * Neither the name of the Willow Garage nor the names of its ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ++ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ *********************************************************************/ + #include "CYdLidar.h" + #include + #include +@@ -58,7 +58,8 @@ using namespace ydlidar; + * Step7: Uninitialize the SDK and Disconnect the LiDAR.(::CYdLidar::disconnecting)\n + */ + +-int main(int argc, char *argv[]) { ++int main(int argc, char *argv[]) ++{ + printf("__ ______ _ ___ ____ _ ____ \n"); + printf("\\ \\ / / _ \\| | |_ _| _ \\ / \\ | _ \\ \n"); + printf(" \\ V /| | | | | | || | | |/ _ \\ | |_) | \n"); +@@ -70,36 +71,46 @@ int main(int argc, char *argv[]) { + ydlidar::os_init(); + + std::map ports = +- ydlidar::lidarPortList(); ++ ydlidar::lidarPortList(); + std::map::iterator it; + +- if (ports.size() == 1) { ++ if (ports.size() == 1) ++ { + port = ports.begin()->second; +- } else { ++ } ++ else ++ { + int id = 0; + +- for (it = ports.begin(); it != ports.end(); it++) { ++ for (it = ports.begin(); it != ports.end(); it++) ++ { + printf("%d. %s\n", id, it->first.c_str()); + id++; + } + +- if (ports.empty()) { ++ if (ports.empty()) ++ { + printf("Not Lidar was detected. Please enter the lidar serial port:"); + std::cin >> port; +- } else { +- while (ydlidar::os_isOk()) { ++ } ++ else ++ { ++ while (ydlidar::os_isOk()) ++ { + printf("Please select the lidar port:"); + std::string number; + std::cin >> number; + +- if ((size_t)atoi(number.c_str()) >= ports.size()) { ++ if ((size_t)atoi(number.c_str()) >= ports.size()) ++ { + continue; + } + + it = ports.begin(); + id = atoi(number.c_str()); + +- while (id) { ++ while (id) ++ { + id--; + it++; + } +@@ -122,16 +133,19 @@ int main(int argc, char *argv[]) { + printf("Baudrate:\n"); + + for (std::map::iterator it = baudrateList.begin(); +- it != baudrateList.end(); it++) { ++ it != baudrateList.end(); it++) ++ { + printf("%d. %d\n", it->first, it->second); + } + +- while (ydlidar::os_isOk()) { ++ while (ydlidar::os_isOk()) ++ { + printf("Please select the lidar baudrate:"); + std::string number; + std::cin >> number; + +- if ((size_t)atoi(number.c_str()) > baudrateList.size()) { ++ if ((size_t)atoi(number.c_str()) > baudrateList.size()) ++ { + continue; + } + +@@ -139,7 +153,8 @@ int main(int argc, char *argv[]) { + break; + } + +- if (!ydlidar::os_isOk()) { ++ if (!ydlidar::os_isOk()) ++ { + return 0; + } + +@@ -149,15 +164,18 @@ int main(int argc, char *argv[]) { + std::cin >> input_channel; + std::transform(input_channel.begin(), input_channel.end(), + input_channel.begin(), +- [](unsigned char c) { +- return std::tolower(c); // correct +- }); ++ [](unsigned char c) ++ { ++ return std::tolower(c); // correct ++ }); + +- if (input_channel.find("y") != std::string::npos) { ++ if (input_channel.find("y") != std::string::npos) ++ { + isSingleChannel = true; + } + +- if (!ydlidar::os_isOk()) { ++ if (!ydlidar::os_isOk()) ++ { + return 0; + } + +@@ -165,12 +183,14 @@ int main(int argc, char *argv[]) { + + float frequency = 8.0; + +- while (ydlidar::os_isOk() && !isSingleChannel) { ++ while (ydlidar::os_isOk() && !isSingleChannel) ++ { + printf("Please enter the lidar scan frequency[5-12]:"); + std::cin >> input_frequency; + frequency = atof(input_frequency.c_str()); + +- if (frequency <= 12 && frequency >= 5.0) { ++ if (frequency <= 12 && frequency >= 5.0) ++ { + break; + } + +@@ -178,7 +198,8 @@ int main(int argc, char *argv[]) { + "Invalid scan frequency,The scanning frequency range is 5 to 12 HZ, Please re-enter.\n"); + } + +- if (!ydlidar::os_isOk()) { ++ if (!ydlidar::os_isOk()) ++ { + return 0; + } + +@@ -252,14 +273,16 @@ int main(int argc, char *argv[]) { + laser.enableSunNoise(false); + + bool ret = laser.initialize(); +- if (!ret) { ++ if (!ret) ++ { + fprintf(stderr, "Fail to initialize %s\n", laser.DescribeError()); + fflush(stderr); + return -1; + } + + ret = laser.turnOn(); +- if (!ret) { ++ if (!ret) ++ { + fprintf(stderr, "Fail to start %s\n", laser.DescribeError()); + fflush(stderr); + return -1; +@@ -278,23 +301,23 @@ int main(int argc, char *argv[]) { + LaserScan scan; + while (ydlidar::os_isOk()) + { +- if (laser.doProcessSimple(scan)) +- { +- printf("Scan received [%u] points stamp [0x%016lX]\n", +- (unsigned int)scan.points.size(), +- scan.stamp); +-// for (size_t i=0; i(global_nodes[i].angle_q6_checkbit / 100.0f) + +@@ -737,6 +742,9 @@ bool CYdLidar::doProcessSimple(LaserScan &outscan) + range = .0; + } + ++ // printf("i %d d %.03f a %.02f flag %u\n", ++ // i, range, angle*180.0/M_PI, node.sync_flag); ++ + if (angle >= outscan.config.min_angle && + angle <= outscan.config.max_angle) + { +@@ -1802,7 +1810,12 @@ bool CYdLidar::checkCOMMs() + { + lidarPtr = new ydlidar::ETLidarDriver(); // T15 + } +- else if (isGSLidar(m_LidarType)) ++ else if (isGS1Lidar(m_LidarType)) ++ { ++ //GS1 ++ lidarPtr = new ydlidar::GS1LidarDriver(); ++ } ++ else if (isGS2Lidar(m_LidarType)) + { + //GS2 + lidarPtr = new ydlidar::GS2LidarDriver(); +diff --git a/src/GS1LidarDriver.cpp b/src/GS1LidarDriver.cpp +new file mode 100644 +index 0000000..dcaf0d0 +--- /dev/null ++++ b/src/GS1LidarDriver.cpp +@@ -0,0 +1,1797 @@ ++/********************************************************************* ++ * Software License Agreement (BSD License) ++ * ++ * Copyright (c) 2018, EAIBOT, Inc. ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * ++ * * Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * * Redistributions in binary form must reproduce the above ++ * copyright notice, this list of conditions and the following ++ * disclaimer in the documentation and/or other materials provided ++ * with the distribution. ++ * * Neither the name of the Willow Garage nor the names of its ++ * contributors may be used to endorse or promote products derived ++ * from this software without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ++ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++ * POSSIBILITY OF SUCH DAMAGE. ++ *********************************************************************/ ++#include ++#include "GS1LidarDriver.h" ++#include "core/serial/common.h" ++#include "ydlidar_config.h" ++ ++using namespace impl; ++ ++namespace ydlidar ++{ ++ ++ GS1LidarDriver::GS1LidarDriver() : _serial(NULL) ++ { ++ //串口配置参数 ++ m_intensities = false; ++ isAutoReconnect = true; ++ isAutoconnting = false; ++ m_baudrate = 230400; ++ isSupportMotorDtrCtrl = true; ++ scan_node_count = 0; ++ sample_rate = 5000; ++ m_PointTime = 1e9 / 5000; ++ trans_delay = 0; ++ scan_frequence = 0; ++ m_sampling_rate = -1; ++ model = -1; ++ retryCount = 0; ++ has_device_header = false; ++ m_SingleChannel = false; ++ m_LidarType = TYPE_TOF; ++ ++ //解析参数 ++ PackageSampleBytes = 2; ++ IntervalSampleAngle = 0.0; ++ CheckSum = 0; ++ CheckSumCal = 0; ++ SampleNumlAndCTCal = 0; ++ LastSampleAngleCal = 0; ++ CheckSumResult = true; ++ Valu8Tou16 = 0; ++ package_Sample_Num = 0; ++ moduleNum = 0; ++ frameNum = 0; ++ isPrepareToSend = false; ++ multi_package.resize(MaximumNumberOfPackages); ++ ++ last_device_byte = 0x00; ++ asyncRecvPos = 0; ++ async_size = 0; ++ headerBuffer = reinterpret_cast(&header_); ++ infoBuffer = reinterpret_cast(&info_); ++ healthBuffer = reinterpret_cast(&health_); ++ get_device_health_success = false; ++ get_device_info_success = false; ++ ++ package_Sample_Index = 0; ++ IntervalSampleAngle_LastPackage = 0.0; ++ globalRecvBuffer = new uint8_t[sizeof(gs1_node_package)]; ++ scan_node_buf = new node_info[MAX_SCAN_NODES]; ++ package_index = 0; ++ has_package_error = false; ++ isValidPoint = true; ++ bias[0] = 0; ++ bias[1] = 0; ++ bias[2] = 0; ++ } ++ ++ GS1LidarDriver::~GS1LidarDriver() ++ { ++ m_isScanning = false; ++ ++ isAutoReconnect = false; ++ _thread.join(); ++ ++ ScopedLocker lk(_serial_lock); ++ ++ if (_serial) ++ { ++ if (_serial->isOpen()) ++ { ++ _serial->flush(); ++ _serial->closePort(); ++ } ++ } ++ ++ if (_serial) ++ { ++ delete _serial; ++ _serial = NULL; ++ } ++ ++ if (globalRecvBuffer) ++ { ++ delete[] globalRecvBuffer; ++ globalRecvBuffer = NULL; ++ } ++ ++ if (scan_node_buf) ++ { ++ delete[] scan_node_buf; ++ scan_node_buf = NULL; ++ } ++ } ++ ++ result_t GS1LidarDriver::connect(const char *port_path, uint32_t baudrate) ++ { ++ ScopedLocker lk(_serial_lock); ++ m_baudrate = baudrate; ++ serial_port = string(port_path); ++ ++ if (!_serial) ++ { ++ _serial = new serial::Serial(port_path, m_baudrate, ++ serial::Timeout::simpleTimeout(DEFAULT_TIMEOUT)); ++ } ++ ++ { ++ ScopedLocker l(_lock); ++ ++ if (!_serial->open()) ++ { ++ return RESULT_FAIL; ++ } ++ ++ m_isConnected = true; ++ } ++ ++ stopScan(); ++ delay(100); ++ clearDTR(); ++ ++ return RESULT_OK; ++ } ++ ++ void GS1LidarDriver::setDTR() ++ { ++ if (!m_isConnected) ++ { ++ return; ++ } ++ ++ if (_serial) ++ { ++ _serial->setDTR(1); ++ } ++ } ++ ++ void GS1LidarDriver::clearDTR() ++ { ++ if (!m_isConnected) ++ { ++ return; ++ } ++ ++ if (_serial) ++ { ++ _serial->setDTR(0); ++ } ++ } ++ void GS1LidarDriver::flushSerial() ++ { ++ if (!m_isConnected) ++ { ++ return; ++ } ++ ++ size_t len = _serial->available(); ++ if (len) ++ { ++ _serial->readSize(len); ++ } ++ ++ delay(20); ++ } ++ ++ void GS1LidarDriver::disconnect() ++ { ++ isAutoReconnect = false; ++ ++ if (!m_isConnected) ++ { ++ return; ++ } ++ ++ stop(); ++ delay(10); ++ ScopedLocker l(_serial_lock); ++ ++ if (_serial) ++ { ++ if (_serial->isOpen()) ++ { ++ _serial->closePort(); ++ } ++ } ++ ++ m_isConnected = false; ++ } ++ ++ void GS1LidarDriver::disableDataGrabbing() ++ { ++ { ++ if (m_isScanning) ++ { ++ m_isScanning = false; ++ _dataEvent.set(); ++ } ++ } ++ _thread.join(); ++ } ++ ++ bool GS1LidarDriver::isscanning() const ++ { ++ return m_isScanning; ++ } ++ bool GS1LidarDriver::isconnected() const ++ { ++ return m_isConnected; ++ } ++ ++ result_t GS1LidarDriver::sendCommand(uint8_t cmd, ++ const void *payload, ++ size_t payloadsize) ++ { ++ return sendCommand(0x00, cmd, payload, payloadsize); ++ // uint8_t pkt_header[12]; ++ // cmd_packet_gs *header = reinterpret_cast(pkt_header); ++ // uint8_t checksum = 0; ++ ++ // if (!m_isConnected) { ++ // return RESULT_FAIL; ++ // } ++ ++ // header->syncByte0 = LIDAR_CMD_SYNC_BYTE; ++ // header->syncByte1 = LIDAR_CMD_SYNC_BYTE; ++ // header->syncByte2 = LIDAR_CMD_SYNC_BYTE; ++ // header->syncByte3 = LIDAR_CMD_SYNC_BYTE; ++ // header->address = 0x00; ++ // header->cmd_flag = cmd; ++ // header->size = 0xffff&payloadsize; ++ // sendData(pkt_header, 8) ; ++ // checksum += cmd; ++ // checksum += 0xff&header->size; ++ // checksum += 0xff&(header->size>>8); ++ ++ // if (payloadsize && payload) { ++ // for (size_t pos = 0; pos < payloadsize; ++pos) { ++ // checksum += ((uint8_t *)payload)[pos]; ++ // } ++ // uint8_t sizebyte = (uint8_t)(payloadsize); ++ // sendData((const uint8_t *)payload, sizebyte); ++ // } ++ ++ // sendData(&checksum, 1); ++ ++ // return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::sendCommand(uint8_t addr, ++ uint8_t cmd, ++ const void *payload, ++ size_t payloadsize) ++ { ++ uint8_t pkt_header[12]; ++ cmd_packet_gs *header = reinterpret_cast(pkt_header); ++ uint8_t checksum = 0; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ header->syncByte0 = LIDAR_CMD_SYNC_BYTE; ++ header->syncByte1 = LIDAR_CMD_SYNC_BYTE; ++ header->syncByte2 = LIDAR_CMD_SYNC_BYTE; ++ header->syncByte3 = LIDAR_CMD_SYNC_BYTE; ++ header->address = addr; ++ header->cmd_flag = cmd; ++ header->size = 0xffff & payloadsize; ++ sendData(pkt_header, 8); ++ checksum += addr; ++ checksum += cmd; ++ checksum += 0xff & header->size; ++ checksum += 0xff & (header->size >> 8); ++ ++ if (payloadsize && payload) ++ { ++ for (size_t pos = 0; pos < payloadsize; ++pos) ++ { ++ checksum += ((uint8_t *)payload)[pos]; ++ } ++ uint8_t sizebyte = (uint8_t)(payloadsize); ++ sendData((const uint8_t *)payload, sizebyte); ++ } ++ ++ sendData(&checksum, 1); ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::sendData(const uint8_t *data, size_t size) ++ { ++ if (!_serial || !_serial->isOpen()) ++ { ++ return RESULT_FAIL; ++ } ++ ++ if (data == NULL || size == 0) ++ { ++ return RESULT_FAIL; ++ } ++ ++ size_t r; ++ ++ while (size) ++ { ++ r = _serial->writeData(data, size); ++ ++ if (!r) ++ { ++ return RESULT_FAIL; ++ } ++ ++ // printf("send: "); ++ // printHex(data, r); ++ ++ size -= r; ++ data += r; ++ } ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::getData(uint8_t *data, size_t size) ++ { ++ if (!_serial || !_serial->isOpen()) ++ { ++ return RESULT_FAIL; ++ } ++ ++ size_t r; ++ ++ while (size) ++ { ++ r = _serial->readData(data, size); ++ ++ if (!r) ++ { ++ return RESULT_FAIL; ++ } ++ ++ // printf("recv: "); ++ // printHex(data, r); ++ ++ size -= r; ++ data += r; ++ } ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::waitResponseHeader(gs_lidar_ans_header *header, ++ uint32_t timeout) ++ { ++ int recvPos = 0; ++ uint32_t startTs = getms(); ++ uint8_t recvBuffer[sizeof(gs_lidar_ans_header)]; ++ uint8_t *headerBuffer = reinterpret_cast(header); ++ uint32_t waitTime = 0; ++ has_device_header = false; ++ last_device_byte = 0x00; ++ ++ while ((waitTime = getms() - startTs) <= timeout) ++ { ++ size_t remainSize = sizeof(gs_lidar_ans_header) - recvPos; ++ size_t recvSize = 0; ++ result_t ans = waitForData(remainSize, timeout - waitTime, &recvSize); ++ ++ if (!IS_OK(ans)) ++ { ++ return ans; ++ } ++ ++ if (recvSize > remainSize) ++ { ++ recvSize = remainSize; ++ } ++ ++ ans = getData(recvBuffer, recvSize); ++ ++ if (IS_FAIL(ans)) ++ { ++ return RESULT_FAIL; ++ } ++ ++ for (size_t pos = 0; pos < recvSize; ++pos) ++ { ++ uint8_t currentByte = recvBuffer[pos]; ++ ++ switch (recvPos) ++ { ++ case 0: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 1: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 2: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 3: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ has_device_header = true; ++ break; ++ ++ default: ++ break; ++ } ++ ++ headerBuffer[recvPos++] = currentByte; ++ last_device_byte = currentByte; ++ ++ if (has_device_header && recvPos == sizeof(gs_lidar_ans_header)) ++ { ++ return RESULT_OK; ++ } ++ } ++ } ++ ++ return RESULT_FAIL; ++ } ++ ++ result_t GS1LidarDriver::waitResponseHeaderEx(gs_lidar_ans_header *header, uint8_t cmd, uint32_t timeout) ++ { ++ int recvPos = 0; ++ uint32_t startTs = getms(); ++ uint8_t recvBuffer[sizeof(gs_lidar_ans_header)]; ++ uint8_t *headerBuffer = reinterpret_cast(header); ++ uint32_t waitTime = 0; ++ has_device_header = false; ++ last_device_byte = 0x00; ++ ++ while ((waitTime = getms() - startTs) <= timeout) ++ { ++ size_t remainSize = sizeof(gs_lidar_ans_header) - recvPos; ++ size_t recvSize = 0; ++ result_t ans = waitForData(remainSize, timeout - waitTime, &recvSize); ++ ++ if (!IS_OK(ans)) ++ { ++ return ans; ++ } ++ ++ if (recvSize > remainSize) ++ { ++ recvSize = remainSize; ++ } ++ ++ ans = getData(recvBuffer, recvSize); ++ ++ if (IS_FAIL(ans)) ++ { ++ return RESULT_FAIL; ++ } ++ ++ for (size_t pos = 0; pos < recvSize; ++pos) ++ { ++ uint8_t currentByte = recvBuffer[pos]; ++ ++ switch (recvPos) ++ { ++ case 0: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 1: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 2: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ ++ case 3: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ case 5: ++ if (currentByte != cmd) ++ { ++ recvPos = 0; ++ continue; ++ } ++ has_device_header = true; ++ break; ++ ++ default: ++ break; ++ } ++ ++ headerBuffer[recvPos++] = currentByte; ++ last_device_byte = currentByte; ++ ++ if (has_device_header && recvPos == sizeof(gs_lidar_ans_header)) ++ { ++ return RESULT_OK; ++ } ++ } ++ } ++ ++ return RESULT_FAIL; ++ } ++ ++ result_t GS1LidarDriver::waitForData(size_t data_count, uint32_t timeout, ++ size_t *returned_size) ++ { ++ size_t length = 0; ++ ++ if (returned_size == NULL) ++ { ++ returned_size = (size_t *)&length; ++ } ++ ++ return (result_t)_serial->waitfordata(data_count, timeout, returned_size); ++ } ++ ++ result_t GS1LidarDriver::checkAutoConnecting() ++ { ++ result_t ans = RESULT_FAIL; ++ isAutoconnting = true; ++ ++ while (isAutoReconnect && isAutoconnting) ++ { ++ { ++ ScopedLocker l(_serial_lock); ++ ++ if (_serial) ++ { ++ if (_serial->isOpen() || m_isConnected) ++ { ++ m_isConnected = false; ++ _serial->closePort(); ++ delete _serial; ++ _serial = NULL; ++ } ++ } ++ } ++ retryCount++; ++ ++ if (retryCount > 100) ++ { ++ retryCount = 100; ++ } ++ ++ delay(100 * retryCount); ++ int retryConnect = 0; ++ ++ while (isAutoReconnect && ++ connect(serial_port.c_str(), m_baudrate) != RESULT_OK) ++ { ++ retryConnect++; ++ ++ if (retryConnect > 50) ++ { ++ retryConnect = 50; ++ } ++ ++ delay(200 * retryConnect); ++ } ++ ++ if (!isAutoReconnect) ++ { ++ m_isScanning = false; ++ return RESULT_FAIL; ++ } ++ ++ if (isconnected()) ++ { ++ delay(100); ++ { ++ ScopedLocker l(_serial_lock); ++ ans = startAutoScan(); ++ ++ if (!IS_OK(ans)) ++ { ++ ans = startAutoScan(); ++ } ++ } ++ ++ if (IS_OK(ans)) ++ { ++ isAutoconnting = false; ++ return ans; ++ } ++ } ++ } ++ ++ return RESULT_FAIL; ++ } ++ ++ int GS1LidarDriver::cacheScanData() ++ { ++ node_info local_buf[MaxPointsPerPackge_GS1]; ++ size_t count = MaxPointsPerPackge_GS1; ++ node_info local_scan[MAX_SCAN_NODES]; ++ size_t scan_count = 0; ++ result_t ans = RESULT_FAIL; ++ memset(local_scan, 0, sizeof(local_scan)); ++ ++ flushSerial(); ++ // waitScanData(local_buf, count); ++ ++ int timeout_count = 0; ++ retryCount = 0; ++ ++ while (m_isScanning) ++ { ++ count = MaxPointsPerPackge_GS1; ++ ans = waitScanData(local_buf, count); ++ ++ if (!IS_OK(ans)) ++ { ++ if (IS_FAIL(ans) || timeout_count > DEFAULT_TIMEOUT_COUNT) ++ { ++ if (!isAutoReconnect) ++ { ++ fprintf(stderr, "exit scanning thread!!\n"); ++ fflush(stderr); ++ { ++ m_isScanning = false; ++ } ++ return RESULT_FAIL; ++ } ++ else ++ { ++ ans = checkAutoConnecting(); ++ ++ if (IS_OK(ans)) ++ { ++ timeout_count = 0; ++ local_scan[0].sync_flag = Node_NotSync; ++ } ++ else ++ { ++ m_isScanning = false; ++ return RESULT_FAIL; ++ } ++ } ++ } ++ else ++ { ++ timeout_count++; ++ local_scan[0].sync_flag = Node_NotSync; ++ fprintf(stderr, "timeout count: %d\n", timeout_count); ++ fflush(stderr); ++ } ++ } ++ else ++ { ++ timeout_count = 0; ++ retryCount = 0; ++ } ++ ++ // printf("sync:%d,index:%d,moduleNum:%d\n",package_type,frameNum,moduleNum); ++ // fflush(stdout); ++ ++ if (!isPrepareToSend) ++ { ++ continue; ++ } ++ ++ size_t size = multi_package.size(); ++ for (size_t i = 0; i < size; i++) ++ { ++ if (multi_package[i].frameNum == frameNum && ++ multi_package[i].moduleNum == moduleNum) ++ { ++ memcpy(scan_node_buf, multi_package[i].all_points, sizeof(node_info) * MaxPointsPerPackge_GS1); ++ break; ++ } ++ } ++ ++ _lock.lock(); // timeout lock, wait resource copys ++ scan_node_buf[0].stamp = local_buf[0].stamp; ++ scan_node_buf[0].scan_frequence = local_buf[0].scan_frequence; ++ scan_node_buf[0].index = 0x03 & moduleNum >> 1; //gs1: 1, 2, 4 ++ scan_node_count = MaxPointsPerPackge_GS1; //一个包固定216个数据 ++ // printf("send frameNum: %d,moduleNum: %d\n",frameNum,moduleNum); ++ // fflush(stdout); ++ _dataEvent.set(); ++ _lock.unlock(); ++ scan_count = 0; ++ isPrepareToSend = false; ++ } ++ ++ m_isScanning = false; ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::waitPackage(node_info *node, uint32_t timeout) ++ { ++ int recvPos = 0; ++ uint32_t startTs = getms(); ++ uint32_t waitTime = 0; ++ uint8_t *packageBuffer = (uint8_t *)&package; ++ isValidPoint = true; ++ int package_recvPos = 0; ++ uint16_t sample_lens = 0; ++ has_device_header = false; ++ uint16_t package_Sample_Num = 0; ++ ++ if (package_Sample_Index == 0) ++ { ++ recvPos = 0; ++ ++ while ((waitTime = getms() - startTs) <= timeout) ++ { ++ size_t remainSize = PackagePaidBytes_GS - recvPos; ++ size_t recvSize = 0; ++ CheckSumCal = 0; ++ result_t ans = waitForData(remainSize, timeout - waitTime, &recvSize); ++ ++ if (!IS_OK(ans)) ++ { ++ return ans; ++ } ++ ++ if (recvSize > remainSize) ++ { ++ recvSize = remainSize; ++ } ++ ++ getData(globalRecvBuffer, recvSize); ++ ++ for (size_t pos = 0; pos < recvSize; ++pos) ++ { ++ uint8_t currentByte = globalRecvBuffer[pos]; ++ switch (recvPos) ++ { ++ case 0: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ case 1: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ case 2: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ break; ++ case 3: ++ if (currentByte != LIDAR_ANS_SYNC_BYTE1) ++ { ++ recvPos = 0; ++ continue; ++ } ++ has_device_header = true; ++ break; ++ case 4: ++ if (currentByte == LIDAR_ANS_SYNC_BYTE1) //如果出现超过4个包头标识的情况 ++ { ++ recvPos = 4; ++ continue; ++ } ++ moduleNum = currentByte; ++ CheckSumCal += currentByte; ++ break; ++ ++ case 5: ++ if (currentByte != GS_LIDAR_ANS_SCAN) ++ { ++ recvPos = 0; ++ CheckSumCal = 0; ++ moduleNum = 0; ++ has_device_header = false; ++ continue; ++ } ++ CheckSumCal += currentByte; ++ break; ++ ++ case 6: ++ sample_lens |= 0x00ff & currentByte; ++ CheckSumCal += currentByte; ++ break; ++ ++ case 7: ++ sample_lens |= (0x00ff & currentByte) << 8; ++ CheckSumCal += currentByte; ++ break; ++ ++ default: ++ break; ++ } ++ ++ packageBuffer[recvPos++] = currentByte; ++ } ++ ++ if (has_device_header && ++ recvPos == PackagePaidBytes_GS) ++ { ++ if (!sample_lens) ++ { ++ recvPos = 0; ++ moduleNum = 0; ++ has_device_header = false; ++ continue; ++ } ++ package_Sample_Num = sample_lens + 1; //环境2Bytes + 点云320Bytes + CRC ++ package_recvPos = recvPos; ++ // printf("sample num %d\n", (package_Sample_Num - 3) / 2); ++ break; ++ } ++ else ++ { ++ recvPos = 0; ++ // printf("invalid data\n"); ++ continue; ++ } ++ } ++ ++ if (PackagePaidBytes_GS == recvPos) ++ { ++ startTs = getms(); ++ recvPos = 0; ++ ++ while ((waitTime = getms() - startTs) <= timeout) ++ { ++ size_t remainSize = package_Sample_Num - recvPos; ++ size_t recvSize = 0; ++ result_t ans = waitForData(remainSize, timeout - waitTime, &recvSize); ++ ++ if (!IS_OK(ans)) ++ { ++ return ans; ++ } ++ ++ if (recvSize > remainSize) ++ { ++ recvSize = remainSize; ++ } ++ ++ getData(globalRecvBuffer, recvSize); ++ ++ for (size_t pos = 0; pos < recvSize - 1; pos++) ++ { ++ CheckSumCal += globalRecvBuffer[pos]; ++ packageBuffer[package_recvPos + recvPos] = globalRecvBuffer[pos]; ++ recvPos++; ++ } ++ CheckSum = globalRecvBuffer[recvSize - 1]; // crc ++ packageBuffer[package_recvPos + recvPos] = CheckSum; // crc ++ recvPos += 1; ++ ++ if (package_Sample_Num == recvPos) ++ { ++ package_recvPos += recvPos; ++ break; ++ } ++ } ++ ++ if (package_Sample_Num != recvPos) ++ { ++ return RESULT_FAIL; ++ } ++ } ++ else ++ { ++ return RESULT_FAIL; ++ } ++ ++ if (CheckSumCal != CheckSum) ++ { ++ CheckSumResult = false; ++ has_package_error = true; ++ } ++ else ++ { ++ CheckSumResult = true; ++ ++ // printf("env: 0x%04X\n", package.BackgroudLight); ++ // fflush(stdout); ++ } ++ } ++ ++ (*node).stamp = getTime(); ++ ++ if (CheckSumResult) ++ { ++ (*node).index = 0x03 & (moduleNum >> 1); ++ (*node).scan_frequence = scan_frequence; ++ (*node).sync_quality = 0; ++ ++ (*node).distance_q2 = ++ package.packageSample[package_Sample_Index].PakageSampleDistance; ++ ++ if (m_intensities) ++ { ++ (*node).sync_quality = (uint16_t)package.packageSample[package_Sample_Index].PakageSampleQuality; ++ } ++ ++ double sampleAngle = 0; ++ if (node->distance_q2 > 0) ++ { ++ angTransform((*node).distance_q2, package_Sample_Index, &sampleAngle, &(*node).distance_q2); ++ } ++ // printf("%lf ", sampleAngle); ++ if (sampleAngle < 0) ++ { ++ (*node).angle_q6_checkbit = (((uint16_t)(sampleAngle * 64 + 23040)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ } ++ else ++ { ++ if ((sampleAngle * 64) > 23040) ++ { ++ (*node).angle_q6_checkbit = (((uint16_t)(sampleAngle * 64 - 23040)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ } ++ else ++ { ++ (*node).angle_q6_checkbit = (((uint16_t)(sampleAngle * 64)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ } ++ } ++ ++ //处理环境数据(2个字节分别存储在两个点的is属性中) ++ if (0 == package_Sample_Index) ++ (*node).is = package.BackgroudLight & 0xFF; ++ else if (1 == package_Sample_Index) ++ (*node).is = package.BackgroudLight >> 8; ++ ++ // printf("%s [%d] : Out : %u %u %u\n", __FUNCTION__, __LINE__, package_Sample_Index, node->distance_q2, node->angle_q6_checkbit); ++ } ++ else ++ { ++ (*node).sync_flag = Node_NotSync; ++ (*node).sync_quality = 0; ++ (*node).angle_q6_checkbit = LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ (*node).distance_q2 = 0; ++ (*node).scan_frequence = 0; ++ return RESULT_FAIL; ++ } ++ ++ package_Sample_Index ++; ++ (*node).sync_flag = Node_NotSync; ++ ++ if (package_Sample_Index >= MaxPointsPerPackge_GS1) ++ { ++ package_Sample_Index = 0; ++ (*node).sync_flag = Node_Sync; ++ CheckSumResult = false; ++ } ++ ++ return RESULT_OK; ++ } ++ ++ void GS1LidarDriver::angTransform(uint16_t dist, int n, double *dstTheta, uint16_t *dstDist) ++ { ++ double pixelU = n, Dist, theta, tempTheta, tempDist, tempX, tempY; ++ uint8_t mdNum = 0x03 & (moduleNum >> 1); // 1,2,4 ++ ++ tempTheta = atan(d_compensateK0[mdNum] * pixelU - d_compensateB0[mdNum]) * 180 / M_PI; ++ Dist = dist / cos(tempTheta * M_PI / 180); ++ theta = tempTheta; ++ ++ if (theta < 0) ++ { ++ theta += 360; ++ } ++ *dstTheta = theta; ++ *dstDist = Dist; ++ } ++ ++ void GS1LidarDriver::addPointsToVec(node_info *nodebuffer, size_t &count) ++ { ++ size_t size = multi_package.size(); ++ bool isFound = false; ++ for (size_t i = 0; i < size; i++) ++ { ++ if (multi_package[i].frameNum == frameNum && multi_package[i].moduleNum == moduleNum) ++ { ++ isFound = true; ++ memcpy(multi_package[i].all_points, nodebuffer, sizeof(node_info) * count); ++ isPrepareToSend = true; ++ if (frameNum > 0) ++ { ++ int lastFrame = frameNum - 1; ++ for (size_t j = 0; j < size; j++) ++ { ++ if (multi_package[j].frameNum == lastFrame && multi_package[j].moduleNum == moduleNum) ++ { ++ break; ++ } ++ } ++ } ++ break; ++ } ++ } ++ if (!isFound) ++ { ++ GS1_Multi_Package package; ++ package.frameNum = frameNum; ++ package.moduleNum = moduleNum; ++ multi_package.push_back(package); ++ } ++ // printf("add points, [sync:%d] [%u]\n",package_type,frameNum); ++ // fflush(stdout); ++ } ++ ++ result_t GS1LidarDriver::waitScanData( ++ node_info *nodebuffer, ++ size_t &count, ++ uint32_t timeout) ++ { ++ if (!m_isConnected) ++ { ++ count = 0; ++ return RESULT_FAIL; ++ } ++ ++ size_t recvNodeCount = 0; ++ uint32_t startTs = getms(); ++ uint32_t waitTime = 0; ++ result_t ans = RESULT_FAIL; ++ ++ while ((waitTime = getms() - startTs) <= timeout && recvNodeCount < count) ++ { ++ node_info node; ++ memset(&node, 0, sizeof(node_info)); ++ ans = waitPackage(&node, timeout - waitTime); ++ ++ if (!IS_OK(ans)) ++ { ++ count = recvNodeCount; ++ return ans; ++ } ++ nodebuffer[recvNodeCount++] = node; ++ ++ if (!package_Sample_Index) ++ { ++ ++ size_t size = _serial->available(); ++ uint64_t delayTime = 0; ++ size_t PackageSize = sizeof(gs1_node_package); ++ ++ if (size > PackagePaidBytes_GS) ++ { ++ size_t packageNum = size / PackageSize; ++ size_t Number = size % PackageSize; ++ delayTime = packageNum * m_PointTime * PackageSize / 2; ++ ++ if (Number > PackagePaidBytes_GS) ++ { ++ delayTime += m_PointTime * ((Number - PackagePaidBytes_GS) / 2); ++ } ++ ++ size = Number; ++ ++ if (packageNum > 0 && Number == 0) ++ { ++ size = PackageSize; ++ } ++ } ++ addPointsToVec(nodebuffer, recvNodeCount); ++ ++ nodebuffer[recvNodeCount - 1].stamp = size * trans_delay + delayTime; ++ nodebuffer[recvNodeCount - 1].scan_frequence = node.scan_frequence; ++ count = recvNodeCount; ++ return RESULT_OK; ++ } ++ ++ if (recvNodeCount == count) ++ { ++ return RESULT_OK; ++ } ++ } ++ ++ count = recvNodeCount; ++ return RESULT_FAIL; ++ } ++ ++ result_t GS1LidarDriver::grabScanData(node_info *nodebuffer, size_t &count, ++ uint32_t timeout) ++ { ++ switch (_dataEvent.wait(timeout)) ++ { ++ case Event::EVENT_TIMEOUT: ++ count = 0; ++ return RESULT_TIMEOUT; ++ ++ case Event::EVENT_OK: ++ { ++ if (scan_node_count == 0) ++ { ++ return RESULT_FAIL; ++ } ++ ++ ScopedLocker l(_lock); ++ size_t size_to_copy = min(count, scan_node_count); ++ memcpy(nodebuffer, scan_node_buf, size_to_copy * sizeof(node_info)); ++ count = size_to_copy; ++ scan_node_count = 0; ++ } ++ ++ return RESULT_OK; ++ ++ default: ++ count = 0; ++ return RESULT_FAIL; ++ } ++ } ++ ++ result_t GS1LidarDriver::ascendScanData(node_info *nodebuffer, size_t count) ++ { ++ float inc_origin_angle = (float)360.0 / count; ++ int i = 0; ++ ++ for (i = 0; i < (int)count; i++) ++ { ++ if (nodebuffer[i].distance_q2 == 0) ++ { ++ continue; ++ } ++ else ++ { ++ while (i != 0) ++ { ++ i--; ++ float expect_angle = (nodebuffer[i + 1].angle_q6_checkbit >> ++ LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / ++ 64.0f - ++ inc_origin_angle; ++ ++ if (expect_angle < 0.0f) ++ { ++ expect_angle = 0.0f; ++ } ++ ++ uint16_t checkbit = nodebuffer[i].angle_q6_checkbit & ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ nodebuffer[i].angle_q6_checkbit = (((uint16_t)(expect_angle * 64.0f)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + checkbit; ++ } ++ ++ break; ++ } ++ } ++ ++ if (i == (int)count) ++ { ++ return RESULT_FAIL; ++ } ++ ++ for (i = (int)count - 1; i >= 0; i--) ++ { ++ if (nodebuffer[i].distance_q2 == 0) ++ { ++ continue; ++ } ++ else ++ { ++ while (i != ((int)count - 1)) ++ { ++ i++; ++ float expect_angle = (nodebuffer[i - 1].angle_q6_checkbit >> ++ LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / ++ 64.0f + ++ inc_origin_angle; ++ ++ if (expect_angle > 360.0f) ++ { ++ expect_angle -= 360.0f; ++ } ++ ++ uint16_t checkbit = nodebuffer[i].angle_q6_checkbit & ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ nodebuffer[i].angle_q6_checkbit = (((uint16_t)(expect_angle * 64.0f)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + checkbit; ++ } ++ ++ break; ++ } ++ } ++ ++ float frontAngle = (nodebuffer[0].angle_q6_checkbit >> ++ LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / ++ 64.0f; ++ ++ for (i = 1; i < (int)count; i++) ++ { ++ if (nodebuffer[i].distance_q2 == 0) ++ { ++ float expect_angle = frontAngle + i * inc_origin_angle; ++ ++ if (expect_angle > 360.0f) ++ { ++ expect_angle -= 360.0f; ++ } ++ ++ uint16_t checkbit = nodebuffer[i].angle_q6_checkbit & ++ LIDAR_RESP_MEASUREMENT_CHECKBIT; ++ nodebuffer[i].angle_q6_checkbit = (((uint16_t)(expect_angle * 64.0f)) << LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) + checkbit; ++ } ++ } ++ ++ size_t zero_pos = 0; ++ float pre_degree = (nodebuffer[0].angle_q6_checkbit >> ++ LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / ++ 64.0f; ++ ++ for (i = 1; i < (int)count; ++i) ++ { ++ float degree = (nodebuffer[i].angle_q6_checkbit >> ++ LIDAR_RESP_MEASUREMENT_ANGLE_SHIFT) / ++ 64.0f; ++ ++ if (zero_pos == 0 && (pre_degree - degree > 180)) ++ { ++ zero_pos = i; ++ break; ++ } ++ ++ pre_degree = degree; ++ } ++ ++ node_info *tmpbuffer = new node_info[count]; ++ ++ for (i = (int)zero_pos; i < (int)count; i++) ++ { ++ tmpbuffer[i - zero_pos] = nodebuffer[i]; ++ } ++ ++ for (i = 0; i < (int)zero_pos; i++) ++ { ++ tmpbuffer[i + (int)count - zero_pos] = nodebuffer[i]; ++ } ++ ++ memcpy(nodebuffer, tmpbuffer, count * sizeof(node_info)); ++ delete[] tmpbuffer; ++ ++ return RESULT_OK; ++ } ++ ++ /************************************************************************/ ++ /* get device parameters of gs lidar */ ++ /************************************************************************/ ++ result_t GS1LidarDriver::getDevicePara(gs_device_para &info, uint32_t timeout) ++ { ++ result_t ans; ++ uint8_t crcSum, mdNum; ++ uint8_t *pInfo = reinterpret_cast(&info); ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ disableDataGrabbing(); ++ flushSerial(); ++ { ++ ScopedLocker l(_lock); ++ ++ if ((ans = sendCommand(GS_LIDAR_CMD_GET_PARAMETER)) != RESULT_OK) ++ { ++ return ans; ++ } ++ gs_lidar_ans_header response_header; ++ // for(int i = 0; i < PackageMaxModuleNums; i++) ++ { ++ if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ if (response_header.type != GS_LIDAR_CMD_GET_PARAMETER) ++ { ++ return RESULT_FAIL; ++ } ++ if (response_header.size < (sizeof(gs_device_para) - 1)) ++ { ++ return RESULT_FAIL; ++ } ++ if (waitForData(response_header.size + 1, timeout) != RESULT_OK) ++ { ++ return RESULT_FAIL; ++ } ++ getData(reinterpret_cast(&info), sizeof(info)); ++ ++ crcSum = 0; ++ crcSum += response_header.address; ++ crcSum += response_header.type; ++ crcSum += 0xff & response_header.size; ++ crcSum += 0xff & (response_header.size >> 8); ++ for (int j = 0; j < response_header.size; j++) ++ { ++ crcSum += pInfo[j]; ++ } ++ if (crcSum != info.crc) ++ { ++ return RESULT_FAIL; ++ } ++ ++ mdNum = response_header.address >> 1; // 1,2,4 ++ if (mdNum > 2) ++ { ++ return RESULT_FAIL; ++ } ++ u_compensateK0[mdNum] = info.u_compensateK0; ++ u_compensateK1[mdNum] = info.u_compensateK1; ++ u_compensateB0[mdNum] = info.u_compensateB0; ++ u_compensateB1[mdNum] = info.u_compensateB1; ++ d_compensateK0[mdNum] = info.u_compensateK0 / 10000.00; ++ d_compensateK1[mdNum] = info.u_compensateK1 / 10000.00; ++ d_compensateB0[mdNum] = info.u_compensateB0 / 10000.00; ++ d_compensateB1[mdNum] = info.u_compensateB1 / 10000.00; ++ bias[mdNum] = double(info.bias) * 0.1; ++ delay(5); ++ } ++ } ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::setDeviceAddress(uint32_t timeout) ++ { ++ result_t ans; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ if (m_SingleChannel) ++ { ++ return RESULT_OK; ++ } ++ ++ disableDataGrabbing(); ++ flushSerial(); ++ { ++ ScopedLocker l(_lock); ++ ++ if ((ans = sendCommand(GS_LIDAR_CMD_GET_ADDRESS)) != RESULT_OK) ++ { ++ return ans; ++ } ++ ++ gs_lidar_ans_header response_header; ++ if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ ++ if (response_header.type != GS_LIDAR_CMD_GET_ADDRESS) ++ { ++ return RESULT_FAIL; ++ } ++ ++ printf("[YDLIDAR] Lidar module count %d", (response_header.address << 1) + 1); ++ } ++ ++ return RESULT_OK; ++ } ++ ++ /************************************************************************/ ++ /* the set to signal quality */ ++ /************************************************************************/ ++ void GS1LidarDriver::setIntensities(const bool &i) ++ { ++ m_intensities = i; ++ // if (m_intensities != isintensities) ++ // { ++ // if (globalRecvBuffer) ++ // { ++ // delete[] globalRecvBuffer; ++ // globalRecvBuffer = NULL; ++ // } ++ ++ // globalRecvBuffer = new uint8_t[sizeof(gs1_node_package)]; ++ // } ++ ++ // m_intensities = isintensities; ++ ++ // if (m_intensities) ++ // { ++ // PackageSampleBytes = 2; ++ // } ++ // else ++ // { ++ // PackageSampleBytes = 2; ++ // } ++ } ++ /** ++ * @brief 设置雷达异常自动重新连接 \n ++ * @param[in] enable 是否开启自动重连: ++ * true 开启 ++ * false 关闭 ++ */ ++ void GS1LidarDriver::setAutoReconnect(const bool &enable) ++ { ++ isAutoReconnect = enable; ++ } ++ ++ void GS1LidarDriver::checkTransDelay() ++ { ++ //采样率 ++ trans_delay = _serial->getByteTime(); ++ sample_rate = 27 * MaxPointsPerPackge_GS1; ++ m_PointTime = 1e9 / sample_rate; ++ } ++ ++ /************************************************************************/ ++ /* start to scan */ ++ /************************************************************************/ ++ result_t GS1LidarDriver::startScan(bool force, uint32_t timeout) ++ { ++ result_t ans; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ if (m_isScanning) ++ { ++ return RESULT_OK; ++ } ++ ++ stop(); ++ checkTransDelay(); ++ flushSerial(); ++ ++ //配置GS1模组地址(三个模组) ++ // setDeviceAddress(300); ++ ++ //获取GS1参数 ++ gs_device_para gs1_info; ++ // delay(30); ++ getDevicePara(gs1_info, 300); ++ // delay(30); ++ { ++ flushSerial(); ++ ++ ScopedLocker l(_lock); ++ if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : GS_LIDAR_CMD_SCAN)) != ++ RESULT_OK) ++ { ++ return ans; ++ } ++ ++ if (!m_SingleChannel) ++ { ++ gs_lidar_ans_header response_header; ++ ++ if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ ++ if (response_header.type != GS_LIDAR_ANS_SCAN) ++ { ++ printf("[CYdLidar] Response to start scan type error!\n"); ++ return RESULT_FAIL; ++ } ++ } ++ ++ ans = this->createThread(); ++ } ++ ++ return ans; ++ } ++ ++ result_t GS1LidarDriver::stopScan(uint32_t timeout) ++ { ++ UNUSED(timeout); ++ result_t ans; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ ScopedLocker l(_lock); ++ ++ if ((ans = sendCommand(GS_LIDAR_CMD_STOP)) != RESULT_OK) ++ { ++ return ans; ++ } ++ gs_lidar_ans_header response_header; ++ if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ if (response_header.type != GS_LIDAR_CMD_STOP) ++ { ++ return RESULT_FAIL; ++ } ++ delay(10); ++ printf("GS1LidarDriver stop lidar successfully\n"); ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::createThread() ++ { ++ _thread = CLASS_THREAD(GS1LidarDriver, cacheScanData); ++ ++ if (_thread.getHandle() == 0) ++ { ++ m_isScanning = false; ++ return RESULT_FAIL; ++ } ++ ++ m_isScanning = true; ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::startAutoScan(bool force, uint32_t timeout) ++ { ++ result_t ans; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ flushSerial(); ++ delay(10); ++ { ++ ++ ScopedLocker l(_lock); ++ ++ if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : GS_LIDAR_CMD_SCAN)) != ++ RESULT_OK) ++ { ++ return ans; ++ } ++ ++ if (!m_SingleChannel) ++ { ++ gs_lidar_ans_header response_header; ++ ++ if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ ++ if (response_header.type != GS_LIDAR_CMD_SCAN) ++ { ++ return RESULT_FAIL; ++ } ++ } ++ } ++ ++ return RESULT_OK; ++ } ++ ++ /************************************************************************/ ++ /* stop scan */ ++ /************************************************************************/ ++ result_t GS1LidarDriver::stop() ++ { ++ if (isAutoconnting) ++ { ++ isAutoReconnect = false; ++ m_isScanning = false; ++ } ++ ++ disableDataGrabbing(); ++ stopScan(); ++ ++ return RESULT_OK; ++ } ++ ++ /************************************************************************/ ++ /* reset device */ ++ /************************************************************************/ ++ result_t GS1LidarDriver::reset(uint8_t addr, uint32_t timeout) ++ { ++ UNUSED(timeout); ++ result_t ans; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ ScopedLocker l(_lock); ++ ++ if ((ans = sendCommand(addr, GS_LIDAR_CMD_RESET)) != RESULT_OK) ++ { ++ return ans; ++ } ++ ++ return RESULT_OK; ++ } ++ ++ std::string GS1LidarDriver::getSDKVersion() ++ { ++ return YDLIDAR_SDK_VERSION_STR; ++ } ++ ++ std::map GS1LidarDriver::lidarPortList() ++ { ++ std::vector lst = list_ports(); ++ std::map ports; ++ ++ for (std::vector::iterator it = lst.begin(); it != lst.end(); it++) ++ { ++ std::string port = "ydlidar" + (*it).device_id; ++ ports[port] = (*it).port; ++ } ++ ++ return ports; ++ } ++ ++ const char *GS1LidarDriver::DescribeError(bool isTCP) ++ { ++ if (_serial) ++ { ++ return _serial->DescribeError(); ++ } ++ return nullptr; ++ } ++ ++ result_t GS1LidarDriver::getHealth(device_health &, uint32_t) ++ { ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::getDeviceInfo(device_info &info, uint32_t timeout) ++ { ++ result_t ret = RESULT_OK; ++ ++ if (!m_isConnected) ++ { ++ return RESULT_FAIL; ++ } ++ ++ disableDataGrabbing(); ++ // flushSerial(); ++ { ++ ScopedLocker l(_lock); ++ ++ if ((ret = sendCommand(GS_LIDAR_CMD_GET_VERSION)) != RESULT_OK) ++ { ++ return ret; ++ } ++ ++ gs_lidar_ans_header head; ++ if ((ret = waitResponseHeaderEx(&head, GS_LIDAR_CMD_GET_VERSION, timeout)) != RESULT_OK) ++ { ++ return ret; ++ } ++ if (head.type != GS_LIDAR_CMD_GET_VERSION) ++ { ++ return RESULT_FAIL; ++ } ++ if (head.size < sizeof(gs_device_info)) ++ { ++ return RESULT_FAIL; ++ } ++ ++ if (waitForData(head.size + 1, timeout) != RESULT_OK) ++ { ++ return RESULT_FAIL; ++ } ++ gs_device_info di = {0}; ++ getData(reinterpret_cast(&di), sizeof(di)); ++ model = YDLIDAR_GS1; ++ info.model = model; ++ info.hardware_version = di.hardware_version; ++ info.firmware_version = uint16_t((di.firmware_version & 0xFF) << 8) + ++ uint16_t(di.firmware_version >> 8); ++ memcpy(info.serialnum, di.serialnum, 16); ++ // head.address; //雷达序号 ++ } ++ ++ return RESULT_OK; ++ } ++ ++ result_t GS1LidarDriver::setWorkMode(int mode, uint8_t addr) ++ { ++ result_t ans; ++ uint32_t timeout = 300; ++ string buf; ++ ++ if (!isconnected()) ++ { ++ return RESULT_FAIL; ++ } ++ ++ //如果已经开启扫描,则先停止扫描 ++ if (isscanning()) ++ { ++ disableDataGrabbing(); ++ delay(10); ++ stopScan(); ++ } ++ flushSerial(); ++ ++ { ++ ScopedLocker l(_lock); ++ uint8_t m = uint8_t(mode); ++ if ((ans = sendCommand(addr, GS_LIDAR_CMD_SET_MODE, &m, 1)) != RESULT_OK) ++ { ++ return ans; ++ } ++ gs_lidar_ans_header response_header; ++ if ((ans = waitResponseHeaderEx(&response_header, GS_LIDAR_CMD_SET_MODE, timeout)) != RESULT_OK) ++ { ++ return ans; ++ } ++ if (response_header.type != GS_LIDAR_CMD_SET_MODE) ++ { ++ return RESULT_FAIL; ++ } ++ } ++ ++ return RESULT_OK; ++ } ++ ++} +diff --git a/src/GS1LidarDriver.h b/src/GS1LidarDriver.h +new file mode 100644 +index 0000000..c49ce81 +--- /dev/null ++++ b/src/GS1LidarDriver.h +@@ -0,0 +1,589 @@ ++/********************************************************************* ++* Software License Agreement (BSD License) ++* ++* Copyright (c) 2018, EAIBOT, Inc. ++* All rights reserved. ++* ++* Redistribution and use in source and binary forms, with or without ++* modification, are permitted provided that the following conditions ++* are met: ++* ++* * Redistributions of source code must retain the above copyright ++* notice, this list of conditions and the following disclaimer. ++* * Redistributions in binary form must reproduce the above ++* copyright notice, this list of conditions and the following ++* disclaimer in the documentation and/or other materials provided ++* with the distribution. ++* * Neither the name of the Willow Garage nor the names of its ++* contributors may be used to endorse or promote products derived ++* from this software without specific prior written permission. ++* ++* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ++* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ++* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ++* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, ++* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ++* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER ++* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ++* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ++* POSSIBILITY OF SUCH DAMAGE. ++*********************************************************************/ ++ ++/** @page GS1LidarDriver ++ * GS1LidarDriver API ++ ++
Library GS1LidarDriver ++
File GS1LidarDriver.h ++
Author Tony [code at ydlidar com] ++
Source https://github.com/ydlidar/YDLidar-SDK ++
Version 1.0.0 ++
++ This GS1LidarDriver support [TYPE_TRIANGLE](\ref LidarTypeID::TYPE_TRIANGLE) and [TYPE_TOF](\ref LidarTypeID::TYPE_TOF) LiDAR ++ ++* @copyright Copyright (c) 2018-2020 EAIBOT ++ Jump to the @link ::ydlidar::GS1LidarDriver @endlink interface documentation. ++*/ ++#ifndef GS1_YDLIDAR_DRIVER_H ++#define GS1_YDLIDAR_DRIVER_H ++ ++#include ++#include ++#include ++#include "core/serial/serial.h" ++#include "core/base/locker.h" ++#include "core/base/thread.h" ++#include "core/common/ydlidar_protocol.h" ++#include "core/common/ydlidar_help.h" ++ ++#if !defined(__cplusplus) ++#ifndef __cplusplus ++#error "The YDLIDAR SDK requires a C++ compiler to be built" ++#endif ++#endif ++ ++ ++using namespace std; ++ ++namespace ydlidar { ++ ++using namespace core; ++using namespace core::serial; ++using namespace core::base; ++ ++/*! ++* GS1操控类 ++*/ ++class GS1LidarDriver : public DriverInterface { ++ public: ++ /** ++ * @brief Set and Get LiDAR single channel. ++ * Whether LiDAR communication channel is a single-channel ++ * @note For a single-channel LiDAR, if the settings are reversed.\n ++ * an error will occur in obtaining device information and the LiDAR will Faied to Start.\n ++ * For dual-channel LiDAR, if th setttings are reversed.\n ++ * the device information cannot be obtained.\n ++ * Set the single channel to match the LiDAR. ++ * @remarks ++ ++
G1/G2/G2A/G2C false ++
G4/G4B/G4PRO/G6/F4/F4PRO false ++
S4/S4B/X4/R2/G4C false ++
S2/X2/X2L false ++
TG15/TG30/TG50 false ++
TX8/TX20 false ++
T5/T15 false ++
GS1 true ++
++ * @see DriverInterface::setSingleChannel and DriverInterface::getSingleChannel ++ */ ++ PropertyBuilderByName(bool, SingleChannel, private); ++ /** ++ * @brief Set and Get LiDAR Type. ++ * @note Refer to the table below for the LiDAR Type.\n ++ * Set the LiDAR Type to match the LiDAR. ++ * @remarks ++ ++
G1/G2A/G2/G2C [TYPE_TRIANGLE](\ref LidarTypeID::TYPE_TRIANGLE) ++
G4/G4B/G4C/G4PRO [TYPE_TRIANGLE](\ref LidarTypeID::TYPE_TRIANGLE) ++
G6/F4/F4PRO [TYPE_TRIANGLE](\ref LidarTypeID::TYPE_TRIANGLE) ++
S4/S4B/X4/R2/S2/X2/X2L [TYPE_TRIANGLE](\ref LidarTypeID::TYPE_TRIANGLE) ++
TG15/TG30/TG50/TX8/TX20 [TYPE_TOF](\ref LidarTypeID::TYPE_TOF) ++
T5/T15 [TYPE_TOF_NET](\ref LidarTypeID::TYPE_TOF_NET) ++
GS1 [TYPE_GS](\ref LidarTypeID::TYPE_GS) ++
++ * @see [LidarTypeID](\ref LidarTypeID) ++ * @see DriverInterface::setLidarType and DriverInterface::getLidarType ++ */ ++ PropertyBuilderByName(int, LidarType, private); ++ /** ++ * @brief Set and Get Sampling interval. ++ * @note Negative correlation between sampling interval and lidar sampling rate.\n ++ * sampling interval = 1e9 / sampling rate(/s)\n ++ * Set the LiDAR sampling interval to match the LiDAR. ++ * @see DriverInterface::setPointTime and DriverInterface::getPointTime ++ */ ++ PropertyBuilderByName(uint32_t, PointTime,private); ++ /*! ++ * A constructor. ++ * A more elaborate description of the constructor. ++ */ ++ GS1LidarDriver(); ++ ++ /*! ++ * A destructor. ++ * A more elaborate description of the destructor. ++ */ ++ virtual ~GS1LidarDriver(); ++ ++ /*! ++ * @brief 连接雷达 \n ++ * 连接成功后,必须使用::disconnect函数关闭 ++ * @param[in] port_path 串口号 ++ * @param[in] baudrate 波特率,YDLIDAR-GS1 雷达波特率:961200 ++ * @return 返回连接状态 ++ * @retval 0 成功 ++ * @retval < 0 失败 ++ * @note连接成功后,必须使用::disconnect函数关闭 ++ * @see 函数::GS1LidarDriver::disconnect (“::”是指定有连接功能,可以看文档里的disconnect变成绿,点击它可以跳转到disconnect.) ++ */ ++ result_t connect(const char *port_path, uint32_t baudrate); ++ ++ /*! ++ * @brief 断开雷达连接 ++ */ ++ void disconnect(); ++ ++ /*! ++ * @brief 获取当前SDK版本号 \n ++ * 静态函数 ++ * @return 返回当前SKD 版本号 ++ */ ++ virtual std::string getSDKVersion(); ++ ++ /*! ++ * @brief lidarPortList 获取雷达端口 ++ * @return 在线雷达列表 ++ */ ++ static std::map lidarPortList(); ++ ++ /*! ++ * @brief 扫图状态 \n ++ * @return 返回当前雷达扫图状态 ++ * @retval true 正在扫图 ++ * @retval false 扫图关闭 ++ */ ++ bool isscanning() const; ++ ++ /*! ++ * @brief 连接雷达状态 \n ++ * @return 返回连接状态 ++ * @retval true 成功 ++ * @retval false 失败 ++ */ ++ bool isconnected() const; ++ ++ /*! ++ * @brief 设置雷达是否带信号质量 \n ++ * 连接成功后,必须使用::disconnect函数关闭 ++ * @param[in] isintensities 是否带信号质量: ++ * true 带信号质量 ++ * false 无信号质量 ++ * @note只有S4B(波特率是153600)雷达支持带信号质量, 别的型号雷达暂不支持 ++ */ ++ void setIntensities(const bool &isintensities); ++ ++ /*! ++ * @brief 设置雷达异常自动重新连接 \n ++ * @param[in] enable 是否开启自动重连: ++ * true 开启 ++ * false 关闭 ++ */ ++ void setAutoReconnect(const bool &enable); ++ ++ /*! ++ * @brief 获取雷达设备信息 \n ++ * @param[in] parameters 设备信息 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 获取成功 ++ * @retval RESULT_FAILE or RESULT_TIMEOUT 获取失败 ++ */ ++ result_t getDevicePara(gs_device_para &info, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 配置雷达地址 \n ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 配置成功 ++ * @retval RESULT_FAILE or RESULT_TIMEOUT 配置超时 ++ */ ++ result_t setDeviceAddress(uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 开启扫描 \n ++ * @param[in] force 扫描模式 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 开启成功 ++ * @retval RESULT_FAILE 开启失败 ++ * @note 只用开启一次成功即可 ++ */ ++ result_t startScan(bool force = false, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 关闭扫描 \n ++ * @return 返回执行结果 ++ * @retval RESULT_OK 关闭成功 ++ * @retval RESULT_FAILE 关闭失败 ++ */ ++ result_t stop(); ++ ++ /*! ++ * @brief 获取激光数据 \n ++ * @param[in] nodebuffer 激光点信息 ++ * @param[in] count 一圈激光点数 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 获取成功 ++ * @retval RESULT_FAILE 获取失败 ++ * @note 获取之前,必须使用::startScan函数开启扫描 ++ */ ++ result_t grabScanData(node_info *nodebuffer, size_t &count, ++ uint32_t timeout = DEFAULT_TIMEOUT) ; ++ ++ ++ /*! ++ * @brief 补偿激光角度 \n ++ * 把角度限制在0到360度之间 ++ * @param[in] nodebuffer 激光点信息 ++ * @param[in] count 一圈激光点数 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 成功 ++ * @retval RESULT_FAILE 失败 ++ * @note 补偿之前,必须使用::grabScanData函数获取激光数据成功 ++ */ ++ result_t ascendScanData(node_info *nodebuffer, size_t count); ++ ++ /*! ++ * @brief 重置激光雷达 \n ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 成功 ++ * @retval RESULT_FAILE 失败 ++ * @note 停止扫描后再执行当前操作, 如果在扫描中调用::stop函数停止扫描 ++ */ ++ result_t reset(uint8_t addr, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ protected: ++ ++ /*! ++ * @brief 创建解析雷达数据线程 \n ++ * @note 创建解析雷达数据线程之前,必须使用::startScan函数开启扫图成功 ++ */ ++ result_t createThread(); ++ ++ ++ /*! ++ * @brief 重新连接开启扫描 \n ++ * @param[in] force 扫描模式 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 开启成功 ++ * @retval RESULT_FAILE 开启失败 ++ * @note sdk 自动重新连接调用 ++ */ ++ result_t startAutoScan(bool force = false, uint32_t timeout = DEFAULT_TIMEOUT) ; ++ ++ /*! ++ * @brief stopScan ++ * @param timeout ++ * @return ++ */ ++ result_t stopScan(uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief waitDevicePackage ++ * @param timeout ++ * @return ++ */ ++ result_t waitDevicePackage(uint32_t timeout = DEFAULT_TIMEOUT); ++ /*! ++ * @brief 解包激光数据 \n ++ * @param[in] node 解包后激光点信息 ++ * @param[in] timeout 超时时间 ++ */ ++ result_t waitPackage(node_info *node, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 发送数据到雷达 \n ++ * @param[in] nodebuffer 激光信息指针 ++ * @param[in] count 激光点数大小 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 成功 ++ * @retval RESULT_TIMEOUT 等待超时 ++ * @retval RESULT_FAILE 失败 ++ */ ++ result_t waitScanData(node_info *nodebuffer, size_t &count, ++ uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 激光数据解析线程 \n ++ */ ++ int cacheScanData(); ++ ++ /*! ++ * @brief 发送数据到雷达 \n ++ * @param[in] cmd 命名码 ++ * @param[in] payload payload ++ * @param[in] payloadsize payloadsize ++ * @return 返回执行结果 ++ * @retval RESULT_OK 成功 ++ * @retval RESULT_FAILE 失败 ++ */ ++ result_t sendCommand(uint8_t cmd, ++ const void *payload = NULL, ++ size_t payloadsize = 0); ++ ++ /*! ++ * @brief 发送数据到雷达 \n ++ * @param[in] addr 模组地址 ++ * @param[in] cmd 命名码 ++ * @param[in] payload payload ++ * @param[in] payloadsize payloadsize ++ * @return 返回执行结果 ++ * @retval RESULT_OK 成功 ++ * @retval RESULT_FAILE 失败 ++ */ ++ result_t sendCommand(uint8_t addr, ++ uint8_t cmd, ++ const void *payload = NULL, ++ size_t payloadsize = 0); ++ ++ /*! ++ * @brief 等待激光数据包头 \n ++ * @param[in] header 包头 ++ * @param[in] timeout 超时时间 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 获取成功 ++ * @retval RESULT_TIMEOUT 等待超时 ++ * @retval RESULT_FAILE 获取失败 ++ * @note 当timeout = -1 时, 将一直等待 ++ */ ++ result_t waitResponseHeader(gs_lidar_ans_header *header, ++ uint32_t timeout = DEFAULT_TIMEOUT); ++ result_t waitResponseHeaderEx(gs_lidar_ans_header *header, ++ uint8_t cmd, ++ uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /*! ++ * @brief 等待固定数量串口数据 \n ++ * @param[in] data_count 等待数据大小 ++ * @param[in] timeout 等待时间 ++ * @param[in] returned_size 实际数据大小 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 获取成功 ++ * @retval RESULT_TIMEOUT 等待超时 ++ * @retval RESULT_FAILE 获取失败 ++ * @note 当timeout = -1 时, 将一直等待 ++ */ ++ result_t waitForData(size_t data_count, uint32_t timeout = DEFAULT_TIMEOUT, ++ size_t *returned_size = NULL); ++ ++ /*! ++ * @brief 获取串口数据 \n ++ * @param[in] data 数据指针 ++ * @param[in] size 数据大小 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 获取成功 ++ * @retval RESULT_FAILE 获取失败 ++ */ ++ result_t getData(uint8_t *data, size_t size); ++ ++ /*! ++ * @brief 串口发送数据 \n ++ * @param[in] data 发送数据指针 ++ * @param[in] size 数据大小 ++ * @return 返回执行结果 ++ * @retval RESULT_OK 发送成功 ++ * @retval RESULT_FAILE 发送失败 ++ */ ++ result_t sendData(const uint8_t *data, size_t size); ++ ++ ++ /*! ++ * @brief checkTransDelay ++ */ ++ void checkTransDelay(); ++ ++ /*! ++ * @brief 关闭数据获取通道 \n ++ */ ++ void disableDataGrabbing(); ++ ++ /*! ++ * @brief 设置串口DTR \n ++ */ ++ void setDTR(); ++ ++ /*! ++ * @brief 清除串口DTR \n ++ */ ++ void clearDTR(); ++ ++ /*! ++ * @brief flushSerial ++ */ ++ void flushSerial(); ++ ++ /*! ++ * @brief checkAutoConnecting ++ */ ++ result_t checkAutoConnecting(); ++ ++ /*! ++ * @brief 换算得出点的距离和角度 ++ */ ++ void angTransform(uint16_t dist, int n, double *dstTheta, uint16_t *dstDist); ++ ++ void addPointsToVec(node_info *nodebuffer, size_t &count); ++ ++ /** ++ * @brief 串口错误信息 ++ * @param isTCP TCP or UDP ++ * @return error information ++ */ ++ virtual const char *DescribeError(bool isTCP = false); ++ ++ /** ++ * @brief GS1雷达没有健康信息\n ++ * @return result status ++ * @retval RESULT_OK success ++ * @retval RESULT_FAILE or RESULT_TIMEOUT failed ++ */ ++ virtual result_t getHealth(device_health &health, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /** ++ * @brief get Device information \n ++ * @param[in] info Device information ++ * @param[in] timeout timeout ++ * @return result status ++ * @retval RESULT_OK success ++ * @retval RESULT_FAILE or RESULT_TIMEOUT failed ++ */ ++ virtual result_t getDeviceInfo(device_info &info, uint32_t timeout = DEFAULT_TIMEOUT); ++ ++ /** ++ * @brief 设置雷达工作模式(目前只针对GS1雷达) ++ * @param[in] mode 雷达工作模式,0为避障模式;1为延边模式 ++ * @param[in] addr 雷达地址,第1个雷达地址为0x01;第2个雷达地址为0x02;第3个雷达地址为0x04; ++ * @return 成功返回RESULT_OK,否则返回非RESULT_OK ++ */ ++ virtual result_t setWorkMode(int mode=0, uint8_t addr=0x00); ++ ++ //未实现的虚函数 ++ virtual result_t getScanFrequency(scan_frequency &frequency, uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setScanFrequencyDis(scan_frequency &frequency, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setScanFrequencyAdd(scan_frequency &frequency, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setScanFrequencyAddMic(scan_frequency &frequency, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setScanFrequencyDisMic(scan_frequency &frequency, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t getSamplingRate(sampling_rate &rate, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setSamplingRate(sampling_rate &rate, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t getZeroOffsetAngle(offset_angle &angle, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ virtual result_t setScanHeartbeat(scan_heart_beat &beat, ++ uint32_t timeout = DEFAULT_TIMEOUT) { return RESULT_OK; } ++ ++public: ++ enum { ++ DEFAULT_TIMEOUT = 2000, /**< 默认超时时间. */ ++ DEFAULT_HEART_BEAT = 1000, /**< 默认检测掉电功能时间. */ ++ MAX_SCAN_NODES = 3600, /**< 最大扫描点数. */ ++ DEFAULT_TIMEOUT_COUNT = 1, ++ }; ++ ++ node_info *scan_node_buf; ///< 激光点信息 ++ size_t scan_node_count; ///< 激光点数 ++ Event _dataEvent; ///< 数据同步事件 ++ Locker _lock; ///< 线程锁 ++ Locker _serial_lock; ///< 串口锁 ++ Thread _thread; ///< 线程id ++ ++ private: ++ int PackageSampleBytes; ///< 一个包包含的激光点数 ++ serial::Serial *_serial; ///< 串口 ++ bool m_intensities; ///< 信号质量状体 ++ uint32_t m_baudrate; ///< 波特率 ++ bool isSupportMotorDtrCtrl; ///< 是否支持电机控制 ++ uint32_t trans_delay; ///< 串口传输一个byte时间 ++ int m_sampling_rate; ///< 采样频率 ++ int model; ///< 雷达型号 ++ int sample_rate; ///< ++ ++ gs1_node_package package; ///< 带信号质量协议包 ++ ++ uint16_t package_Sample_Index; ///< 包采样点索引 ++ float IntervalSampleAngle; ++ float IntervalSampleAngle_LastPackage; ++ uint8_t CheckSum; ///< 校验和 ++ uint8_t scan_frequence; ///< 协议中雷达转速 ++ ++ uint8_t CheckSumCal; ++ uint16_t SampleNumlAndCTCal; ++ uint16_t LastSampleAngleCal; ++ bool CheckSumResult; ++ uint16_t Valu8Tou16; ++ ++ std::string serial_port;///< 雷达端口 ++ uint8_t *globalRecvBuffer; ++ int retryCount; ++ bool has_device_header; ++ uint8_t last_device_byte; ++ int asyncRecvPos; ++ uint16_t async_size; ++ ++ //singleChannel ++ device_info info_; ++ device_health health_; ++ gs_lidar_ans_header header_; ++ uint8_t *headerBuffer; ++ uint8_t *infoBuffer; ++ uint8_t *healthBuffer; ++ bool get_device_info_success; ++ bool get_device_health_success; ++ ++ int package_index; ++ uint8_t package_type; ++ bool has_package_error; ++ ++ double d_compensateK0[PackageMaxModuleNums]; ++ double d_compensateK1[PackageMaxModuleNums]; ++ double d_compensateB0[PackageMaxModuleNums]; ++ double d_compensateB1[PackageMaxModuleNums]; ++ uint16_t u_compensateK0[PackageMaxModuleNums]; ++ uint16_t u_compensateK1[PackageMaxModuleNums]; ++ uint16_t u_compensateB0[PackageMaxModuleNums]; ++ uint16_t u_compensateB1[PackageMaxModuleNums]; ++ double bias[PackageMaxModuleNums]; ++ bool isValidPoint; ++ uint8_t package_Sample_Num; ++ ++ uint8_t frameNum; //帧序号 ++ uint8_t moduleNum; //模块编号 ++ bool isPrepareToSend; //是否准备好发送 ++ ++ std::vector multi_package; ++}; ++ ++}// namespace ydlidar ++ ++#endif // GS1_YDLIDAR_DRIVER_H +diff --git a/src/YDlidarDriver.cpp b/src/YDlidarDriver.cpp +index 7c1be54..d64e9ad 100644 +--- a/src/YDlidarDriver.cpp ++++ b/src/YDlidarDriver.cpp +@@ -1296,6 +1296,10 @@ void YDlidarDriver::parseNodeDebugFromBuffer(node_info *node) + (*node).sync_flag = Node_Sync; + package_index = 0; + ++ // printf("start angle %f end angle %f\n", ++ // float(FirstSampleAngle) / 64.0, ++ // float(LastSampleAngle) / 64.0); ++ + if (CheckSumResult) { + has_package_error = false; + (*node).index = package_index; +-- +2.34.1 + diff --git a/bb_fix/ydlidar-sdk/files/0004-S2-Pro.patch b/bb_fix/ydlidar-sdk/files/0004-S2-Pro.patch new file mode 100644 index 0000000000000000000000000000000000000000..cdcb215cb0a4d2bd139701cdf4cbf45573dea015 --- /dev/null +++ b/bb_fix/ydlidar-sdk/files/0004-S2-Pro.patch @@ -0,0 +1,113 @@ +From 66c77cad6191947a08a742e845d5cfa417123c1f Mon Sep 17 00:00:00 2001 +From: zhanyiaini +Date: Tue, 1 Nov 2022 19:00:02 +0800 +Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9S2-Pro=E9=87=87=E6=A0=B7?= + =?UTF-8?q?=E7=8E=87=E9=97=AE=E9=A2=98?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + core/common/DriverInterface.h | 1 + + core/common/ydlidar_help.h | 12 ++++++++---- + samples/tri_test.cpp | 14 +++++++------- + 3 files changed, 16 insertions(+), 11 deletions(-) + +diff --git a/core/common/DriverInterface.h b/core/common/DriverInterface.h +index e1e1e31..09879c6 100644 +--- a/core/common/DriverInterface.h ++++ b/core/common/DriverInterface.h +@@ -454,6 +454,7 @@ class DriverInterface { + YDLIDAR_T1 = 2,/**< T1 LiDAR Model. */ + YDLIDAR_F2 = 3,/**< F2 LiDAR Model. */ + YDLIDAR_S4 = 4,/**< S4 LiDAR Model. */ ++ YDLIDAR_S2PRO = YDLIDAR_S4,/**< S2PRO LiDAR Model. */ + YDLIDAR_G4 = 5,/**< G4 LiDAR Model. */ + YDLIDAR_X4 = 6,/**< X4 LiDAR Model. */ + YDLIDAR_G4PRO = 7,/**< G4PRO LiDAR Model. */ +diff --git a/core/common/ydlidar_help.h b/core/common/ydlidar_help.h +index 35ac3ee..b80021e 100644 +--- a/core/common/ydlidar_help.h ++++ b/core/common/ydlidar_help.h +@@ -81,9 +81,9 @@ inline std::string lidarModelToString(int model) { + + break; + +- case DriverInterface::YDLIDAR_S4: +- name = "S4"; +- ++ // case DriverInterface::YDLIDAR_S4: ++ case DriverInterface::YDLIDAR_S2PRO: ++ name = "S2PRO"; + break; + + case DriverInterface::YDLIDAR_G4: +@@ -223,7 +223,11 @@ inline std::vector getDefaultSampleRate(int model) + case DriverInterface::YDLIDAR_F4: + case DriverInterface::YDLIDAR_T1: + case DriverInterface::YDLIDAR_F2: +- case DriverInterface::YDLIDAR_S4: ++ srs.push_back(4); ++ break; ++ // case DriverInterface::YDLIDAR_S4: ++ case DriverInterface::YDLIDAR_S2PRO: ++ srs.push_back(3); + srs.push_back(4); + break; + case DriverInterface::YDLIDAR_G4: +diff --git a/samples/tri_test.cpp b/samples/tri_test.cpp +index 4e5f80c..c19b2cf 100644 +--- a/samples/tri_test.cpp ++++ b/samples/tri_test.cpp +@@ -181,7 +181,7 @@ int main(int argc, char *argv[]) + + std::string input_frequency; + +- float frequency = 8.0; ++ float frequency = 5.0; + + while (ydlidar::os_isOk() && !isSingleChannel) + { +@@ -229,12 +229,12 @@ int main(int argc, char *argv[]) + optval = 4; + laser.setlidaropt(LidarPropAbnormalCheckCount, &optval, sizeof(int)); + /// Intenstiy bit count +- optval = 8; ++ optval = 10; + laser.setlidaropt(LidarPropIntenstiyBit, &optval, sizeof(int)); + + //////////////////////bool property///////////////// + /// fixed angle resolution +- bool b_optvalue = false; ++ bool b_optvalue = true; + laser.setlidaropt(LidarPropFixedResolution, &b_optvalue, sizeof(bool)); + /// rotate 180 + laser.setlidaropt(LidarPropReversion, &b_optvalue, sizeof(bool)); +@@ -245,10 +245,10 @@ int main(int argc, char *argv[]) + /// one-way communication + laser.setlidaropt(LidarPropSingleChannel, &isSingleChannel, sizeof(bool)); + /// intensity +- b_optvalue = false; ++ b_optvalue = true; + laser.setlidaropt(LidarPropIntenstiy, &b_optvalue, sizeof(bool)); + /// Motor DTR +- b_optvalue = true; ++ b_optvalue = false; + laser.setlidaropt(LidarPropSupportMotorDtrCtrl, &b_optvalue, sizeof(bool)); + /// HeartBeat + b_optvalue = false; +@@ -303,9 +303,9 @@ int main(int argc, char *argv[]) + { + if (laser.doProcessSimple(scan)) + { +- printf("Scan received [%u] points stamp [0x%016lX]\n", ++ printf("Scan received [%u] points inc [%f]\n", + (unsigned int)scan.points.size(), +- scan.stamp); ++ scan.config.angle_increment); + // for (size_t i = 0; i < scan.points.size(); ++i) + // { + // const LaserPoint &p = scan.points.at(i); +-- +2.34.1 + diff --git a/bb_fix/ydlidar-sdk/files/0005-GS2-S2.patch b/bb_fix/ydlidar-sdk/files/0005-GS2-S2.patch new file mode 100644 index 0000000000000000000000000000000000000000..19dece4bce5b0bf2e481a6cb97eca5899068259b --- /dev/null +++ b/bb_fix/ydlidar-sdk/files/0005-GS2-S2.patch @@ -0,0 +1,1496 @@ +From 2b7e756c2823f00ba8b80911852c4127b93213cc Mon Sep 17 00:00:00 2001 +From: zhanyiaini +Date: Tue, 13 Dec 2022 18:13:16 +0800 +Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9GS2=E5=92=8CS2=E7=B3=BB?= + =?UTF-8?q?=E5=88=97=E5=90=8C=E6=97=B6=E4=BD=BF=E7=94=A8=E6=97=B6=E7=BA=BF?= + =?UTF-8?q?=E7=A8=8B=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +--- + CMakeLists.txt | 2 +- + core/base/thread.h | 6 +- + samples/gs_test.cpp | 2 +- + samples/tri_and_gs_test.cpp | 237 +++++++++++++++++++++++++ + src/CYdLidar.cpp | 6 +- + src/GS2LidarDriver.cpp | 141 +++++++-------- + src/GS2LidarDriver.h | 30 ++-- + src/YDlidarDriver.cpp | 343 ++++++++++++++++++++---------------- + 8 files changed, 519 insertions(+), 248 deletions(-) + create mode 100644 samples/tri_and_gs_test.cpp + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 0adc747..05ad037 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,7 +5,7 @@ project(ydlidar_sdk C CXX) + # version + set(YDLIDAR_SDK_VERSION_MAJOR 1) + set(YDLIDAR_SDK_VERSION_MINOR 1) +-set(YDLIDAR_SDK_VERSION_PATCH 2) ++set(YDLIDAR_SDK_VERSION_PATCH 3) + set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH}) + + ########################################################## +diff --git a/core/base/thread.h b/core/base/thread.h +index a952933..c13e04b 100644 +--- a/core/base/thread.h ++++ b/core/base/thread.h +@@ -107,19 +107,17 @@ class Thread { + void *res; + int s = -1; + s = pthread_cancel((pthread_t)(this->_handle)); +- + if (s != 0) { + } + + s = pthread_join((pthread_t)(this->_handle), &res); +- + if (s != 0) { + } + + if (res == PTHREAD_CANCELED) { +- printf("%lu thread has been canceled\n", this->_handle); +- this->_handle = 0; ++ printf("0x%X thread has been canceled\n", this->_handle); + } ++ this->_handle = 0; //强制置空线程句柄,以免再次调用该函数时出现异常 + + #endif + return 0; +diff --git a/samples/gs_test.cpp b/samples/gs_test.cpp +index 2bb7671..cea13f8 100644 +--- a/samples/gs_test.cpp ++++ b/samples/gs_test.cpp +@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) + int id = 0; + + for (it = ports.begin(); it != ports.end(); it++) { +- printf("%d. %s\n", id, it->first.c_str()); ++ printf("[%d] %s %s\n", id, it->first.c_str(), it->second.c_str()); + id++; + } + +diff --git a/samples/tri_and_gs_test.cpp b/samples/tri_and_gs_test.cpp +new file mode 100644 +index 0000000..3c28b43 +--- /dev/null ++++ b/samples/tri_and_gs_test.cpp +@@ -0,0 +1,237 @@ ++#include "CYdLidar.h" ++#include ++#include ++#include ++#include ++#include "core/base/timer.h" ++ ++using namespace std; ++using namespace ydlidar; ++ ++#if defined(_MSC_VER) ++#pragma comment(lib, "ydlidar_sdk.lib") ++#endif ++ ++int main(int argc, char *argv[]) ++{ ++ printf("__ ______ _ ___ ____ _ ____ \n"); ++ printf("\\ \\ / / _ \\| | |_ _| _ \\ / \\ | _ \\ \n"); ++ printf(" \\ V /| | | | | | || | | |/ _ \\ | |_) | \n"); ++ printf(" | | | |_| | |___ | || |_| / ___ \\| _ < \n"); ++ printf(" |_| |____/|_____|___|____/_/ \\_\\_| \\_\\ \n"); ++ printf("\n"); ++ fflush(stdout); ++ ++ ydlidar::os_init(); ++ ++ bool ret = false; ++ CYdLidar lidarGs; //GS2雷达 ++ { ++ bool isSingleChannel = false; ++ float frequency = 8.0; ++ std::string port = "/dev/ttyUSB0"; ++ int baudrate = 921600; ++ //////////////////////string property///////////////// ++ /// lidar port ++ lidarGs.setlidaropt(LidarPropSerialPort, port.c_str(), port.size()); ++ /// lidar baudrate ++ lidarGs.setlidaropt(LidarPropSerialBaudrate, &baudrate, sizeof(int)); ++ /// gs lidar ++ int optval = TYPE_GS; ++ lidarGs.setlidaropt(LidarPropLidarType, &optval, sizeof(int)); ++ /// device type ++ optval = YDLIDAR_TYPE_SERIAL; ++ lidarGs.setlidaropt(LidarPropDeviceType, &optval, sizeof(int)); ++ /// sample rate ++ optval = 4; ++ lidarGs.setlidaropt(LidarPropSampleRate, &optval, sizeof(int)); ++ /// abnormal count ++ optval = 4; ++ lidarGs.setlidaropt(LidarPropAbnormalCheckCount, &optval, sizeof(int)); ++ /// Intenstiy bit count ++ optval = 8; ++ lidarGs.setlidaropt(LidarPropIntenstiyBit, &optval, sizeof(int)); ++ //////////////////////bool property///////////////// ++ /// fixed angle resolution ++ bool b_optvalue = false; ++ lidarGs.setlidaropt(LidarPropFixedResolution, &b_optvalue, sizeof(bool)); ++ /// rotate 180 ++ lidarGs.setlidaropt(LidarPropReversion, &b_optvalue, sizeof(bool)); ++ /// Counterclockwise ++ lidarGs.setlidaropt(LidarPropInverted, &b_optvalue, sizeof(bool)); ++ b_optvalue = true; ++ lidarGs.setlidaropt(LidarPropAutoReconnect, &b_optvalue, sizeof(bool)); ++ /// one-way communication ++ lidarGs.setlidaropt(LidarPropSingleChannel, &isSingleChannel, sizeof(bool)); ++ /// intensity ++ b_optvalue = true; ++ lidarGs.setlidaropt(LidarPropIntenstiy, &b_optvalue, sizeof(bool)); ++ /// Motor DTR ++ b_optvalue = true; ++ lidarGs.setlidaropt(LidarPropSupportMotorDtrCtrl, &b_optvalue, sizeof(bool)); ++ /// HeartBeat ++ b_optvalue = false; ++ lidarGs.setlidaropt(LidarPropSupportHeartBeat, &b_optvalue, sizeof(bool)); ++ //////////////////////float property///////////////// ++ /// unit: ° ++ float f_optvalue = 180.0f; ++ lidarGs.setlidaropt(LidarPropMaxAngle, &f_optvalue, sizeof(float)); ++ f_optvalue = -180.0f; ++ lidarGs.setlidaropt(LidarPropMinAngle, &f_optvalue, sizeof(float)); ++ /// unit: m ++ f_optvalue = 1.f; ++ lidarGs.setlidaropt(LidarPropMaxRange, &f_optvalue, sizeof(float)); ++ f_optvalue = 0.025f; ++ lidarGs.setlidaropt(LidarPropMinRange, &f_optvalue, sizeof(float)); ++ /// unit: Hz ++ lidarGs.setlidaropt(LidarPropScanFrequency, &frequency, sizeof(float)); ++ ++ //雷达初始化 ++ ret = lidarGs.initialize(); ++ if (!ret) ++ { ++ fprintf(stderr, "Fail to initialize %s\n", lidarGs.DescribeError()); ++ fflush(stderr); ++ return -1; ++ } ++ } ++ ++ CYdLidar lidarS2; //S2雷达 ++ { ++ bool isSingleChannel = false; ++ float frequency = 8.0; ++ std::string port = "/dev/ttyUSB1"; ++ int baudrate = 115200; ++ //////////////////////string property///////////////// ++ /// lidar port ++ lidarS2.setlidaropt(LidarPropSerialPort, port.c_str(), port.size()); ++ //////////////////////int property///////////////// ++ /// lidar baudrate ++ lidarS2.setlidaropt(LidarPropSerialBaudrate, &baudrate, sizeof(int)); ++ /// tof lidar ++ int optval = TYPE_TRIANGLE; ++ lidarS2.setlidaropt(LidarPropLidarType, &optval, sizeof(int)); ++ /// device type ++ optval = YDLIDAR_TYPE_SERIAL; ++ lidarS2.setlidaropt(LidarPropDeviceType, &optval, sizeof(int)); ++ /// sample rate ++ optval = isSingleChannel ? 3 : 4; ++ lidarS2.setlidaropt(LidarPropSampleRate, &optval, sizeof(int)); ++ /// abnormal count ++ optval = 4; ++ lidarS2.setlidaropt(LidarPropAbnormalCheckCount, &optval, sizeof(int)); ++ /// Intenstiy bit count ++ optval = 10; ++ lidarS2.setlidaropt(LidarPropIntenstiyBit, &optval, sizeof(int)); ++ //////////////////////bool property///////////////// ++ /// fixed angle resolution ++ bool b_optvalue = true; ++ lidarS2.setlidaropt(LidarPropFixedResolution, &b_optvalue, sizeof(bool)); ++ b_optvalue = false; ++ /// rotate 180 ++ lidarS2.setlidaropt(LidarPropReversion, &b_optvalue, sizeof(bool)); ++ /// Counterclockwise ++ lidarS2.setlidaropt(LidarPropInverted, &b_optvalue, sizeof(bool)); ++ b_optvalue = true; ++ lidarS2.setlidaropt(LidarPropAutoReconnect, &b_optvalue, sizeof(bool)); ++ /// one-way communication ++ lidarS2.setlidaropt(LidarPropSingleChannel, &isSingleChannel, sizeof(bool)); ++ /// intensity ++ b_optvalue = true; ++ lidarS2.setlidaropt(LidarPropIntenstiy, &b_optvalue, sizeof(bool)); ++ /// Motor DTR ++ b_optvalue = false; ++ lidarS2.setlidaropt(LidarPropSupportMotorDtrCtrl, &b_optvalue, sizeof(bool)); ++ /// HeartBeat ++ b_optvalue = false; ++ lidarS2.setlidaropt(LidarPropSupportHeartBeat, &b_optvalue, sizeof(bool)); ++ //////////////////////float property///////////////// ++ /// unit: ° ++ float f_optvalue = 180.0f; ++ lidarS2.setlidaropt(LidarPropMaxAngle, &f_optvalue, sizeof(float)); ++ f_optvalue = -180.0f; ++ lidarS2.setlidaropt(LidarPropMinAngle, &f_optvalue, sizeof(float)); ++ /// unit: m ++ f_optvalue = 64.f; ++ lidarS2.setlidaropt(LidarPropMaxRange, &f_optvalue, sizeof(float)); ++ f_optvalue = 0.05f; ++ lidarS2.setlidaropt(LidarPropMinRange, &f_optvalue, sizeof(float)); ++ /// unit: Hz ++ lidarS2.setlidaropt(LidarPropScanFrequency, &frequency, sizeof(float)); ++ ret = lidarS2.initialize(); ++ if (!ret) ++ { ++ fprintf(stderr, "Fail to initialize %s\n", lidarS2.DescribeError()); ++ fflush(stderr); ++ return -1; ++ } ++ } ++ ++ LaserScan scanGs; //GS2点云数据 ++ LaserScan scanS2; //S2雷达点云数据 ++ while (ydlidar::os_isOk()) ++ { ++ //启动S2 ++ ret = lidarS2.turnOn(); ++ if (!ret) ++ { ++ fprintf(stderr, "Fail to turn on S2 %s\n", lidarS2.DescribeError()); ++ fflush(stderr); ++ return -1; ++ } ++ //启动GS2 ++ ret = lidarGs.turnOn(); ++ if (!ret) ++ { ++ fprintf(stderr, "Fail to turn on GS2 %s\n", lidarGs.DescribeError()); ++ fflush(stderr); ++ return -1; ++ } ++ //启动后运行5秒然后停止扫描 ++ uint64_t t = getms(); ++ while (getms() - t < 5000) ++ { ++ //获取GS2点云数据 ++ if (lidarGs.doProcessSimple(scanGs)) ++ { ++ printf("[%lu] points in [0x%016lX] module num [%d] env flag [0x%04X]\n", ++ scanGs.points.size(), ++ scanGs.stamp, ++ scanGs.moduleNum, ++ scanGs.envFlag); ++ fflush(stdout); ++ } ++ else ++ { ++ fprintf(stderr, "Failed to get Lidar GS2 Data\n"); ++ fflush(stderr); ++ } ++ //获取S2点云数据 ++ if (lidarS2.doProcessSimple(scanS2)) ++ { ++ printf("[%u] points inc [%f]\n", ++ (unsigned int)scanS2.points.size(), ++ scanS2.config.angle_increment); ++ fflush(stdout); ++ } ++ else ++ { ++ fprintf(stderr, "Failed to get Lidar S2 Data\n"); ++ fflush(stderr); ++ static int s_errorCount = 0; ++ if (s_errorCount++ > 10) ++ return -1; ++ } ++ } ++ ++ //停止S2 ++ lidarS2.turnOff(); ++ //停止GS2 ++ lidarGs.turnOff(); ++ } ++ ++ lidarGs.turnOff(); ++ lidarGs.disconnecting(); ++ ++ return 0; ++} +diff --git a/src/CYdLidar.cpp b/src/CYdLidar.cpp +index 668e24f..54e1687 100644 +--- a/src/CYdLidar.cpp ++++ b/src/CYdLidar.cpp +@@ -1088,6 +1088,7 @@ bool CYdLidar::checkLidarAbnormal() + } + } + ++ //单通雷达,计算采样率、固定分辨率时的一圈点数 + if (IS_OK(op_result) && lidarPtr->getSingleChannel()) + { + data.push_back(count); +@@ -1115,7 +1116,7 @@ bool CYdLidar::checkLidarAbnormal() + scan_time = 1.0 * static_cast(end_time - start_time) / 1e9; + bool ret = CalculateSampleRate(count, scan_time); + +- if (scan_time > 0.05 && scan_time < 0.5 && lidarPtr->getSingleChannel()) ++ if (scan_time > 0.05 && scan_time < 0.5) + { + if (!ret) + { +@@ -1717,7 +1718,8 @@ bool CYdLidar::checkScanFrequency() + + m_ScanFrequency -= frequencyOffset; + m_FixedSize = m_SampleRate * 1000 / (m_ScanFrequency - 0.1); +- printf("[YDLIDAR INFO] Current Scan Frequency: %fHz\n", m_ScanFrequency); ++ printf("[YDLIDAR] Current Scan Frequency: %fHz\n", m_ScanFrequency); ++ printf("[YDLIDAR] Fixed size: %d\n", m_FixedSize); + return true; + } + +diff --git a/src/GS2LidarDriver.cpp b/src/GS2LidarDriver.cpp +index d6193fc..8fc3708 100644 +--- a/src/GS2LidarDriver.cpp ++++ b/src/GS2LidarDriver.cpp +@@ -99,19 +99,16 @@ GS2LidarDriver::GS2LidarDriver(): + GS2LidarDriver::~GS2LidarDriver() + { + m_isScanning = false; +- + isAutoReconnect = false; + _thread.join(); + +- ScopedLocker lk(_serial_lock); +- ++ ScopedLocker l(_cmd_lock); + if (_serial) { + if (_serial->isOpen()) { + _serial->flush(); + _serial->closePort(); + } + } +- + if (_serial) { + delete _serial; + _serial = NULL; +@@ -121,7 +118,6 @@ GS2LidarDriver::~GS2LidarDriver() + delete[] globalRecvBuffer; + globalRecvBuffer = NULL; + } +- + if (scan_node_buf) { + delete[] scan_node_buf; + scan_node_buf = NULL; +@@ -130,19 +126,17 @@ GS2LidarDriver::~GS2LidarDriver() + + result_t GS2LidarDriver::connect(const char *port_path, uint32_t baudrate) + { +- ScopedLocker lk(_serial_lock); + m_baudrate = baudrate; + serial_port = string(port_path); +- +- if (!_serial) { +- _serial = new serial::Serial(port_path, m_baudrate, +- serial::Timeout::simpleTimeout(DEFAULT_TIMEOUT)); +- } +- + { +- ScopedLocker l(_lock); +- +- if (!_serial->open()) { ++ ScopedLocker l(_cmd_lock); ++ if (!_serial) ++ { ++ _serial = new serial::Serial(port_path, m_baudrate, ++ serial::Timeout::simpleTimeout(DEFAULT_TIMEOUT)); ++ } ++ if (!_serial->open()) ++ { + return RESULT_FAIL; + } + +@@ -200,7 +194,7 @@ void GS2LidarDriver::disconnect() { + + stop(); + delay(10); +- ScopedLocker l(_serial_lock); ++ ScopedLocker l(_cmd_lock); + + if (_serial) { + if (_serial->isOpen()) { +@@ -212,12 +206,11 @@ void GS2LidarDriver::disconnect() { + } + + +-void GS2LidarDriver::disableDataGrabbing() { +- { +- if (m_isScanning) { +- m_isScanning = false; +- _dataEvent.set(); +- } ++void GS2LidarDriver::disableDataGrabbing() ++{ ++ if (m_isScanning) { ++ m_isScanning = false; ++ _dataEvent.set(); + } + _thread.join(); + } +@@ -539,7 +532,7 @@ result_t GS2LidarDriver::checkAutoConnecting() { + + while (isAutoReconnect && isAutoconnting) { + { +- ScopedLocker l(_serial_lock); ++ ScopedLocker l(_cmd_lock); + + if (_serial) { + if (_serial->isOpen() || m_isConnected) { +@@ -578,7 +571,7 @@ result_t GS2LidarDriver::checkAutoConnecting() { + if (isconnected()) { + delay(100); + { +- ScopedLocker l(_serial_lock); ++ ScopedLocker l(_cmd_lock); + ans = startAutoScan(); + + if (!IS_OK(ans)) { +@@ -597,20 +590,18 @@ result_t GS2LidarDriver::checkAutoConnecting() { + + } + +-int GS2LidarDriver::cacheScanData() { ++int GS2LidarDriver::cacheScanData() ++{ + node_info local_buf[200]; + size_t count = 200; +- node_info local_scan[MAX_SCAN_NODES]; + size_t scan_count = 0; + result_t ans = RESULT_FAIL; +- memset(local_scan, 0, sizeof(local_scan)); + +- flushSerial(); +- waitScanData(local_buf, count); +- +- int timeout_count = 0; ++ int timeout_count = 0; + retryCount = 0; + ++ m_isScanning = true; ++ + while (m_isScanning) + { + count = 160; +@@ -630,7 +621,6 @@ int GS2LidarDriver::cacheScanData() { + + if (IS_OK(ans)) { + timeout_count = 0; +- local_scan[0].sync_flag = Node_NotSync; + } else { + m_isScanning = false; + return RESULT_FAIL; +@@ -638,7 +628,6 @@ int GS2LidarDriver::cacheScanData() { + } + } else { + timeout_count++; +- local_scan[0].sync_flag = Node_NotSync; + fprintf(stderr, "timeout count: %d\n", timeout_count); + fflush(stderr); + } +@@ -647,9 +636,6 @@ int GS2LidarDriver::cacheScanData() { + retryCount = 0; + } + +- // printf("sync:%d,index:%d,moduleNum:%d\n",package_type,frameNum,moduleNum); +- // fflush(stdout); +- + if (!isPrepareToSend) { + continue; + } +@@ -663,17 +649,17 @@ int GS2LidarDriver::cacheScanData() { + } + } + +- _lock.lock(); //timeout lock, wait resource copys +- scan_node_buf[0].stamp = local_buf[0].stamp; +- scan_node_buf[0].scan_frequence = local_buf[0].scan_frequence; +- scan_node_buf[0].index = 0x03 & (moduleNum >> 1); //gs2: 1, 2, 4 +- scan_node_count = 160; //一个包固定160个数据 +- // printf("count [%d] stamp [0x%016lX]\n", count, local_buf[count - 1].stamp); +- // fflush(stdout); +- _dataEvent.set(); +- _lock.unlock(); +- scan_count = 0; +- isPrepareToSend = false; ++ { ++ // printf("[YDLIDAR] GS2 points Stored in buffer %lu\n", count); ++ ScopedLocker l(_lock); ++ scan_node_buf[0].stamp = local_buf[0].stamp; ++ scan_node_buf[0].scan_frequence = local_buf[0].scan_frequence; ++ scan_node_buf[0].index = 0x03 & (moduleNum >> 1); // gs2: 1, 2, 4 ++ scan_node_count = 160; // 一个包固定160个数据 ++ _dataEvent.set(); ++ scan_count = 0; ++ isPrepareToSend = false; ++ } + } + + m_isScanning = false; +@@ -811,7 +797,7 @@ result_t GS2LidarDriver::waitPackage(node_info *node, uint32_t timeout) + else + { + recvPos = 0; +- printf("invalid gs2 data\n"); ++ // printf("invalid gs2 data\n"); + continue; + } + } +@@ -1132,25 +1118,20 @@ result_t GS2LidarDriver::grabScanData(node_info *nodebuffer, size_t &count, + count = 0; + return RESULT_TIMEOUT; + +- case Event::EVENT_OK: { +- if (scan_node_count == 0) { +- return RESULT_FAIL; +- } +- ++ case Event::EVENT_OK: ++ { + ScopedLocker l(_lock); + size_t size_to_copy = min(count, scan_node_count); + memcpy(nodebuffer, scan_node_buf, size_to_copy * sizeof(node_info)); + count = size_to_copy; + scan_node_count = 0; + } +- + return RESULT_OK; + + default: + count = 0; + return RESULT_FAIL; + } +- + } + + +@@ -1275,13 +1256,12 @@ result_t GS2LidarDriver::getDevicePara(gs_device_para &info, uint32_t timeout) { + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); +- ++ ScopedLocker l(_cmd_lock); + if ((ans = sendCommand(GS_LIDAR_CMD_GET_PARAMETER)) != RESULT_OK) { + return ans; + } + gs_lidar_ans_header response_header; +- for(int i = 0; i < PackageMaxModuleNums; i++) ++ for (int i = 0; i < PackageMaxModuleNums && i < moduleCount; i++) + { + if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) { + return ans; +@@ -1344,7 +1324,7 @@ result_t GS2LidarDriver::setDeviceAddress(uint32_t timeout) + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(GS_LIDAR_CMD_GET_ADDRESS)) != RESULT_OK) { + return ans; +@@ -1354,12 +1334,12 @@ result_t GS2LidarDriver::setDeviceAddress(uint32_t timeout) + if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) { + return ans; + } +- + if (response_header.type != GS_LIDAR_CMD_GET_ADDRESS) { + return RESULT_FAIL; + } + +- printf("[YDLIDAR] Lidar module count %d", (response_header.address << 1) + 1); ++ moduleCount = (response_header.address >> 1) + 1; ++ printf("[YDLIDAR] GS Lidar count %u\n", moduleCount); + } + + return RESULT_OK; +@@ -1427,13 +1407,12 @@ result_t GS2LidarDriver::startScan(bool force, uint32_t timeout) { + + //获取GS2参数 + gs_device_para gs2_info; +-// delay(30); +- getDevicePara(gs2_info, 300); +-// delay(30); ++ ans = getDevicePara(gs2_info, 300); ++ if (IS_OK(ans)) + { + flushSerial(); + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : GS_LIDAR_CMD_SCAN)) != + RESULT_OK) { + return ans; +@@ -1446,7 +1425,6 @@ result_t GS2LidarDriver::startScan(bool force, uint32_t timeout) { + if ((ans = waitResponseHeader(&response_header, timeout)) != RESULT_OK) { + return ans; + } +- + if (response_header.type != GS_LIDAR_ANS_SCAN) { + printf("[CYdLidar] Response to start scan type error!\n"); + return RESULT_FAIL; +@@ -1468,7 +1446,7 @@ result_t GS2LidarDriver::stopScan(uint32_t timeout) { + return RESULT_FAIL; + } + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(GS_LIDAR_CMD_STOP)) != RESULT_OK) { + return ans; +@@ -1485,19 +1463,26 @@ result_t GS2LidarDriver::stopScan(uint32_t timeout) { + return RESULT_OK; + } + +-result_t GS2LidarDriver::createThread() { ++result_t GS2LidarDriver::createThread() ++{ ++ // 如果线程已启动,则先退出线程 ++ if (_thread.getHandle()) ++ { ++ m_isScanning = false; ++ _thread.join(); ++ } + _thread = CLASS_THREAD(GS2LidarDriver, cacheScanData); + +- if (_thread.getHandle() == 0) { +- m_isScanning = false; ++ if (!_thread.getHandle()) { + return RESULT_FAIL; + } + +- m_isScanning = true; ++ printf("[GS2Lidar] Create GS2 thread 0x%X\n", _thread.getHandle()); ++ fflush(stdout); ++ + return RESULT_OK; + } + +- + result_t GS2LidarDriver::startAutoScan(bool force, uint32_t timeout) { + result_t ans; + +@@ -1509,7 +1494,7 @@ result_t GS2LidarDriver::startAutoScan(bool force, uint32_t timeout) { + delay(10); + { + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : GS_LIDAR_CMD_SCAN)) != + RESULT_OK) { +@@ -1536,10 +1521,10 @@ result_t GS2LidarDriver::startAutoScan(bool force, uint32_t timeout) { + /************************************************************************/ + /* stop scan */ + /************************************************************************/ +-result_t GS2LidarDriver::stop() { ++result_t GS2LidarDriver::stop() ++{ + if (isAutoconnting) { + isAutoReconnect = false; +- m_isScanning = false; + } + + disableDataGrabbing(); +@@ -1559,7 +1544,7 @@ result_t GS2LidarDriver::reset(uint8_t addr, uint32_t timeout) { + return RESULT_FAIL; + } + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(addr, GS_LIDAR_CMD_RESET)) != RESULT_OK) { + return ans; +@@ -1608,7 +1593,7 @@ result_t GS2LidarDriver::getDeviceInfo(device_info &info, uint32_t timeout) + disableDataGrabbing(); + // flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ret = sendCommand(GS_LIDAR_CMD_GET_VERSION)) != RESULT_OK) { + return ret; +@@ -1662,7 +1647,7 @@ result_t GS2LidarDriver::setWorkMode(int mode, uint8_t addr) + flushSerial(); + + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + uint8_t m = uint8_t(mode); + if ((ans = sendCommand(addr, GS_LIDAR_CMD_SET_MODE, &m, 1)) != RESULT_OK) { + return ans; +diff --git a/src/GS2LidarDriver.h b/src/GS2LidarDriver.h +index 12cfdb9..17e1eef 100644 +--- a/src/GS2LidarDriver.h ++++ b/src/GS2LidarDriver.h +@@ -511,18 +511,18 @@ public: + DEFAULT_TIMEOUT_COUNT = 1, + }; + +- node_info *scan_node_buf; ///< 激光点信息 +- size_t scan_node_count; ///< 激光点数 +- Event _dataEvent; ///< 数据同步事件 +- Locker _lock; ///< 线程锁 +- Locker _serial_lock; ///< 串口锁 +- Thread _thread; ///< 线程id ++ // node_info *scan_node_buf; ///< 激光点信息 ++ // size_t scan_node_count; ///< 激光点数 ++ // Event _dataEvent; ///< 数据同步事件 ++ // Locker _lock; ///< 线程锁 ++ // Locker _cmd_lock; ///< 串口锁 ++ // Thread _thread; ///< 线程id + + private: + int PackageSampleBytes; ///< 一个包包含的激光点数 + serial::Serial *_serial; ///< 串口 +- bool m_intensities; ///< 信号质量状体 +- uint32_t m_baudrate; ///< 波特率 ++ // bool m_intensities; ///< 信号质量状体 ++ // uint32_t m_baudrate; ///< 波特率 + bool isSupportMotorDtrCtrl; ///< 是否支持电机控制 + uint32_t trans_delay; ///< 串口传输一个byte时间 + int m_sampling_rate; ///< 采样频率 +@@ -531,7 +531,7 @@ public: + + gs2_node_package package; ///< 带信号质量协议包 + +- uint16_t package_Sample_Index; ///< 包采样点索引 ++ // uint16_t package_Sample_Index; ///< 包采样点索引 + float IntervalSampleAngle; + float IntervalSampleAngle_LastPackage; + uint8_t CheckSum; ///< 校验和 +@@ -543,9 +543,9 @@ public: + bool CheckSumResult; + uint16_t Valu8Tou16; + +- std::string serial_port;///< 雷达端口 ++ // std::string serial_port;///< 雷达端口 + uint8_t *globalRecvBuffer; +- int retryCount; ++ // int retryCount; + bool has_device_header; + uint8_t last_device_byte; + int asyncRecvPos; +@@ -577,10 +577,10 @@ public: + bool isValidPoint; + uint8_t package_Sample_Num; + +- uint8_t frameNum; //帧序号 +- uint8_t moduleNum; //模块编号 +- bool isPrepareToSend; //是否准备好发送 +- ++ uint8_t frameNum = 0; //帧序号 ++ uint8_t moduleNum = 0; //模块编号 ++ bool isPrepareToSend = false; //是否准备好发送 ++ uint8_t moduleCount = 1; //当前模组数量 + std::vector multi_package; + }; + +diff --git a/src/YDlidarDriver.cpp b/src/YDlidarDriver.cpp +index d64e9ad..d811620 100644 +--- a/src/YDlidarDriver.cpp ++++ b/src/YDlidarDriver.cpp +@@ -92,67 +92,74 @@ YDlidarDriver::YDlidarDriver(uint8_t type): + m_BlockRevSize = 0; + } + +-YDlidarDriver::~YDlidarDriver() { +- { +- m_isScanning = false; +- } +- ++YDlidarDriver::~YDlidarDriver() ++{ ++ m_isScanning = false; + isAutoReconnect = false; + _thread.join(); + delay(200); + +- ScopedLocker lck(_cmd_lock); +- +- if (_serial) { +- if (_serial->isOpen()) { +- _serial->flush(); +- _serial->closePort(); ++ { ++ ScopedLocker l(_cmd_lock); ++ if (_serial) ++ { ++ if (_serial->isOpen()) ++ { ++ _serial->flush(); ++ _serial->closePort(); ++ } ++ } ++ if (_serial) ++ { ++ delete _serial; ++ _serial = NULL; + } + } + +- if (_serial) { +- delete _serial; +- _serial = NULL; +- } +- +- if (globalRecvBuffer) { +- delete[] globalRecvBuffer; +- globalRecvBuffer = NULL; +- } ++ { ++ ScopedLocker l(_lock); ++ if (globalRecvBuffer) ++ { ++ delete[] globalRecvBuffer; ++ globalRecvBuffer = NULL; ++ } + +- if (scan_node_buf) { +- delete[] scan_node_buf; +- scan_node_buf = NULL; ++ if (scan_node_buf) ++ { ++ delete[] scan_node_buf; ++ scan_node_buf = NULL; ++ } + } + } + +- +-result_t YDlidarDriver::connect(const char *port_path, uint32_t baudrate) { +- ScopedLocker lck(_cmd_lock); ++result_t YDlidarDriver::connect(const char *port_path, uint32_t baudrate) ++{ + m_baudrate = baudrate; + serial_port = string(port_path); + +- if (!_serial) { +- if (m_TranformerType == YDLIDAR_TYPE_TCP) { +- _serial = new CActiveSocket(); +- } else { +- _serial = new serial::Serial(port_path, m_baudrate, +- serial::Timeout::simpleTimeout(DEFAULT_TIMEOUT)); +- } +- +- _serial->bindport(port_path, baudrate); +- } +- + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); ++ if (!_serial) ++ { ++ if (m_TranformerType == YDLIDAR_TYPE_TCP) ++ { ++ _serial = new CActiveSocket(); ++ } ++ else ++ { ++ _serial = new serial::Serial(port_path, m_baudrate, ++ serial::Timeout::simpleTimeout(DEFAULT_TIMEOUT)); ++ } ++ _serial->bindport(port_path, baudrate); ++ } + +- if (!_serial->open()) { ++ if (!_serial->open()) ++ { + setDriverError(NotOpenError); + return RESULT_FAIL; + } + + m_isConnected = true; +- + } + + stopScan(); +@@ -217,8 +224,8 @@ void YDlidarDriver::disconnect() { + + stop(); + delay(10); +- ScopedLocker l(_cmd_lock); + ++ ScopedLocker l(_cmd_lock); + if (_serial) { + if (_serial->isOpen()) { + _serial->closePort(); +@@ -226,7 +233,6 @@ void YDlidarDriver::disconnect() { + } + + m_isConnected = false; +- + } + + +@@ -416,64 +422,81 @@ result_t YDlidarDriver::waitForData(size_t data_count, uint32_t timeout, + return (result_t)_serial->waitfordata(data_count, timeout, returned_size); + } + +-result_t YDlidarDriver::checkAutoConnecting(bool serialError) { ++result_t YDlidarDriver::checkAutoConnecting(bool serialError) ++{ + result_t ans = RESULT_FAIL; + isAutoconnting = true; + m_InvalidNodeCount = 0; + +- if (m_driverErrno != BlockError) { ++ if (m_driverErrno != BlockError) ++ { + setDriverError(TimeoutError); + } + +- +- while (isAutoReconnect && isAutoconnting) { ++ while (isAutoReconnect && isAutoconnting) ++ { + { + ScopedLocker l(_cmd_lock); ++ if (_serial) ++ { ++ if (_serial->isOpen() || m_isConnected) ++ { ++ size_t buffer_size = _serial->available(); ++ m_BufferSize += buffer_size; + +- if (_serial) { +- if (_serial->isOpen() || m_isConnected) { +- size_t buffer_size = _serial->available(); +- m_BufferSize += buffer_size; +- +- if (m_BufferSize && m_BufferSize % 7 == 0) { +- setDriverError(BlockError); +- } else { +- if (buffer_size > 0 || m_BufferSize > 0) { +- if (m_driverErrno != BlockError) { +- setDriverError(TrembleError); ++ if (m_BufferSize && m_BufferSize % 7 == 0) ++ { ++ setDriverError(BlockError); ++ } ++ else ++ { ++ if (buffer_size > 0 || m_BufferSize > 0) ++ { ++ if (m_driverErrno != BlockError) ++ { ++ setDriverError(TrembleError); ++ } ++ } ++ else ++ { ++ setDriverError(NotBufferError); + } +- } else { +- setDriverError(NotBufferError); + } +- } + +- if ((retryCount % 2 == 1) || serialError) { +- m_isConnected = false; +- _serial->closePort(); +- delete _serial; +- _serial = NULL; +- } else { +- m_BufferSize -= buffer_size; +- } ++ if ((retryCount % 2 == 1) || serialError) ++ { ++ m_isConnected = false; ++ _serial->closePort(); ++ delete _serial; ++ _serial = NULL; ++ } ++ else ++ { ++ m_BufferSize -= buffer_size; ++ } + } + } + } + +- if (!m_isConnected && ((retryCount % 2 == 1) || serialError)) { +- if (!IS_OK(connect(serial_port.c_str(), m_baudrate))) { ++ if (!m_isConnected && ((retryCount % 2 == 1) || serialError)) ++ { ++ if (!IS_OK(connect(serial_port.c_str(), m_baudrate))) ++ { + setDriverError(NotOpenError); + } + } + + retryCount++; + +- if (retryCount > 50) { ++ if (retryCount > 50) ++ { + retryCount = 50; + } + + int tempCount = 0; + +- while (isAutoReconnect && isscanning() && tempCount < retryCount) { ++ while (isAutoReconnect && isscanning() && tempCount < retryCount) ++ { + delay(200); + tempCount++; + } +@@ -482,64 +505,76 @@ result_t YDlidarDriver::checkAutoConnecting(bool serialError) { + int retryConnect = 0; + + while (isAutoReconnect && +- connect(serial_port.c_str(), m_baudrate) != RESULT_OK) { ++ connect(serial_port.c_str(), m_baudrate) != RESULT_OK) ++ { + retryConnect++; + +- if (retryConnect > 25) { ++ if (retryConnect > 25) ++ { + retryConnect = 25; + } + + tempCount = 0; + setDriverError(NotOpenError); + +- while (isAutoReconnect && isscanning() && tempCount < retryConnect) { ++ while (isAutoReconnect && isscanning() && tempCount < retryConnect) ++ { + delay(200); + tempCount++; + } + } + +- if (!isAutoReconnect) { ++ if (!isAutoReconnect) ++ { + m_isScanning = false; + isAutoconnting = false; + return RESULT_FAIL; + } + +- if (isconnected()) { ++ if (isconnected()) ++ { + delay(50); + +- if (!m_SingleChannel && m_driverErrno != BlockError) { ++ if (!m_SingleChannel && m_driverErrno != BlockError) ++ { + device_info devinfo; + ans = getDeviceInfo(devinfo); + +- if (!IS_OK(ans)) { +- stopScan(); +- ans = getDeviceInfo(devinfo); ++ if (!IS_OK(ans)) ++ { ++ stopScan(); ++ ans = getDeviceInfo(devinfo); + } + +- if (!IS_OK(ans)) { +- setDriverError(DeviceNotFoundError); +- continue; ++ if (!IS_OK(ans)) ++ { ++ setDriverError(DeviceNotFoundError); ++ continue; + } + } + + { +- ScopedLocker l(_cmd_lock); + ans = startAutoScan(); + +- if (!IS_OK(ans)) { +- ans = startAutoScan(); ++ if (!IS_OK(ans)) ++ { ++ ans = startAutoScan(); + } + } + +- if (IS_OK(ans)) { ++ if (IS_OK(ans)) ++ { + isAutoconnting = false; + +- if (getDriverError() == DeviceNotFoundError) { +- setDriverError(NoError); ++ if (getDriverError() == DeviceNotFoundError) ++ { ++ setDriverError(NoError); + } + + return ans; +- } else { ++ } ++ else ++ { + setDriverError(DeviceNotFoundError); + } + } +@@ -547,7 +582,6 @@ result_t YDlidarDriver::checkAutoConnecting(bool serialError) { + + isAutoconnting = false; + return RESULT_FAIL; +- + } + + result_t YDlidarDriver::autoHeartBeat() { +@@ -555,7 +589,7 @@ result_t YDlidarDriver::autoHeartBeat() { + return RESULT_FAIL; + } + +- ScopedLocker lock(_lock); ++ ScopedLocker l(_cmd_lock); + result_t ans = sendCommand(LIDAR_CMD_SCAN); + return ans; + } +@@ -599,21 +633,23 @@ int YDlidarDriver::cacheScanData() + waitDevicePackage(1000); + } + +- flushSerial(); +- waitScanData(local_buf, count); ++ // flushSerial(); ++ // waitScanData(local_buf, count); + +- int timeout_count = 0; ++ int timeout_count = 0; + retryCount = 0; + m_BufferSize = 0; + m_heartbeat_ts = getms(); + bool m_last_frame_valid = false; + ++ m_isScanning = true; ++ + while (m_isScanning) + { + count = 128; + ans = waitScanData(local_buf, count, DEFAULT_TIMEOUT / 2); + +- // printf("count %llu\n", count); ++ // printf("count %lu ret %d\n", count, ans); + // fflush(stdout); + + if (!IS_OK(ans)) { +@@ -668,9 +704,10 @@ int YDlidarDriver::cacheScanData() + { + if (local_buf[pos].sync_flag & LIDAR_RESP_MEASUREMENT_SYNCBIT) + { ++ // printf("[YDLIDAR] S2 points Stored in buffer start %lu\n", scan_count); + if (local_scan[0].sync_flag & LIDAR_RESP_MEASUREMENT_SYNCBIT) + { +- _lock.lock();//timeout lock, wait resource copy ++ ScopedLocker l(_lock); + //将下一圈的第一个点的采集时间作为当前圈数据的采集时间 + // local_scan[0].stamp = local_buf[pos].stamp; + // if (local_scan[0].stamp == 0) { +@@ -681,7 +718,7 @@ int YDlidarDriver::cacheScanData() + memcpy(scan_node_buf, local_scan, scan_count * sizeof(node_info)); + scan_node_count = scan_count; + _dataEvent.set(); +- _lock.unlock(); ++ // printf("[YDLIDAR] S2 points Stored in buffer end %lu\n", scan_count); + } + + scan_count = 0; +@@ -928,14 +965,15 @@ result_t YDlidarDriver::parseResponseHeader( + size_t remainSize = PackagePaidBytes - recvPos; + size_t recvSize = 0; + ans = waitForData(remainSize, timeout - waitTime, &recvSize); +- + if (!IS_OK(ans)) ++ { + return ans; ++ } + + if (recvSize > remainSize) + recvSize = remainSize; + +- getData(globalRecvBuffer, recvSize); ++ ans = getData(globalRecvBuffer, recvSize); + // printf("recv: "); + // printHex(globalRecvBuffer, recvSize); + +@@ -1273,6 +1311,7 @@ void YDlidarDriver::calcutePackageCT() { + package_CT = packages.package_CT; + nowPackageNum = packages.nowPackageNum; + } ++ // printf("[YDLIDAR] S2 pack points %u\n", nowPackageNum); + } + + void YDlidarDriver::parseNodeDebugFromBuffer(node_info *node) +@@ -1414,7 +1453,8 @@ void YDlidarDriver::parseNodeFromeBuffer(node_info *node) + + package_Sample_Index ++; + +- if (package_Sample_Index >= nowPackageNum) { ++ if (package_Sample_Index >= nowPackageNum) ++ { + package_Sample_Index = 0; + CheckSumResult = false; + } +@@ -1485,36 +1525,37 @@ result_t YDlidarDriver::waitScanData( + return RESULT_FAIL; + } + +- +-result_t YDlidarDriver::grabScanData(node_info *nodebuffer, size_t &count, +- uint32_t timeout) { +- switch (_dataEvent.wait(timeout)) { ++result_t YDlidarDriver::grabScanData(node_info *nodebuffer, ++ size_t &count, ++ uint32_t timeout) ++{ ++ switch (_dataEvent.wait(timeout)) ++ { + case Event::EVENT_TIMEOUT: +- count = 0; +- return RESULT_TIMEOUT; ++ count = 0; ++ return RESULT_TIMEOUT; + +- case Event::EVENT_OK: { +- if (scan_node_count == 0) { +- return RESULT_FAIL; +- } ++ case Event::EVENT_OK: ++ { ++ ScopedLocker l(_lock); ++ // if (scan_node_count == 0) ++ // { ++ // return RESULT_FAIL; ++ // } + +- ScopedLocker l(_lock); +- size_t size_to_copy = min(count, scan_node_count); +- memcpy(nodebuffer, scan_node_buf, size_to_copy * sizeof(node_info)); +- count = size_to_copy; +- scan_node_count = 0; ++ size_t size_to_copy = min(count, scan_node_count); ++ memcpy(nodebuffer, scan_node_buf, size_to_copy * sizeof(node_info)); ++ count = size_to_copy; ++ scan_node_count = 0; + } +- +- return RESULT_OK; ++ return RESULT_OK; + + default: +- count = 0; +- return RESULT_FAIL; +- } +- ++ count = 0; ++ return RESULT_FAIL; ++ } + } + +- + result_t YDlidarDriver::ascendScanData(node_info *nodebuffer, size_t count) { + float inc_origin_angle = (float)360.0 / count; + int i = 0; +@@ -1645,7 +1686,7 @@ result_t YDlidarDriver::getHealth(device_health &health, uint32_t timeout) { + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_DEVICE_HEALTH)) != RESULT_OK) { + return ans; +@@ -1702,7 +1743,7 @@ result_t YDlidarDriver::getDeviceInfo(device_info &info, uint32_t timeout) { + // disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_DEVICE_INFO)) != RESULT_OK) { + return ans; +@@ -1843,8 +1884,7 @@ result_t YDlidarDriver::startScan(bool force, uint32_t timeout) + flushSerial(); + delay(30); + { +- ScopedLocker l(_lock); +- ++ ScopedLocker l(_cmd_lock); + if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : LIDAR_CMD_SCAN)) != + RESULT_OK) + { +@@ -1890,7 +1930,7 @@ result_t YDlidarDriver::stopScan(uint32_t timeout) { + return RESULT_FAIL; + } + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + sendCommand(LIDAR_CMD_FORCE_STOP); + delay(5); + sendCommand(LIDAR_CMD_STOP); +@@ -1898,15 +1938,24 @@ result_t YDlidarDriver::stopScan(uint32_t timeout) { + return RESULT_OK; + } + +-result_t YDlidarDriver::createThread() { ++result_t YDlidarDriver::createThread() ++{ ++ //如果线程已启动,则先退出线程 ++ if (_thread.getHandle()) ++ { ++ m_isScanning = false; ++ _thread.join(); ++ } ++ + _thread = CLASS_THREAD(YDlidarDriver, cacheScanData); + +- if (_thread.getHandle() == 0) { +- m_isScanning = false; ++ if (!_thread.getHandle()) { + return RESULT_FAIL; + } + +- m_isScanning = true; ++ printf("[YDlidar] Create thread 0x%X\n", _thread.getHandle()); ++ fflush(stdout); ++ + return RESULT_OK; + } + +@@ -1922,7 +1971,7 @@ result_t YDlidarDriver::startAutoScan(bool force, uint32_t timeout) { + delay(10); + { + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(force ? LIDAR_CMD_FORCE_SCAN : LIDAR_CMD_SCAN)) != + RESULT_OK) { +@@ -1984,7 +2033,7 @@ result_t YDlidarDriver::reset(uint32_t timeout) { + return RESULT_FAIL; + } + +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_RESET)) != RESULT_OK) { + return ans; +@@ -1997,7 +2046,7 @@ result_t YDlidarDriver::reset(uint32_t timeout) { + /* startMotor */ + /************************************************************************/ + result_t YDlidarDriver::startMotor() { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if (m_SupportMotorDtrCtrl) { + setDTR(); +@@ -2014,7 +2063,7 @@ result_t YDlidarDriver::startMotor() { + /* stopMotor */ + /************************************************************************/ + result_t YDlidarDriver::stopMotor() { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if (m_SupportMotorDtrCtrl) { + clearDTR(); +@@ -2041,7 +2090,7 @@ result_t YDlidarDriver::getScanFrequency(scan_frequency &frequency, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_AIMSPEED)) != RESULT_OK) { + return ans; +@@ -2084,7 +2133,7 @@ result_t YDlidarDriver::setScanFrequencyAdd(scan_frequency &frequency, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_AIMSPEED_ADD)) != RESULT_OK) { + return ans; +@@ -2127,7 +2176,7 @@ result_t YDlidarDriver::setScanFrequencyDis(scan_frequency &frequency, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_AIMSPEED_DIS)) != RESULT_OK) { + return ans; +@@ -2170,7 +2219,7 @@ result_t YDlidarDriver::setScanFrequencyAddMic(scan_frequency &frequency, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_AIMSPEED_ADDMIC)) != RESULT_OK) { + return ans; +@@ -2213,7 +2262,7 @@ result_t YDlidarDriver::setScanFrequencyDisMic(scan_frequency &frequency, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_AIMSPEED_DISMIC)) != RESULT_OK) { + return ans; +@@ -2255,7 +2304,7 @@ result_t YDlidarDriver::getSamplingRate(sampling_rate &rate, uint32_t timeout) { + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_SAMPLING_RATE)) != RESULT_OK) { + return ans; +@@ -2298,7 +2347,7 @@ result_t YDlidarDriver::setSamplingRate(sampling_rate &rate, uint32_t timeout) { + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_SAMPLING_RATE)) != RESULT_OK) { + return ans; +@@ -2341,7 +2390,7 @@ result_t YDlidarDriver::getZeroOffsetAngle(offset_angle &angle, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_OFFSET_ANGLE)) != RESULT_OK) { + return ans; +@@ -2384,7 +2433,7 @@ result_t YDlidarDriver::setScanHeartbeat(scan_heart_beat &beat, + disableDataGrabbing(); + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_SET_HEART_BEAT)) != RESULT_OK) { + return ans; +@@ -2426,7 +2475,7 @@ result_t YDlidarDriver::getAutoZeroOffsetAngle(offset_angle &angle, + + flushSerial(); + { +- ScopedLocker l(_lock); ++ ScopedLocker l(_cmd_lock); + + if ((ans = sendCommand(LIDAR_CMD_GET_OFFSET_ANGLE)) != RESULT_OK) { + return ans; +-- +2.34.1 + diff --git a/bb_fix/ydlidar-sdk/fix/APPENDS b/bb_fix/ydlidar-sdk/fix/APPENDS index 07124b22db84e2633aa8c3ad00bedeea6b1f6ff1..7e94b2b69963711f47187b4110c908eb01f949de 100644 --- a/bb_fix/ydlidar-sdk/fix/APPENDS +++ b/bb_fix/ydlidar-sdk/fix/APPENDS @@ -15,3 +15,5 @@ FILES:${PN}-dev += " \ " EXTRA_OECMAKE += " -DBUILD_TEST=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_INSTALL_LIBDIR=${libdir}" +CXXFLAGS_remove = "-O2" +CXXFLAGS_append = " -O0" diff --git a/change-obs-packages-to-gitee.sh b/change-obs-packages-to-gitee.sh new file mode 100755 index 0000000000000000000000000000000000000000..23409474de811d6b3acd6c4efcba38f5690d910c --- /dev/null +++ b/change-obs-packages-to-gitee.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +. base.sh + +USER_INFO="$1" +OBS_PACKAGES_LIST=${OUTPUT}/obs-packages.list +OBS_BASE=${OUTPUT}/obs +SERVICE_FILE=_service + + +prepare() +{ + if [ ! -d "${OBS_BASE}" -o ! -f "${OBS_PACKAGES_LIST}" ] + then + log_error "please run download-osb-projects.sh first" + exit 1 + fi +} + +main() +{ + prepare + + info_log "Start to change obs packages." + cd ${OBS_BASE}/${OBS_PROJECT} + + while read pkg + do + info_log "start change package $pkg" + + grep -q "^${pkg}$" ${ROS_PROJECTS_NAME} + if [ $? -eq 0 ] + then + branch=${OPENEULER_SP_BRANCH} + else + branch=${OPENEULER_ROS_DEP_PKG_BRANCH} + fi + + cd ${OBS_BASE}/${OBS_PROJECT}/${pkg} + echo "" > ${SERVICE_FILE} + echo " " >> ${SERVICE_FILE} + echo " git" >> ${SERVICE_FILE} + echo " https://${GITEE_DOMAIN}/${GITEE_ORG}/${pkg}.git" >> ${SERVICE_FILE} + echo " *" >> ${SERVICE_FILE} + echo " *" >> ${SERVICE_FILE} + echo " ${branch}" >> ${SERVICE_FILE} + echo " " >> ${SERVICE_FILE} + echo "" >> ${SERVICE_FILE} + + osc ci -m "change remote to ${GITEE_DOMAIN}/${GITEE_ORG}" + [ $? -ne 0 ] && log_error "change package $pkg error" + done < ${OBS_PACKAGES_LIST} + + info_log "get status of projects ok" +} + +main $* diff --git a/check-build-status-in-obs.sh b/check-build-status-in-obs.sh index 589f2220a1354ecc9f362b3d7183c658b4ec6893..08053903d2cf26836a2488bd16bccb5842cad0b7 100755 --- a/check-build-status-in-obs.sh +++ b/check-build-status-in-obs.sh @@ -37,7 +37,8 @@ main() info_log "Start to analyse ros-pkg." cd ${ROS_OUTPUT_TMP} rm -f src - wget http://119.3.219.20:82/openEuler:/ROS:/humble/standard_x86_64/src + prj_path=`echo ${OBS_PROJECT} | sed -e "s#:#:/#g"` + wget http://119.3.219.20:82/${prj_path}/standard_x86_64/src grep "\.src.rpm" src | awk -F"href=\"" '{print $2}' | cut -d'"' -f1 | sed -e "s/\-[[:digit:]]\+\..*//g" >.build_succeeded while read project diff --git a/clone-projects-from-gitee.sh b/clone-projects-from-gitee.sh index c32609b3ef73502ba369c4d6e1de92c45ec81986..28c412e5cb1c845addde0a6ef15f67a7bedca0e3 100755 --- a/clone-projects-from-gitee.sh +++ b/clone-projects-from-gitee.sh @@ -2,9 +2,9 @@ . base.sh -GITEE_URL=git@gitee.com -GITEE_ORG=will_niutao +GITEE_URL=git@${GITEE_DOAMIN} GITEE_BASE=${OUTPUT}/gitee +CLONE_BRANCH=humble prepare() { @@ -30,12 +30,11 @@ main() if [ -d ${GITEE_BASE}/${project}/.git ] then cd ${GITEE_BASE}/${project} - git pull origin humble + git pull origin ${CLONE_BRANCH} continue fi cd ${GITEE_BASE} - #git clone ${GITEE_DOMAIN}:${GITEE_ORG}/${project}.git git clone https://${GITEE_DOMAIN}/${GITEE_ORG}/${project}.git if [ $? -ne 0 ] then @@ -43,12 +42,12 @@ main() continue fi cd ${project} - git branch -a | grep ${ROS_DISTRO} + git branch -a | grep ${CLONE_BRANCH} if [ $? -eq 0 ] then - git checkout ${ROS_DISTRO} + git checkout ${CLONE_BRANCH} else - git checkout -b ${ROS_DISTRO} + git checkout -b ${CLONE_BRANCH} fi done < ${ROS_PROJECTS_NAME} diff --git a/config b/config index ffe5a54b12f6f3e325743af36439bb40faf18612..9cd63e9dcfa63be2adaa348af69ba5649334f10e 100644 --- a/config +++ b/config @@ -2,7 +2,9 @@ ROS_DISTRO=humble SRC_TAR_FROM=ubuntu DEBUG=no SRC_TAR_BASE_URL=https://packages.ros.org/ros2/ubuntu/pool/main/r -GITEE_ORG=your_name +GITEE_ORG=src-openeuler GITEE_DOMAIN=gitee.com OBS_DOMAIN=build.openeuler.openatom.cn OBS_PROJECT=openEuler:ROS:humble +OPENEULER_BASE_VERSION=openEuler-22.03-LTS +OPENEULER_SP_VERSION=SP2 diff --git a/create-ebs-projects.sh b/create-ebs-projects.sh new file mode 100755 index 0000000000000000000000000000000000000000..849f84045707db7dc2365649d811d4337dcfc1c7 --- /dev/null +++ b/create-ebs-projects.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +. base.sh + +EBS_CONFIG_TPLT=${ROOT}/template/project.json +EBS_CONFIG=${OUTPUT}/project.json +EBS_PROJECTS=${OUTPUT}/ebs-projects.list + +prepare() +{ + if [ ! -f ${ROS_PROJECTS_NAME} -o ! -f ${EBS_PROJECTS} ] + then + error_log "Please give the source repo path of ros" + exit 1 + fi +} + +main() +{ + prepare + + info_log "Start to analyse ros-pkg." + + cp ${EBS_CONFIG_TPLT} ${EBS_CONFIG} + + while read pkg + do + info_log "start create project $pkg" + grep -q "^${pkg}$" ${ROS_PROJECTS_NAME} + if [ $? -eq 0 ] + then + branch=${OPENEULER_SP_BRANCH} + else + branch=${OPENEULER_ROS_DEP_PKG_BRANCH} + fi + + echo ' {' >> ${EBS_CONFIG} + echo ' "spec_name": "'${pkg}'",' >> ${EBS_CONFIG} + echo ' "spec_url": "'https://${GITEE_DOMAIN}/${GITEE_ORG}/${pkg}.git'",' >> ${EBS_CONFIG} + echo ' "spec_branch": "'${branch}'",' >> ${EBS_CONFIG} + echo ' "spec_description": "sig-ROS package '${pkg}'"' >> ${EBS_CONFIG} + echo ' },' >> ${EBS_CONFIG} + done < ${EBS_PROJECTS} + + echo ' ]' >> ${EBS_CONFIG} + echo '}' >> ${EBS_CONFIG} + + info_log "create project ok" +} + +main $* + diff --git a/create-graph-deps-for-check-list.sh b/create-graph-deps-for-check-list.sh index 1ede1889e31b007a5f049972d3a114171978890d..6e6eb9a2f85508b31f0db71cf3d11874462093d2 100755 --- a/create-graph-deps-for-check-list.sh +++ b/create-graph-deps-for-check-list.sh @@ -108,6 +108,8 @@ main() rpm_spec_dependency_analyzer --output ros.dot *.spec + sed -i "/GraphicsMagick_c/d" ros.dot + while read project do sed -i "/$project$/d" ros.dot diff --git a/create-pr-in-gitee.sh b/create-pr-in-gitee.sh new file mode 100755 index 0000000000000000000000000000000000000000..67b0b7196acd35ac433396ce8b48008433bac056 --- /dev/null +++ b/create-pr-in-gitee.sh @@ -0,0 +1,231 @@ +#!/bin/bash + +. base.sh + +act=$1 +GITEE_TOKEN=$2 + +GITEE_URL=git@gitee.com +GITEE_BASE=${OUTPUT}/gitee +GITEE_PUSH_LIST=${GITEE_BASE}/push.list + +prepare() +{ + if [ "$act" == "" -o "$GITEE_TOKEN" == "" ] + then + echo "Usage:" + echo " ./$0 [fork|clone|commit|pr|merge] gitee_token" + echo "" + exit 1 + fi + + if [ ! -f ${ROS_PROJECTS_NAME} ] + then + error_log "Please give the source repo path of ros" + exit 1 + fi + + mkdir -p ${GITEE_BASE} +} + +fork_projects() +{ + while read project + do + echo "start to fork project $project" + grep -q "^${project}$" ${OUTPUT}/.has_forked && continue + echo curl -X POST --header \''Content-Type:application/json;charset=UTF8'\' \'https://gitee.com/api/v5/repos/${GITEE_ORG}/${project}/forks\' -d \''{"access_token":"'${GITEE_TOKEN}'","name":"openEuler_'${project}'","path":"openEuler_'${project}'"}'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post 1>/dev/null 2>&1 + if [ $? -ne 0 ] + then + error_log "fail to fork project $project" + exit 1 + fi + + echo $project >>${OUTPUT}/.has_forked + + done < ${ROS_PROJECTS_NAME} +} + +clone_projects() +{ + info_log "Start to clone projects from $GITEE_URL" + + while read project + do + project=openEuler_${project} + info_log "start clone project ${project}" + + if [ -d ${GITEE_BASE}/${project}/.git ] + then + cd ${GITEE_BASE}/${project} + git pull origin ${ROS_DISTRO} + continue + fi + + cd ${GITEE_BASE} + git clone https://${GITEE_DOMAIN}/will_niutao/${project}.git + if [ $? -ne 0 ] + then + error_log "fail to clone project ${project}" + continue + fi + cd ${project} + git branch -a | grep "/${OPENEULER_DEV_BRANCH}" + if [ $? -eq 0 ] + then + git checkout ${OPENEULER_DEV_BRANCH} + else + error_log "no ros branch ${OPENEULER_DEV_BRANCH}" + echo $project ${OPENEULER_DEV_BRANCH} >> ${OUTPUT}/gitee/no_branch + fi + + git branch -a | grep "/${OPENEULER_SP_BRANCH}" + if [ $? -ne 0 ] + then + error_log "no ros branch ${OPENEULER_SP_BRANCH}" + echo $project ${OPENEULER_SP_BRANCH} >> ${OUTPUT}/gitee/no_branch + fi + git branch -a | grep "/${OPENEULER_NEXT_BRANCH}" + if [ $? -ne 0 ] + then + error_log "no ros branch ${OPENEULER_NEXT_BRANCH}" + echo $project ${OPENEULER_NEXT_BRANCH} >> ${OUTPUT}/gitee/no_branch + fi + + done < ${ROS_PROJECTS_NAME} + + info_log "clone project ok" +} + +commit_projects() +{ + info_log "Start to commit projects from $GITEE_URL" + + rm -f ${GITEE_PUSH_LIST} + + while read project + do + fork_project=openEuler_${project} + info_log "start commit project ${project}" + + cd ${OUTPUT}/gitee/${fork_project} + + rm -rf * + git checkout -- README.md README.en.md + git checkout -- *.yaml 2>/dev/null + cp ${OUTPUT}/repo/${project}/* . + git status | grep -qE "modified:|Untracked|deleted:" + if [ $? -ne 0 ] + then + #info_log "nothing changed of project $project, continue" + continue + fi + #git status + #continue + + git add -A * + git add -u + git status + + git commit -s -m "upload ROS ${ROS_DISTRO} package on `date`" + git push origin ${OPENEULER_DEV_BRANCH}:${OPENEULER_DEV_BRANCH} + if [ $? -ne 0 ] + then + error_log "fail to push project ${project}" + continue + fi + + echo ${fork_project} >> ${GITEE_PUSH_LIST} + + done < ${ROS_PROJECTS_NAME} + + info_log "commit project ok" +} + + +create_pr_projects() +{ + rm -f ${OUTPUT}/.has_create_pr + while read project + do + pkg=`echo $project | sed -s "s#openEuler_##g"` + echo "start to create pr for project $project" + grep -q "^${project}$" ${OUTPUT}/.has_create_pr && continue + echo curl -X POST --header \''Content-Type:application/json;charset=UTF8'\' \'https://gitee.com/api/v5/repos/${GITEE_ORG}/${pkg}/pulls\' -d \''{"access_token":"'${GITEE_TOKEN}'","title":"Upload ROS '${ROS_DISTRO}'","head":"will_niutao:'${OPENEULER_DEV_BRANCH}'","base":"'${OPENEULER_DEV_BRANCH}'"}'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post >${OUTPUT}/.pr + if [ $? -ne 0 ] + then + error_log "fail to fork project $project" + exit 1 + fi + + pr_id=`cat ${OUTPUT}/.pr | sed -s "s#,#\n#g" | grep html_url | grep pulls | awk -F"/pulls/" '{print $2}' | cut -d'"' -f1` + echo curl -X POST --header \''Content-Type:application/json;charset=UTF8'\' \'https://gitee.com/api/v5/repos/${GITEE_ORG}/${pkg}/pulls/${pr_id}/comments\' -d \''{"access_token":"'${GITEE_TOKEN}'","body":"/sync '${OPENEULER_NEXT_BRANCH} ${OPENEULER_SP_BRANCH}'"}'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post >${OUTPUT}/.pr + + + echo $project >>${OUTPUT}/.has_create_pr + + done < ${GITEE_PUSH_LIST} + + info_log "commit project ok" +} + +auto_merge_pr() +{ + while read pkg + do + echo "start to get pr for project $project" + echo curl -X GET --header \''Content-Type:application/json;charset=UTF8'\' \''https://gitee.com/api/v5/repos/'${GITEE_ORG}'/'${pkg}'/pulls?access_token='${GITEE_TOKEN}'&state=open&sort=created&direction=desc&page=1&per_page=20'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post >${OUTPUT}/.pr + if [ $? -ne 0 ] + then + error_log "fail to fork project $project" + exit 1 + fi + + pr_id=`cat ${OUTPUT}/.pr | sed -s "s#,#\n#g" | grep html_url | grep pulls | awk -F"/pulls/" '{print $2}' | cut -d'"' -f1` + for pr in $pr_id + do + echo curl -X POST --header \''Content-Type:application/json;charset=UTF8'\' \'https://gitee.com/api/v5/repos/${GITEE_ORG}/${pkg}/pulls/${pr}/comments\' -d \''{"access_token":"'${GITEE_TOKEN}'","body":"/lgtm"}'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post >${OUTPUT}/.pr + + sleep 5 + + echo curl -X POST --header \''Content-Type:application/json;charset=UTF8'\' \'https://gitee.com/api/v5/repos/${GITEE_ORG}/${pkg}/pulls/${pr}/comments\' -d \''{"access_token":"'${GITEE_TOKEN}'","body":"/approve"}'\' >${OUTPUT}/.post + bash ${OUTPUT}/.post >${OUTPUT}/.pr + done + done < ${GITEE_PUSH_LIST} + + info_log "merge project ok" +} + +main() +{ + prepare + + case $act in + "fork") + fork_projects + ;; + "clone") + clone_projects + ;; + "commit") + commit_projects + ;; + "pr") + create_pr_projects + ;; + "merge") + auto_merge_pr + ;; + *) + echo "Usage:" + echo " ./$0 [fork|clone|commit|pr|merge] gitee_token" + echo "" + ;; + esac +} +main $* diff --git a/create-release-management.sh b/create-release-management.sh new file mode 100755 index 0000000000000000000000000000000000000000..bf8c416bcfa8a6f3bcba09cfef4f8874c536232c --- /dev/null +++ b/create-release-management.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +. base.sh + +PCKG_MGMT=${OUTPUT}/pckg-mgmt.yaml +EPOL_LIST=${OUTPUT}/epol.list +ROS_OBS_FROM=openEuler:22.03:LTS:Next:Epol:Multi-Version:ROS:humble +ROS_OBS_TO=openEuler:22.03:LTS:SP2:Epol:Multi-Version:ROS:humble +ROS_DEP_OBS_FROM=openEuler:22.03:LTS:Next:Epol +ROS_DEP_OBS_TO=openEuler:22.03:LTS:SP2:Epol + +prepare() +{ + if [ ! -f ${EPOL_LIST} ] + then + error_log "Please give the source repo path of ros" + exit 1 + fi + + >${PCKG_MGMT} +} + +main() +{ + prepare + + info_log "Start to analyse ros-pkg." + + while read repo + do + info_log "start create project $repo" + + grep -q "^${repo}$" ${ROS_PROJECTS_NAME} + if [ $? -eq 0 ] + then + obs_from=${ROS_OBS_FROM} + obs_to=${ROS_OBS_TO} + source_dir=${OPENEULER_NEXT_BRANCH} + destination_dir=${OPENEULER_SP_BRANCH} + else + obs_from=${ROS_DEP_OBS_FROM} + obs_to=${ROS_DEP_OBS_TO} + source_dir=${OPENEULER_ROS_DEP_NEXT_BRANCH} + destination_dir=${OPENEULER_ROS_DEP_PKG_BRANCH} + fi + echo '- name: '$repo >> ${PCKG_MGMT} + echo ' source_dir: '${source_dir} >> ${PCKG_MGMT} + echo ' destination_dir: '${destination_dir} >> ${PCKG_MGMT} + echo ' obs_from: '${obs_from} >> ${PCKG_MGMT} + echo ' obs_to: '${obs_to} >> ${PCKG_MGMT} + echo ' date: '\'`date +%Y-%m-%d`\' >> ${PCKG_MGMT} + done < ${EPOL_LIST} + + info_log "create project ok" +} + +main $* diff --git a/download-obs-projects.sh b/download-obs-projects.sh new file mode 100755 index 0000000000000000000000000000000000000000..41a152ec3724f97a5183ca9c0047fe48dc8337c3 --- /dev/null +++ b/download-obs-projects.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +. base.sh + +USER_INFO="$1" +OBS_PACKAGES_LIST=${OUTPUT}/obs-packages.list +OBS_BASE=${OUTPUT}/obs + +prepare() +{ + if [ "$USER_INFO" == "" ] + then + echo "Usage:" + echo " ./$0 user:pass" + echo "" + exit 1 + fi + + mkdir -p ${OBS_BASE} +} + +main() +{ + prepare + + info_log "Start to download obs projects." + cd ${OBS_BASE} + osc list /${OBS_PROJECT} >${OBS_PACKAGES_LIST} + + while read pkg + do + info_log "start checkout package $pkg" + osc co ${OBS_PROJECT}/$pkg + [ $? -ne 0 ] && log_error "Checkout package $pkg error" + done < ${OBS_PACKAGES_LIST} + + info_log "get status of projects ok" +} + +main $* diff --git a/gen-pkg-ext-bb.sh b/gen-pkg-ext-bb.sh index 3491842707249f4446e95ab2c5b88c368fc84d7c..f7f2aefef11060b4cf2e012b2a3c09e7dca63d0e 100755 --- a/gen-pkg-ext-bb.sh +++ b/gen-pkg-ext-bb.sh @@ -4,7 +4,7 @@ GEN_ONE=$1 -SPEC_TO_BB_LIST=${ROS_DISTRO}/spec_to_bb.list +SPEC_TO_BB_LIST=${ROOT}/ros/${ROS_DISTRO}/spec_to_bb.list BB_FIX=${ROOT}/bb_fix BB_FIX_PKG_REMAP=${BB_FIX}/pkg.remap BB_DEVTOOLS_BASE=${ROS_BB_BASE}/recipes-devtools diff --git a/gen-pkg-spec.sh b/gen-pkg-spec.sh index dc94ed959eab145c2f2e3a0b5a58d96f6fd8485d..83e9d1129f4c5b8df552e3656cb9961b1f603d30 100755 --- a/gen-pkg-spec.sh +++ b/gen-pkg-spec.sh @@ -200,8 +200,8 @@ modify_spec() debug_log "gen changelog" maintainer=`grep maintainer: ${ROS_DEPS_BASE}/$pkg-PackageXml | awk -F"maintainer:" '{print $2}'` - #changetime=`date +"%a %b %d %Y"` - changetime="Thu May 04 2023" + changetime=`date +"%a %b %d %Y"` + #changetime="Thu May 04 2023" changelog="$changetime $maintainer - $base_version-$release_version" sed -i "s#ROS_PACKAGE_CHANGELOG#$changelog#g" $spec diff --git a/get-epol.sh b/get-epol.sh new file mode 100755 index 0000000000000000000000000000000000000000..29ce093e844d914a45622d3dd9d0429f6a3b624b --- /dev/null +++ b/get-epol.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +. base.sh + +GEN_ONE=$1 + +ROS_CAN_INSTALLED_LIST=${OUTPUT}/ros-can-installed.list +ROS_PKG_LIST=${OUTPUT}/ros-pkg.list +ROS_EPOL_LIST=${OUTPUT}/epol.list +ROS_PACKAGES_LIST=${OUTPUT}/packages.list + +prepare() +{ + if [ ! -f ${ROS_CAN_INSTALLED_LIST} -o ! -f ${ROS_PKG_LIST} ] + then + error_log "Can not find ${ROS_PKG_SRC}, you can use get-repo-src.sh to create it" + exit 1 + fi + + rm -f ${ROS_EPOL_LIST} ${ROS_PACKAGES_LIST} ${OUTPUT}/.epol.list +} + +main() +{ + prepare + + info_log "Start to analyse ros-pkg." + + while read pkg repo version + do + grep -qP "ros-${ROS_DISTRO}-${pkg}$" ${ROS_CAN_INSTALLED_LIST} && echo $repo >> ${OUTPUT}/.epol.list + done < ${ROS_PKG_LIST} + + cat ${OUTPUT}/.epol.list | sort | uniq >${ROS_EPOL_LIST} + cat ${ROS_CAN_INSTALLED_LIST} | sort >${ROS_PACKAGES_LIST} + + info_log "Gen ros-pkg-src.list done, you can find it in ${ROS_PKG_SRC}" +} + +main $* diff --git a/get-repo-list.sh b/get-repo-list.sh index 56774a54b566c4cee9ed2d6da9f479753e4060f3..35b58c5848bd152f3e5a088cf53ee7bc49aaffb7 100755 --- a/get-repo-list.sh +++ b/get-repo-list.sh @@ -2,8 +2,8 @@ . base.sh -ROS_PROJECTS_LIST=${ROOT}/${ROS_DISTRO}/ros-projects.list -ROS_VERSION_FIX=${ROOT}/${ROS_DISTRO}/ros-version-fix +ROS_PROJECTS_LIST=${ROOT}/ros/${ROS_DISTRO}/ros-projects.list +ROS_VERSION_FIX=${ROOT}/ros/${ROS_DISTRO}/ros-version-fix ROS_REPOS=${OUTPUT}/ros.repos ROS_REPOS_URL=${OUTPUT}/ros.url diff --git a/package_fix/yaml-cpp-vendor/00-yaml-cpp-vendor-fix-eulermaker-x86-build-error.patch b/package_fix/yaml-cpp-vendor/00-yaml-cpp-vendor-fix-eulermaker-x86-build-error.patch new file mode 100644 index 0000000000000000000000000000000000000000..7b2a96f0778c83d55bdba8ccf1b6da7d9c98d0eb --- /dev/null +++ b/package_fix/yaml-cpp-vendor/00-yaml-cpp-vendor-fix-eulermaker-x86-build-error.patch @@ -0,0 +1,14 @@ +diff -Naur ros-humble-yaml-cpp-vendor-8.0.2_org/yaml_cpp_vendor-extras.cmake.in ros-humble-yaml-cpp-vendor-8.0.2/yaml_cpp_vendor-extras.cmake.in +--- ros-humble-yaml-cpp-vendor-8.0.2_org/yaml_cpp_vendor-extras.cmake.in 2023-06-10 14:17:04.259752071 +0800 ++++ ros-humble-yaml-cpp-vendor-8.0.2/yaml_cpp_vendor-extras.cmake.in 2023-06-10 14:17:28.876907884 +0800 +@@ -12,6 +12,10 @@ + find_package(yaml-cpp CONFIG REQUIRED QUIET) + endif() + ++set_target_properties(yaml-cpp PROPERTIES ++ IMPORTED_LOCATION_RELEASE "/usr/lib64/libyaml-cpp.so.${yaml-cpp_VERSION}" ++) ++ + set(yaml_cpp_vendor_LIBRARIES ${YAML_CPP_LIBRARIES}) + set(yaml_cpp_vendor_INCLUDE_DIRS ${YAML_CPP_INCLUDE_DIR}) + diff --git a/package_fix/yaml-cpp-vendor/source.fix b/package_fix/yaml-cpp-vendor/source.fix new file mode 100644 index 0000000000000000000000000000000000000000..e7fa45499ea28b602541bcc3a4c7d18426104347 --- /dev/null +++ b/package_fix/yaml-cpp-vendor/source.fix @@ -0,0 +1,2 @@ + +Patch0: 00-yaml-cpp-vendor-fix-eulermaker-x86-build-error.patch diff --git a/humble/ros-projects-third.list b/ros/humble/ros-projects-third.list similarity index 100% rename from humble/ros-projects-third.list rename to ros/humble/ros-projects-third.list diff --git a/humble/ros-projects.list b/ros/humble/ros-projects.list similarity index 100% rename from humble/ros-projects.list rename to ros/humble/ros-projects.list diff --git a/humble/ros-version-fix b/ros/humble/ros-version-fix similarity index 100% rename from humble/ros-version-fix rename to ros/humble/ros-version-fix diff --git a/humble/spec_to_bb.list b/ros/humble/spec_to_bb.list similarity index 44% rename from humble/spec_to_bb.list rename to ros/humble/spec_to_bb.list index 5fe6fba68ae3dc0841e3e932b9269751f89bd387..496b9df801f915bdf1af2e4ac0a0b2b9276cca1f 100644 --- a/humble/spec_to_bb.list +++ b/ros/humble/spec_to_bb.list @@ -1,37 +1,37 @@ #package_name package_type is_native bbfile_name spec_url source_name unpack_name -python3-importlib-resources python yes python3-importlib-resources https://gitee.com/src-openeuler/python-importlib-resources/raw/openEuler-22.03-LTS-SP1/python-importlib-resources.spec importlib_resources-5.4.0.tar.gz importlib_resources-5.4.0 -python3-catkin_pkg python yes python3-catkin-pkg https://gitee.com/will_niutao/catkin_pkg/raw/master/catkin-pkg.spec 0.5.2.tar.gz catkin_pkg-0.5.2 -python3-sphinx python no python3-sphinx https://gitee.com/src-openeuler/python-sphinx/raw/openEuler-22.03-LTS-SP1/python-sphinx.spec Sphinx-4.4.0.tar.gz Sphinx-4.4.0 -python3-docutils python yes python3-docutils https://gitee.com/src-openeuler/python-docutils/raw/openEuler-22.03-LTS-SP1/python-docutils.spec docutils-0.17.1.tar.gz docutils-0.17.1 -python3-flake8 python yes python3-flake8 https://gitee.com/src-openeuler/python-flake8/raw/openEuler-22.03-LTS-SP1/python-flake8.spec flake8-3.9.2.tar.gz flake8-3.9.2 -python3-mock python yes python3-mock https://gitee.com/src-openeuler/python-mock/raw/openEuler-22.03-LTS-SP1/python-mock.spec mock-4.0.3.tar.gz mock-4.0.3 -#python3-mccabe python yes python3-mccabe https://gitee.com/src-openeuler/python-mccabe/raw/openEuler-22.03-LTS-SP1/python-mccabe.spec mccabe-0.6.1.tar.gz mccabe-0.6.1 -python3-empy python yes python3-empy https://gitee.com/will_niutao/python-empy/raw/master/python-empy.spec empy-3.3.4.tar.gz empy-3.3.4 -gtest cmake yes gtest https://gitee.com/src-openeuler/gtest/raw/openEuler-22.03-LTS-SP1/gtest.spec release-1.8.1.tar.gz googletest-release-1.8.1 -#python3-yaml python yes python3-yaml https://gitee.com/src-openeuler/PyYAML/raw/openEuler-22.03-LTS-SP1/PyYAML.spec PyYAML-6.0.tar.gz PyYAML-6.0 -console-bridge cmake yes console-bridge https://gitee.com/will_niutao/console_bridge/raw/master/console_bridge.spec 1.0.2.tar.gz console_bridge-1.0.2 -yaml-cpp cmake yes yaml-cpp https://gitee.com/src-openeuler/yaml-cpp/raw/openEuler-22.03-LTS-SP1/yaml-cpp.spec yaml-cpp-0.6.3.tar.gz yaml-cpp-yaml-cpp-0.6.3 -python3-lark-parser python yes python3-lark-parser https://gitee.com/src-openeuler/python-lark-parser/raw/master/python-lark-parser.spec lark-parser-0.12.0.tar.gz lark-parser-0.12.0 -python3-netifaces python yes python3-netifaces https://gitee.com/src-openeuler/python-netifaces/raw/openEuler-22.03-LTS-SP1/python-netifaces.spec netifaces-0.11.0.tar.gz netifaces-0.11.0 -pybind11 cmake yes pybind11 https://gitee.com/src-openeuler/pybind11/raw/openEuler-22.03-LTS-SP1/pybind11.spec v2.8.1.tar.gz pybind11-2.8.1 -tinyxml2 cmake yes tinyxml2 https://gitee.com/src-openeuler/tinyxml2/raw/openEuler-22.03-LTS-SP1/tinyxml2.spec tinyxml2-6.0.0-8c8293b.tar.gz tinyxml2-8c8293ba8969a46947606a93ff0cb5a083aab47a -python3-rosdistro python yes python3-rosdistro https://gitee.com/will_niutao/python-rosdistro/raw/master/python-rosdistro.spec 0.9.0.tar.gz rosdistro-0.9.0 -python3-rospkg python yes python3-rospkg https://gitee.com/will_niutao/python-rospkg/raw/master/python-rospkg.spec 1.5.0.tar.gz rospkg-1.5.0 -python3-catkin-sphinx python yes python3-catkin-sphinx https://gitee.com/will_niutao/python-catkin-sphinx/raw/master/python-catkin-sphinx.spec 0.3.2.tar.gz catkin-sphinx-0.3.2 -cppcheck cmake yes cppcheck https://gitee.com/src-openeuler/cppcheck/raw/openEuler-22.03-LTS-SP1/cppcheck.spec 2.6.3.tar.gz cppcheck-2.6.3 -python3-pydocstyle python yes python3-pydocstyle https://gitee.com/src-openeuler/python-pydocstyle/raw/openEuler-22.03-LTS-SP1/python-pydocstyle.spec 6.1.1.tar.gz pydocstyle-6.1.1 -#acl cmake yes acl https://gitee.com/src-openeuler/acl/raw/openEuler-22.03-LTS-SP1/acl.spec acl-2.3.1.tar.gz acl-2.3.1 -#eigen3 cmake no eigen3 https://gitee.com/will_niutao/eigen/raw/master/eigen3.spec eigen-3.3.8.tar.bz2 eigen-3.3.8 -pcl cmake no pcl https://gitee.com/will_niutao/pcl/raw/master/pcl.spec pcl-1.12.1.tar.gz pcl-pcl-1.12.1 -flann cmake no flann https://gitee.com/will_niutao/flann/raw/master/flann.spec 1.9.2.tar.gz flann-1.9.2 -qhull cmake no qhull https://gitee.com/src-openeuler/qhull/raw/openEuler-22.03-LTS-SP1/qhull.spec qhull-2015-src-7.2.0.tgz qhull-2015.2 +python3-importlib-resources python yes python3-importlib-resources https://gitee.com/src-openeuler/python-importlib-resources/raw/openEuler-22.03-LTS-SP2/python-importlib-resources.spec importlib_resources-5.4.0.tar.gz importlib_resources-5.4.0 +python3-catkin_pkg python yes python3-catkin-pkg https://gitee.com/src-openeuler/python-catkin_pkg/raw/openEuler-22.03-LTS-SP2/catkin-pkg.spec 0.5.2.tar.gz catkin_pkg-0.5.2 +python3-sphinx python no python3-sphinx https://gitee.com/src-openeuler/python-sphinx/raw/openEuler-22.03-LTS-SP2/python-sphinx.spec Sphinx-4.4.0.tar.gz Sphinx-4.4.0 +python3-docutils python yes python3-docutils https://gitee.com/src-openeuler/python-docutils/raw/openEuler-22.03-LTS-SP2/python-docutils.spec docutils-0.17.1.tar.gz docutils-0.17.1 +python3-flake8 python yes python3-flake8 https://gitee.com/src-openeuler/python-flake8/raw/openEuler-22.03-LTS-SP2/python-flake8.spec flake8-3.9.2.tar.gz flake8-3.9.2 +python3-mock python yes python3-mock https://gitee.com/src-openeuler/python-mock/raw/openEuler-22.03-LTS-SP2/python-mock.spec mock-4.0.3.tar.gz mock-4.0.3 +#python3-mccabe python yes python3-mccabe https://gitee.com/src-openeuler/python-mccabe/raw/openEuler-22.03-LTS-SP2/python-mccabe.spec mccabe-0.6.1.tar.gz mccabe-0.6.1 +python3-empy python yes python3-empy https://gitee.com/src-openeuler/python-empy/raw/openEuler-22.03-LTS-SP2/python-empy.spec empy-3.3.4.tar.gz empy-3.3.4 +gtest cmake yes gtest https://gitee.com/src-openeuler/gtest/raw/openEuler-22.03-LTS-SP2/gtest.spec release-1.8.1.tar.gz googletest-release-1.8.1 +#python3-yaml python yes python3-yaml https://gitee.com/src-openeuler/PyYAML/raw/openEuler-22.03-LTS-SP2/PyYAML.spec PyYAML-6.0.tar.gz PyYAML-6.0 +console-bridge cmake yes console-bridge https://gitee.com/src-openeuler/console_bridge/raw/openEuler-22.03-LTS-SP2/console_bridge.spec 1.0.2.tar.gz console_bridge-1.0.2 +yaml-cpp cmake yes yaml-cpp https://gitee.com/src-openeuler/yaml-cpp/raw/openEuler-22.03-LTS-SP2/yaml-cpp.spec yaml-cpp-0.6.3.tar.gz yaml-cpp-yaml-cpp-0.6.3 +python3-lark-parser python yes python3-lark-parser https://gitee.com/src-openeuler/python-lark-parser/raw/openEuler-22.03-LTS-SP2/python-lark-parser.spec lark-parser-0.12.0.tar.gz lark-parser-0.12.0 +python3-netifaces python yes python3-netifaces https://gitee.com/src-openeuler/python-netifaces/raw/openEuler-22.03-LTS-SP2/python-netifaces.spec netifaces-0.11.0.tar.gz netifaces-0.11.0 +pybind11 cmake yes pybind11 https://gitee.com/src-openeuler/pybind11/raw/openEuler-22.03-LTS-SP2/pybind11.spec v2.8.1.tar.gz pybind11-2.8.1 +tinyxml2 cmake yes tinyxml2 https://gitee.com/src-openeuler/tinyxml2/raw/openEuler-22.03-LTS-SP2/tinyxml2.spec tinyxml2-6.0.0-8c8293b.tar.gz tinyxml2-8c8293ba8969a46947606a93ff0cb5a083aab47a +python3-rosdistro python yes python3-rosdistro https://gitee.com/src-openeuler/python-rosdistro/raw/openEuler-22.03-LTS-SP2/python-rosdistro.spec 0.9.0.tar.gz rosdistro-0.9.0 +python3-rospkg python yes python3-rospkg https://gitee.com/src-openeuler/python-rospkg/raw/openEuler-22.03-LTS-SP2/python-rospkg.spec 1.5.0.tar.gz rospkg-1.5.0 +python3-catkin-sphinx python yes python3-catkin-sphinx https://gitee.com/src-openeuler/python-catkin-sphinx/raw/openEuler-22.03-LTS-SP2/python-catkin-sphinx.spec catkin-sphinx-0.3.2.tar.gz catkin-sphinx-0.3.2 +cppcheck cmake yes cppcheck https://gitee.com/src-openeuler/cppcheck/raw/openEuler-22.03-LTS-SP2/cppcheck.spec 2.6.3.tar.gz cppcheck-2.6.3 +python3-pydocstyle python yes python3-pydocstyle https://gitee.com/src-openeuler/python-pydocstyle/raw/openEuler-22.03-LTS-SP2/python-pydocstyle.spec 6.1.1.tar.gz pydocstyle-6.1.1 +#acl cmake yes acl https://gitee.com/src-openeuler/acl/raw/openEuler-22.03-LTS-SP2/acl.spec acl-2.3.1.tar.gz acl-2.3.1 +#eigen3 cmake no eigen3 https://gitee.com/src-openeuler/eigen/raw/openEuler-22.03-LTS-SP2/eigen3.spec eigen-3.3.8.tar.bz2 eigen-3.3.8 +pcl cmake no pcl https://gitee.com/src-openeuler/pcl/raw/openEuler-22.03-LTS-SP2/pcl.spec pcl-1.12.1.tar.gz pcl-pcl-1.12.1 +flann cmake no flann https://gitee.com/src-openeuler/flann/raw/openEuler-22.03-LTS-SP2/flann.spec 1.9.2.tar.gz flann-1.9.2 +qhull cmake no qhull https://gitee.com/src-openeuler/qhull/raw/openEuler-22.03-LTS-SP2/qhull.spec qhull-2015-src-7.2.0.tgz qhull-2015.2 tinyxml cmake no tinyxml https://gitee.com/src-openeuler/tinyxml/raw/openEuler-22.03-LTS-SP2/tinyxml.spec tinyxml_2_6_2.tar.gz tinyxml -orocos-kdl cmake no orocos-kdl https://gitee.com/src-openeuler/orocos_kdl/raw/master/orocos-kdl.spec v1.5.1.tar.gz orocos_kinematics_dynamics-1.5.1 -graphicsmagick cmake no graphicsmagick https://gitee.com/src-openeuler/GraphicsMagick/raw/openEuler-22.03-LTS-SP1/GraphicsMagick.spec GraphicsMagick-1.3.30.tar.xz GraphicsMagick-1.3.30 -cppzmq cmake no cppzmq https://gitee.com/will_niutao/cppzmq/raw/master/cppzmq.spec v4.9.0.tar.gz cppzmq-4.9.0 -zeromq cmake no zeromq https://gitee.com/src-openeuler/zeromq/raw/openEuler-22.03-LTS-SP1/zeromq.spec libzmq-4.3.4.tar.gz libzmq-4.3.4 -catch2 cmake no catch2 https://gitee.com/will_niutao/catch2/raw/master/catch2.spec v3.3.2.tar.gz Catch2-3.3.2 -suitesparse cmake no suitesparse https://gitee.com/src-openeuler/suitesparse/raw/openEuler-22.03-LTS-SP1/suitesparse.spec SuiteSparse-5.10.1.tar.gz SuiteSparse-5.10.1 -ydlidar-sdk cmake no ydlidar-sdk https://gitee.com/will_niutao/ydlidar-sdk/raw/master/ydlidar-sdk.spec V1.1.3.tar.gz YDLidar-SDK-1.1.3 -metis cmake no metis https://gitee.com/src-openeuler/metis/raw/openEuler-22.03-LTS-SP1/metis.spec metis-5.1.0.tar.gz metis-5.1.0 -ceres-solver cmake no ceres-solver https://gitee.com/src-openeuler/ceres-solver/raw/master/ceres-solver.spec ceres-solver-2.0.0.tar.gz ceres-solver-2.0.0 +orocos-kdl cmake no orocos-kdl https://gitee.com/src-openeuler/orocos_kdl/raw/openEuler-22.03-LTS-SP2/orocos-kdl.spec v1.5.1.tar.gz orocos_kinematics_dynamics-1.5.1 +graphicsmagick cmake no graphicsmagick https://gitee.com/src-openeuler/GraphicsMagick/raw/openEuler-22.03-LTS-SP2/GraphicsMagick.spec GraphicsMagick-1.3.30.tar.xz GraphicsMagick-1.3.30 +cppzmq cmake no cppzmq https://gitee.com/src-openeuler/cppzmq/raw/openEuler-22.03-LTS-SP2/cppzmq.spec v4.9.0.tar.gz cppzmq-4.9.0 +zeromq cmake no zeromq https://gitee.com/src-openeuler/zeromq/raw/openEuler-22.03-LTS-SP2/zeromq.spec libzmq-4.3.4.tar.gz libzmq-4.3.4 +catch2 cmake no catch2 https://gitee.com/src-openeuler/Catch2/raw/openEuler-22.03-LTS-SP2/catch2.spec v3.3.2.tar.gz Catch2-3.3.2 +suitesparse cmake no suitesparse https://gitee.com/src-openeuler/suitesparse/raw/openEuler-22.03-LTS-SP2/suitesparse.spec SuiteSparse-5.10.1.tar.gz SuiteSparse-5.10.1 +ydlidar-sdk cmake no ydlidar-sdk https://gitee.com/src-openeuler/ydlidar-sdk/raw/openEuler-22.03-LTS-SP2/ydlidar-sdk.spec V1.1.3.tar.gz YDLidar-SDK-1.1.3 +metis cmake no metis https://gitee.com/src-openeuler/metis/raw/openEuler-22.03-LTS-SP2/metis.spec metis-5.1.0.tar.gz metis-5.1.0 +ceres-solver cmake no ceres-solver https://gitee.com/src-openeuler/ceres-solver/raw/openEuler-22.03-LTS-SP2/ceres-solver.spec ceres-solver-2.0.0.tar.gz ceres-solver-2.0.0 diff --git a/spec_fix/pkg.remap b/spec_fix/pkg.remap index 775c118e29d3ae65508d5508b9712e2e805c5f36..c9377655c6a60d0dc51224f5f9d9dc06584493e7 100644 --- a/spec_fix/pkg.remap +++ b/spec_fix/pkg.remap @@ -108,3 +108,5 @@ python3-pil python3-pillow libomp-dev libomp-devel libglew-dev glew-devel glut freeglut +python3-nose python3-nose2 +python3-collada python3-pycollada diff --git a/template/cmake-ubuntu.spec b/template/cmake-ubuntu.spec index 877de1bc1cf748714a55663e993220fcb4922f74..76689d4c0260094cf1b6e7749d9ce025f960f677 100644 --- a/template/cmake-ubuntu.spec +++ b/template/cmake-ubuntu.spec @@ -61,6 +61,7 @@ mkdir -p .obj-%{_target_platform} && cd .obj-%{_target_platform} -DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \ -DAMENT_PREFIX_PATH="/opt/ros/%{ros_distro}" \ -DCMAKE_PREFIX_PATH="/opt/ros/%{ros_distro}" \ + -DCMAKE_INSTALL_LIBDIR="/opt/ros/%{ros_distro}/lib" \ -DSETUPTOOLS_DEB_LAYOUT=OFF \ %if !0%{?with_tests} -DBUILD_TESTING=OFF \ diff --git a/template/project.json b/template/project.json new file mode 100644 index 0000000000000000000000000000000000000000..f8e8f9dccee60cc637a7de175f783c4f84531616 --- /dev/null +++ b/template/project.json @@ -0,0 +1,39 @@ +{ + "os_project": "openEuler_22.03_LTS_SP2_Epol_Multi-Version_ROS_humble_test", + "owner": "niutao", + "lock": false, + "to_delete": false, + "users": { + "niutao": "maintainer" + }, + "create_time": "2023-06-08T11:38:51.220+0800", + "spec_branch": "Multi-Version_ros-humble_openEuler-22.03-LTS-SP2", + "build_targets": [ + { + "os_variant": "openEuler:22.03-LTS-SP2", + "architecture": "aarch64", + "ground_projects": [ + "openEuler-22.03-LTS-SP2:epol", + "openEuler-22.03-LTS-SP2:everything" + ], + "flags": { + "build": true, + "publish": true + } + }, + { + "os_variant": "openEuler:22.03-LTS-SP2", + "architecture": "x86_64", + "ground_projects": [ + "openEuler-22.03-LTS-SP2:epol", + "openEuler-22.03-LTS-SP2:everything" + ], + "flags": { + "build": true, + "publish": true + } + } + ], + "description": "", + "my_specs": [ +