ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Best practices for organizing a project [closed]

asked 2015-06-10 19:09:30 -0500

troman gravatar image

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.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Miquel Massot
close date 2015-07-15 06:43:57.960994

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-11 00:50:21 -0500

ahendrix gravatar image

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

edit flag offensive delete link more


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?

troman gravatar image troman  ( 2015-06-11 11:43:53 -0500 )edit

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)

troman gravatar image troman  ( 2015-06-11 12:45:28 -0500 )edit

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.

ahendrix gravatar image ahendrix  ( 2015-06-11 15:16:19 -0500 )edit

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.

ahendrix gravatar image ahendrix  ( 2015-06-11 15:19:20 -0500 )edit

Question Tools

1 follower


Asked: 2015-06-10 19:09:30 -0500

Seen: 693 times

Last updated: Jun 11 '15