Skip to content

Commit

Permalink
增加适配GS系列TCP通讯方式
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanyiaini committed May 23, 2023
1 parent cefbe59 commit 7a12bc6
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 900 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 11)
set(YDLIDAR_SDK_VERSION_PATCH 12)
set(YDLIDAR_SDK_VERSION ${YDLIDAR_SDK_VERSION_MAJOR}.${YDLIDAR_SDK_VERSION_MINOR}.${YDLIDAR_SDK_VERSION_PATCH})

##########################################################
Expand Down
20 changes: 5 additions & 15 deletions core/common/DriverInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class DriverInterface {
* @see DriverInterface::setLidarType and DriverInterface::getLidarType
*/
PropertyBuilderByName(int, LidarType, protected);
//设备类型(串口或网络)
PropertyBuilderByName(uint8_t, DeviceType, protected);
/**
* @brief Set and Get Sampling interval.
* @note Negative correlation between sampling interval and lidar sampling rate.\n
Expand Down Expand Up @@ -82,25 +84,11 @@ class DriverInterface {
*/
PropertyBuilderByName(bool, SupportMotorDtrCtrl, protected);

/**
* @brief Set and Get LiDAR HeartBeat function.
* @note The current paramter settings are only valid
* if the LiDAR is BigScreen.\n
* Set the LiDAR HeartBeat to match the LiDAR.
* @remarks
<table>
<tr><th>G4/G4PRO <td>false
</table>
* @see DriverInterface::setHeartBeat and DriverInterface::getHeartBeat
*/
PropertyBuilderByName(bool, HeartBeat, protected);

//是否开启调试
PropertyBuilderByName(bool, Debug, protected);

//扫描频率
PropertyBuilderByName(float, ScanFreq, protected);

//是否底板优先
PropertyBuilderByName(bool, Bottom, protected);
//是否已获取到设备信息
Expand All @@ -110,7 +98,8 @@ class DriverInterface {
* @par Constructor
*
*/
DriverInterface() : serial_port(""),
DriverInterface() :
serial_port(""),
m_baudrate(8000),
m_intensities(false),
m_intensityBit(10),
Expand All @@ -122,6 +111,7 @@ class DriverInterface {
isAutoconnting(false) {
m_SingleChannel = false;
m_LidarType = TYPE_TRIANGLE;
m_DeviceType = YDLIDAR_TYPE_SERIAL;
m_PointTime = 0;
m_SupportMotorDtrCtrl = true;
m_HeartBeat = false;
Expand Down
5 changes: 4 additions & 1 deletion samples/gs_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ int main(int argc, char *argv[])
std::map<std::string, std::string> ports = ydlidar::lidarPortList();
std::map<std::string, std::string>::iterator it;

ports["IP1"] = "192.168.1.200";

if (ports.size() == 1) {
port = ports.begin()->second;
} else {
Expand Down Expand Up @@ -115,6 +117,7 @@ int main(int argc, char *argv[])
int baudrate = 921600;
std::map<int, int> baudrateList;
baudrateList[0] = 921600;
baudrateList[1] = 8000; //网络端口
printf("Baudrate:\n");
for (std::map<int, int>::iterator it = baudrateList.begin();
it != baudrateList.end(); it++) {
Expand Down Expand Up @@ -158,7 +161,7 @@ int main(int argc, char *argv[])
int optval = TYPE_GS;
laser.setlidaropt(LidarPropLidarType, &optval, sizeof(int));
/// device type
optval = YDLIDAR_TYPE_SERIAL;
optval = YDLIDAR_TYPE_TCP; //YDLIDAR_TYPE_TCP YDLIDAR_TYPE_SERIAL
laser.setlidaropt(LidarPropDeviceType, &optval, sizeof(int));
/// sample rate
optval = isSingleChannel ? 3 : 4;
Expand Down
2 changes: 1 addition & 1 deletion src/CYdLidar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@ bool CYdLidar::checkCOMMs()
if (isNetTOFLidar(m_LidarType))
lidarPtr = new ydlidar::ETLidarDriver(); //T15
else if (isGS2Lidar(m_LidarType)) //GS2
lidarPtr = new ydlidar::GSLidarDriver();
lidarPtr = new ydlidar::GSLidarDriver(m_DeviceType);
else if (isSDMLidar(m_LidarType)) //SDM
lidarPtr = new ydlidar::SDMLidarDriver();
else //通用雷达
Expand Down
Loading

0 comments on commit 7a12bc6

Please sign in to comment.