写在前面
用以前的设置,快速配置项目,以防长久不用忘记,部分资料在资源文件里还没有整理
outline
- cmakelist 复用
- vscode 找到头文件
- vscode debug
- 现有代码直接关联远端git
- ros杂记
- repo 杂记
- glog杂记
cmakelist 复用
包含了根据系统路径找库,debug,主动set库路径,单元测试用,和常用的加入头文件与源文件
cmake_minimum_required(VERSION 3.14.1)
project(project_osqp)
set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( THREADS_PREFER_PTHREAD_FLAG ON )function(include_sub_directories_recursively root_dir)if (IS_DIRECTORY ${root_dir})include_directories(${root_dir})file(GLOB children RELATIVE ${root_dir} ${root_dir}/*)foreach(child ${children})if (IS_DIRECTORY ${root_dir}/${child})include_sub_directories_recursively(${root_dir}/${child})endif()endforeach()endif()
endfunction()function(aux_source_directory_recursively root_dir var_name)if(IS_DIRECTORY ${root_dir})aux_source_directory(${root_dir} TMP_SRC_LIST)set(${var_name} ${${var_name}} ${TMP_SRC_LIST} PARENT_SCOPE)file(GLOB children RELATIVE ${root_dir} ${root_dir}/*)foreach(child ${children})if(IS_DIRECTORY ${root_dir}/${child})aux_source_directory_recursively(${root_dir}/${child} ${var_name}) endif()endforeach()endif()
endfunction()find_package(Threads REQUIRED )
find_package(glog REQUIRED)
find_package(Eigen3 REQUIRED)set(GLOG_LIBRARIES "/usr/local/lib/libglog.so")message(STATUS "GLOG_INCLUDE_DIRS: ${GLOG_INCLUDE_DIRS}")
message(STATUS "GLOG_LIBRARIES: ${GLOG_LIBRARIES}")
message(STATUS "EIGEN3_INCLUDE_DIR: ${EIGEN3_INCLUDE_DIR}")set(CMAKE_BUILD_TYPE "Debug")
set(CMAKE_INCLUDE_CURRENT_DIR ON)# aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC_LIST)aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/src/. SRC_LIST)#aux_source_directory_recursively(${CMAKE_CURRENT_SOURCE_DIR}/src SRC_LIST)
include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_sub_directories_recursively(${CMAKE_CURRENT_SOURCE_DIR}/src)##############################debug start##############################
get_property(include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)foreach(dir ${include_dirs})message("Include directory: ${dir}")
endforeach()message("Source files:")
foreach(file IN LISTS SRC_LIST)message(" ${file}")
endforeach()
#################################debug end####################################include_directories(${EIGEN3_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs)
add_executable(${PROJECT_NAME} ${SRC_LIST})
#add_library(${PROJECT_NAME} STATIC ${SRC_LIST}) # temp use
target_include_directories(${PROJECT_NAME} PRIVATE ${GLOG_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${GLOG_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${EIGEN3_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/libs/yaml-cpp/libyaml-cpp.a)#####################################unit test ###################################
# add_executable(unit_test_pathFW ${SRC_LIST})
# target_link_libraries( unit_test_pathFW
# ${GLOG_LIBRARIES}
# # ${CMAKE_CURRENT_SOURCE_DIR}/libs/yaml-cpp/libyaml-cpp.a
# ${CMAKE_CURRENT_SOURCE_DIR}/libs/yaml-cpp/libyaml-cpp.a
# # yaml-cpp
# )
#####################################unit test end#################################
备注:target_include_directories 用于为特定目标设置包含目录,而 include_directories 用于设置项目中所有目标的全局包含目录
vscode 找头文件
之前使用visual studio 感觉在这一点上 更方便,如果vscode 要配置一下 。
新建:c_cpp_properties.json 或者 ctrl +shift+ p在设置中查找 configuration (json),但也可以ui方式直接设置
{
"configurations": [
{
"browse": {
"databaseFilename": "${default}",
"limitSymbolsToIncludedHeaders": false
},
"includePath": [
"/home/kaifengqu/Desktop/H06CodeinROSEnv/devel/include/**",
"/opt/ros/noetic/include/**",
"/home/kaifengqu/Desktop/H06CodeinROSEnv/src/**",
"/usr/include/**"
],
"name": "ROS",
"intelliSenseMode": "gcc-x64",
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "c++14"
}
],
"version": 4
}
vscode debug
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) 启动","type": "cppdbg","request": "launch","program": "${workspaceFolder}/build_t/project_MPtest
","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "gdb","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "将反汇编风格设置为 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}]}]
}
# 使用ros的方式
1 Vscode 安装ros插件 还是需要添加一下launch配置{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "ROS: Attach","type": "ros","request": "attach"}]
}
2设置断点,运行节点,回放数据
3使用调试与运行中 ROS Attach 查找ID 或进程名称,将可执行文件(NODE)附加到进程里。如果不是用ros(有一个问题无法暂停数据的播放)也要配置debuggdb
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) 启动",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/project_PPconrtoller",
"args": [],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}]
}
现有代码直接关联远端git
echo "# Scripts" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git@github.com:HerrQQ/Scripts.git
git push -u origin main
ros 杂记
脚本更改
rosrun pilot_controller modifyForRos.py
分析工具rosrun plotjuggler plotjuggler
记录
rosbag record -O recorded_data -a
启动节点
roslaunch pilot_controller pilot_controller_ha1.launch 找节点关闭
pidof program_name pkill -f feishu回放
rqt_bag编译
catkin_make -j4 -DCMAKE_BUILD_TYPE=Debug
plotjuggler缺东西问题
使用sudo apt install ros-noetic-plotjuggler-ros一键安装plotjuggler及其ros插件
repo 杂记
https://blog.csdn.net/weixin_48120109/article/details/128272613 讲解repo具体用法
https://blog.csdn.net/KIK9973/article/details/118755045 haoyong nice to use
1. 初始化: 使用 repo init 命令初始化 repo,在后面添加 -u 参数,并指明源的 URL。例如:
repo init -u https://android.googlesource.com/platform/manifest
可以添加 -b 参数来切换到不同的分支,比如 -b android-4.0.1_r1。
同步: 使用 repo sync 命令将所有相关的 git 仓库同步到本地。可以添加 仓库名 参数来单独同步某一个仓库,否则默认同步全部。例如:
repo sync
同步特定仓库:
repo sync project_name
查看状态:使用 repo status 命令来查看所有 git 仓库的状态。
开始工作: 在开始对任何仓库做出修改之前,建议先使用 repo start 创建一个新的分支:
repo start my_branch my_project
1. 提交: 分别在每个 git 仓库中添加和提交更改,然后使用 repo upload 上传更改。
更多关于 repo 使用的命令和详细说明,可以通过在控制台输入 repo -h 查看。
Glog杂记
google::InitGoogleLogging(argv[0]);
google::SetStderrLogging(google::GLOG_ERROR);
FLAGS_colorlogtostderr = true;FLAGS_logtostderr = false; // 将日志输出到日志文件FLAGS_minloglevel = 2; // 设置最小日志级别为 ERRORFLAGS_log_dir = "/path/to/logs"; // 设置日志文件的输出目录