Skip to content

Commit

Permalink
Correct ROS1 argument issue (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
ooeygui committed Feb 27, 2022
1 parent fe85dd6 commit 9c64379
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.8.2
* Correct ROS1 launch command that does not contain arguments

## 0.8.1
* Update Dependencies
* Update Docs
Expand Down
31 changes: 28 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vscode-ros",
"version": "0.8.1",
"version": "0.8.2",
"publisher": "ms-iot",
"engines": {
"vscode": "^1.63.1"
Expand Down Expand Up @@ -141,9 +141,9 @@
"description": "Absolute path to launch file",
"default": ""
},
"args": {
"arguments": {
"type": "array",
"description": "Arguments for the roslaunch (or ros2 launch) command",
"description": "Arguments for the roslaunch or ros2 launch command",
"default": []
},
"env": {
Expand All @@ -153,6 +153,31 @@
"additionalProperties": {
"type": "string"
}
},
"symbolSearchPath": {
"type": "string",
"description": "Semicolon separated list of directories to use to search for symbol (that is, pdb) files. Example: \"c:\\dir1;c:\\dir2\"",
"default": ""
},
"additionalSOLibSearchPath": {
"type": "string",
"description": "Semicolon separated list of directories to use to search for .so files",
"default": ""
},
"sourceFileMap": {
"type": "string",
"description": "Optional source file mappings passed to the debug engine. Example: '{ \"/original/source/path\":\"/current/source/path\" }'",
"default": ""
},
"launch": {
"type": "array",
"description": "A list of Scripts or executables to just launch without attaching a debugger",
"default": ""
},
"attachDebugger": {
"type": "array",
"description": "A specific list of executables to just attach a debugger. Useful for large compostions with where only a few nodes need to be debugged",
"default": ""
}
}
},
Expand Down
17 changes: 12 additions & 5 deletions src/debugger/configuration/resolvers/ros1/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,18 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
env: await extension.resolvedEnv(),
};

let result = await promisifiedExec(`roslaunch --dump-params ${config.target} ${config.args.join(' ')}`, rosExecOptions);
// If the configuration has arguments,
let configArgs :string = "";
if (config.arguments)
{
configArgs = config.arguments.join(' ');
}

let result = await promisifiedExec(`roslaunch --dump-params ${config.target} ${configArgs}`, rosExecOptions);
if (result.stderr) {
throw (new Error(`Error from roslaunch:\r\n ${result.stderr}`));
} else if (result.stdout.length == 0) {
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target}\" in a ros terminal.`));
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target} ${configArgs}\" in a ros terminal.`));
}


Expand All @@ -90,16 +97,16 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider {
});
}

result = await promisifiedExec(`roslaunch --nodes ${config.target} ${config.args.join(' ')}`, rosExecOptions);
result = await promisifiedExec(`roslaunch --nodes ${config.target} ${configArgs}`, rosExecOptions);
if (result.stderr) {
throw (new Error(`Error from roslaunch:\r\n ${result.stderr}`));
} else if (result.stdout.length == 0) {
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target}\" in a ros terminal.`));
throw (new Error(`roslaunch unexpectedly produced no output, please test by running \"roslaunch --dump-params ${config.target} ${configArgs}\" in a ros terminal.`));
}

const nodes = result.stdout.trim().split(os.EOL);
await Promise.all(nodes.map((node: string) => {
return promisifiedExec(`roslaunch --args ${node} ${config.target} ${config.args.join(' ')}`, rosExecOptions);
return promisifiedExec(`roslaunch --args ${node} ${config.target} ${configArgs}`, rosExecOptions);
})).then((commands: Array<{ stdout: string; stderr: string; }>) => {
commands.forEach(async (command, index) => {
const launchRequest = this.generateLaunchRequest(nodes[index], command.stdout, config);
Expand Down

0 comments on commit 9c64379

Please sign in to comment.