• 大小: 434KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-17
  • 语言: 其他
  • 标签: ros  

资源简介

ros机器人代码,激光雷达导航系统,slam

资源截图

代码片段和文件信息

/*
*  3iRoboticsLIDAR System II
*  Driver Interface
*
*  Copyright 2017 3iRobotics
*  All rights reserved.
*
* Author: 3iRobotics Data:2017-09-15
*
*/


#include “C3iroboticsLidar.h“
#include “CSerialConnection.h“

#define DEG2RAD(x) ((x)*M_PI/180.)


typedef struct _rslidar_data
{
    _rslidar_data()
    {
        signal = 0;
        angle = 0.0;
        distance = 0.0;
    }
    uint8_t signal;
    float   angle;
    float   distance;
}RslidarDataComplete;

using namespace std;
using namespace everest::hwdrivers;


int main(int argc char * argv[])
{
int    opt_com_baudrate = 230400;
    string opt_com_path = “/dev/ttyUSB0“;

    CSerialConnection serial_connect;
    C3iroboticsLidar robotics_lidar;

    serial_connect.setBaud(opt_com_baudrate);
    serial_connect.setPort(opt_com_path.c_str());
    if(serial_connect.openSimple())
    {
        printf(“[AuxCtrl] Open serail port sucessful!\n“);
        printf(“baud rate:%d\n“serial_connect.getBaud());
    }
    else
    {
        printf(“[AuxCtrl] Open serail port %s failed! \n“ opt_com_path.c_str());
        return -1;
    }

    printf(“C3iroboticslidar connected\n“);

    robotics_lidar.initilize(&serial_connect);


    while (1)
    {
TLidarGrabResult result = robotics_lidar.getScanData();
        switch(result)
        {
            case LIDAR_GRAB_ING:
            {
                break;
            }
            case LIDAR_GRAB_SUCESS:
            {
                TLidarScan lidar_scan = robotics_lidar.getLidarScan();
                size_t lidar_scan_size = lidar_scan.getSize();
                std::vector send_lidar_scan_data;
                send_lidar_scan_data.resize(lidar_scan_size);
                RslidarDataComplete one_lidar_data;
                for(size_t i = 0; i < lidar_scan_size; i++)
                {
                    one_lidar_data.signal = lidar_scan.signal[i];
                    one_lidar_data.angle = lidar_scan.angle[i];
                    one_lidar_data.distance = lidar_scan.distance[i];
                    send_lidar_scan_data[i] = one_lidar_data;
                }

                printf(“Lidar count %d!\n“ lidar_scan_size);


                break;
            }
            case LIDAR_GRAB_ERRO:
            {
                break;
            }
            case LIDAR_GRAB_ELSE:
            {
                printf(“[Main] LIDAR_GRAB_ELSE!\n“);
                break;
            }
        }
        //usleep(50);
    }

    return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-12-06 02:18  Delta_2B_linux\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\
     文件       45508  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\CMakeOutput.log
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdC\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdC\tmp\
     文件       18076  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdC\CMakeCCompilerId.c
     文件        8400  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdC\a.out
     文件         402  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CMakeSystem.cmake
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdCXX\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdCXX\tmp\
     文件       17631  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdCXX\CMakeCXXCompilerId.cpp
     文件        8408  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CompilerIdCXX\a.out
     文件        2219  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CMakeCCompiler.cmake
     文件        4849  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CMakeCXXCompiler.cmake
     文件        8240  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CMakeDetermineCompilerABI_C.bin
     文件        8256  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\3.10.2\CMakeDetermineCompilerABI_CXX.bin
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\CMakeTmp\
     文件         688  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\feature_tests.c
     文件       10011  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\feature_tests.cxx
     文件          85  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\cmake.check_cache
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\
     文件       29394  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\build.make
     文件         276  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\flags.make
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\app\
     文件       82480  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\app\node.cpp.o
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\src\
     目录           0  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\src\src\
     文件      188072  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\src\src\C3iroboticsLidar.cpp.o
     文件        1640  2018-12-06 02:18  Delta_2B_linux\build\CMakeFiles\delta_2b_lidar_node.dir\src\src\CArcTime.cpp.o
............此处省略57个文件信息

评论

共有 条评论