-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start ROSCore for launch debugging, if not running (ROS1) #429
Changes from 3 commits
6e8b754
09c51a3
cde9ff0
ab89416
e490def
050333d
293279d
b6849aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,8 @@ import * as vscode from "vscode"; | |
import * as extension from "../../../../extension"; | ||
import * as requests from "../../../requests"; | ||
import * as utils from "../../../utils"; | ||
import { rosApi } from "../../../../ros/ros"; | ||
import { env } from "../../../../extension"; | ||
|
||
const promisifiedExec = util.promisify(child_process.exec); | ||
|
||
|
@@ -32,7 +34,31 @@ export class LaunchResolver implements vscode.DebugConfigurationProvider { | |
if (!path.isAbsolute(config.target) || path.extname(config.target) !== ".launch") { | ||
throw new Error("Launch request requires an absolute path as target."); | ||
} | ||
|
||
const delay = ms => new Promise(res => setTimeout(res, ms)); | ||
|
||
switch(env.ROS_VERSION.trim()) { | ||
case "1": { | ||
// Manage the status of the ROS core, starting one if not present | ||
// The ROS core will continue to run until the VSCode window is closed | ||
const core_active = rosApi.getCoreStatus(); | ||
if (!(await core_active).valueOf()) { | ||
rosApi.startCore(); | ||
|
||
// Wait for the core to start | ||
while (!(await rosApi.getCoreStatus()).valueOf()) { | ||
await delay(100); | ||
} | ||
} | ||
break; | ||
} | ||
case "2": { | ||
// TODO, support starting the ROS2 daemon automatically | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With a Todo comment, could you link it to a github issue so we don't forget to add this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I created #431 for the issue. I wasn't sure on the exact format you wanted to link it, so I went with |
||
break; | ||
} | ||
} | ||
|
||
|
||
const rosExecOptions: child_process.ExecOptions = { | ||
env: await extension.resolvedEnv(), | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be great to add a maximum timeout - Wouldn't want to cause issues with vscode if roscore fails for some other reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I wasn't sure on the exact timeout to set, so I settled for 3 seconds. From my local testing, roscore seems to activate at about the 700 ms mark, but I figured it could be slower if you were running this on a Raspberry Pi or something. The error message should help users if a super slow machine can't start roscore in 3 seconds.