0
$\begingroup$

Rosanswers logo

Hello all,

Sorry for the long winded explanation but my thoughts are a bit scattered on this.

I'm fairly new to ROS. I've been working with it for about a month and I feel I'm beginning to understand most of the basics (packages, topics, subscriptions, services, etc), but when it comes to how to put together a practical project I'm struggling. I'm using ROS for my senior design project, which is a mobile autonomous robot with some mapping and computer vision capabilities. The robot is going to have several well-defined modes of operation where some subsystems should be active or inactive.

We're using a Kinect and converting the depth cloud to a laserscan with the depthcloud_to_laserscan node. I've already got this working with HectorSLAM as a preliminary mapping system since the robot isn't built yet and I don't have access to physical odometry. Here are examples of a few of the operation modes:

  • Autonomous Mapping Mode: Sonar/tactile based obstacle avoidance system + SLAM system
  • Manual Mapping Mode: Teleoperation system + SLAM system
  • Autonomous Patrol Mode: Sonar/tactile based obstacle avoidance system + Map-based navigation system + Motion detection system

What's the best way to initialize/start this system and switch between these states? I don't want all the subsystems to be active at the same time because power and processing will be important. For prototyping, I want to be able to type commands into the terminal to switch between each of these systems, launching all of the relevant nodes and closing them cleanly when the procedures are complete or are interrupted.

I suppose this is more of a design philosophy question, I'm sorry if it's not specific enough. I've read through most of the tutorial content and so far I haven't found anything that quite answers my question.

All replies welcome, thanks.


Originally posted by troman on ROS Answers with karma: 30 on 2015-06-10

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

For the first revision of your project, I think launch files are appropriate; have a look at roslaunch

For my robot, I have a base launch file which runs the driver for my base and my sensors, and the kalman filter that I use to estimate position. All of my modes use this functionality.

For each mode, I have an additional launch file which runs the nodes for that mode.

Launch files can include one another as well, so if you have some functionality that is used by some modes, but not all, you can separate out those nodes into their own launch file, and include that launch file within each mode that needs it.

For even more things that you can do with roslaunch, have a look at the roslaunch tips for large projects


Originally posted by ahendrix with karma: 47576 on 2015-06-11

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by troman on 2015-06-11:
Thanks for the helpful suggestions. Do you have any advice for how to stop or shut down nodes cleanly? Would it be sufficient to just put a system call in the nodes to kill themselves when a particular condition is met?

Comment by troman on 2015-06-11:
So I started delving deeper into the rospy API and found this:

Initialization and Shutdown

If anyone else has the same question your answer is at the bottom: rospy.signal_shutdown(reason)

Comment by ahendrix on 2015-06-11:
When you stop a roslaunch, it will stop all of the nodes that it started; I usually use that instead of an explicit shutdown within the node.

Comment by ahendrix on 2015-06-11:
The capabilities framework is a more advanced system which can manage dependencies and startup and shutdown of launch files, but it also requires more setup.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.