0
$\begingroup$

Rosanswers logo

I know there are various best practice pages for ROS. I've combined what I learned from there with some of my own. Any comments on these: http://cosi119r.s3-website-us-west-2.amazonaws.com/content/topics/robotics_notes/ros_best_practices/

These are my suggested ROS best practices (Be kind - I am taking a risk just putting this out here)

*** DRAFT ***

ROS Nodes, Topics, Messages

  • There’s rarely a need to design a custom message (.msg) If you need one it’s ok but you should try and avoid it if possible.
  • As a general rule if you can organize your functionality into multiple separate ROS nodes you will get better modularity and reusability.
  • As a general rule you can get nicer ROS code if you break the functionality into ROS classes and in separate files (packages) This works especially well if you can identify bits functionality that may be reused in other applications
  • Don’t assume that /scan topic’s LaserScan message has 360 items in the ranges array. Even in our simple case, the YDLidar Driver we use seems to have 720 items, that is ½ degree entries. If you get that wrong your code just won’t work. You can use len(msg.ranges) to figure out the actual number you have.
  • Topics vs. Services vs. Actions. Topics are almost always the right communications abstraction. Use a service when you want the requested to BLOCK execution until the request is done - noting that this is only suitable for very fast operations. Actions are useful in very specific situations where there is a longish running request where interim progress reports are useful. It is possible to use just topics to accomplish the same thing (I think!)

Package Structure

  • Create properly structured packages so they can easily be added to other workspaces.
  • Name the directory with the programs src
  • Other directories should be present only if you use them
  • Include a package.xml and CMakeFile.txt
  • Use the create_package utility to create a correct package

Documentation

  • It's a good idea to include a readme.md
  • It's a good idea to include a license.md

TFs (transforms)

  • There are conventional names for TFs: (https://www.ros.org/reps/rep-0105.html)
  • base_link for the “center” of the robot. You get to pick it but it should make some intuitive sense. All other parts of the robot are below base_link
  • Sometimes it’s useful to have another TF which is the center of the footprint of the robot, meaning, a TF projected straight down from base_link and intersecting with the ground plane wherever that is.
  • odom for the odometry created TF
  • map for the TF of a map built by hand or through slam
  • TFs follow a typical hierarchy as follows: map -> odom -> base_link

Python

  • Ros Melodic relies on Python 2.7 and the next (and final) ROS1 version neotic relies on Python 3.x
  • You can chose to use classes or just top level functions
  • If you find yourself using global often that's a smell and a hint that you should be using a classes

Originally posted by pitosalas on ROS Answers with karma: 628 on 2021-03-24

Post score: 0


Original comments

Comment by gvdhoorn on 2021-03-25:
You already link to it, but the leggedrobotics best practices seem to include yours and add a lot more best practices. Are you primarily trying to avoid information overload for students?

TFs follow a typical hierarchy as follows: map -> odom -> base_link

this sounds like it's a convention, but it's actually standardised in REP 105: Coordinate Frames for Mobile Platforms.

Additionally: this is really "only" for mobile robots. I have lots of robots, but they don't drive around, so I don't have map nor odom frames.

All other parts of the robot are below base_link

"below" as in: closer to the ground level? Or their links and/or frames are children of base_link?

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

@pitosalas This isn't really a question with a definite answer by which it's not great for this site. Especially with the many different areas, it's hard for people to know if your answers are resolved or if it needs more attention. However it's a decent way to get a little feedback so I'm not going to close it out immediately. But please make sure not to leave this question dangling and mark it as resolved so that it doesn't become one more issue that people eventually need to triage.


Originally posted by tfoote with karma: 58457 on 2021-03-25

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by pitosalas on 2021-03-31:
Alas other than good old @gvdhoorn I didn't receive any feedback. But as requested, I am closing it now.

Comment by tfoote on 2021-03-31:
Thanks for helping keep things clean here. I might suggest a slightly different approach. It's very hard for anyone individually answer what is "Best" for any specific topic. And similarly if you now ask for expertise in transforms, documentation, package structure, and computational structure. People may have answers to any of the specific questions but don't have expertise for all of them. If you really want to find the "best" answers for this it's probably most efficient to ask specific questions on this site and then look for the best answer. That's basically exactly what this site is designed for. A well phrased question with clear scope and background will usually get one or more well phrased answers.

Comment by tfoote on 2021-03-31:
When you ask the questions think about who will answer them and what time it will take and if there's a concrete answer or if you're just asking open ended questions with arbitrary responses that will take someone a lot of time to respond. If I can't answer the question off the top of my head immediately while reading it, even if I want to answer it, it likely get pushed onto a queue of things to do later and often that queue is never emptied. You want to be able to be answered without ending up on that other queue because other people's volunteered time is precious.

Comment by pitosalas on 2021-04-01:
Thanks! I knew this one was an open ended question, I was hoping for people to say: x is wrong and you forgot y. I still want to improve my best practices note for my students :) As you can tell from my next question about sleep and spin once there's some nuance about that usage that I am not fully on top of yet, but I want to give them a best practice there too.

$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.