vscode, ros

1. 编译

首先需要把ros的项目编译成exe

2. 在vsocde中配置launch.json

在ros exe中添加,打印出exe的相关输入参数

    for (int i = 0; i < argc; i++)
    {
        cout << "args value is:" << argv[i] << endl;
    }

然后根据上面的参数配置vsocde的launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/devel/lib/orb_object_slam/ros_mono",
            "args": ["${workspaceFolder}/src/cube_slam/orb_object_slam/Vocabulary/ORBvoc.bin", 
                     "${workspaceFolder}/src/cube_slam/orb_object_slam/Examples/Monocular/KITTI04-12_me.yaml"],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

3. roslaunch启动时的launch文件

需要先按正常的命令启动一个launch文件。比如roslaunch orb_object_slam mono.launch,然后在ros的exe中,才能读取launch中的参数。