Skip to content
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

Code does not follow ROS design conventions #3

Closed
rokusottervanger opened this issue Nov 28, 2020 · 3 comments · Fixed by #8
Closed

Code does not follow ROS design conventions #3

rokusottervanger opened this issue Nov 28, 2020 · 3 comments · Fixed by #8
Labels
enhancement New feature or request later Improvements or additions for the future

Comments

@rokusottervanger
Copy link
Contributor

This node does not follow the conventions and rules about:

Also, it's good practice to separate a library for interfacing with the hardware from the ROS wrapper, implemented as a C++ class.

Would you be interested in a refactor to make your driver follow these conventions? It might break existing setups, but as there is no release yet, that doesn't seem like too much of a problem.

@horverno horverno added the later Improvements or additions for the future label Nov 30, 2020
@horverno
Copy link
Member

horverno commented Dec 2, 2020

Here are my remarks:

Package naming: https://www.ros.org/reps/rep-0144.html

ROS Enhancement Proposals suggests lowercase alphanumerics and _ separators, so instead of duro-ros i think eg duro_ros would be ok

Naming conventions for drivers: https://ros.org/reps/rep-0135.html

Are you suggesting to add namespaces into the launch file?

Parameter namespacing: http://wiki.ros.org/Parameter%20Server

There are two params duro_address and duro_port, it seems ok, but clearly I have missed something, can you explain please?

IMU topics and using the sensor_msgs/IMU message: https://www.ros.org/reps/rep-0145.html

That makes sense to me.

@horverno horverno added the enhancement New feature or request label Dec 2, 2020
@rokusottervanger
Copy link
Contributor Author

Here are my remarks:

Package naming: https://www.ros.org/reps/rep-0144.html

ROS Enhancement Proposals suggests lowercase alphanumerics and _ separators, so instead of duro-ros i think eg duro_ros would be ok

Correct!

Naming conventions for drivers: https://ros.org/reps/rep-0135.html

Are you suggesting to add namespaces into the launch file?

Yes. So you remove the hard coded namespaces from the driver (/gps/duro), and just publish topics in the global namespace:

/fix
/imu
/mag
/status_flag
/status_string

(of course, without forcing them in the global namespace by hardcoding the initial /). Then push the node to a group with a ns in the launch file (which is up to the user, in the end).

Parameter namespacing: http://wiki.ros.org/Parameter%20Server

There are two params duro_address and duro_port, it seems ok, but clearly I have missed something, can you explain please?

You're looking up those parameters in the global namespace by performing the lookup using the global nodehandle here:

ros::NodeHandle n;

n.getParam("duro_address", tcp_ip_addr);
n.getParam("duro_port", tcp_ip_port);

Instead, you should do the lookup of node specific parameters in the node's local namespace with a local nodehandle:

ros::NodeHandle n_p("~");

When they are in the node's namespace, there's no need to prefix the parameter names with duro_ anymore either, so you can just call them ip_address and port or something like that.

By the way, there is a built in way to use defaults too: http://wiki.ros.org/roscpp/Overview/Parameter%20Server#Getting_Parameters

IMU topics and using the sensor_msgs/IMU message: https://www.ros.org/reps/rep-0145.html

That makes sense to me.

Good :) Also take note of the units specified in the sensor_msgs/MagneticField message. Those should be in Tesla, not microTesla.

I can make a PR for you probably over the weekend.

@rokusottervanger
Copy link
Contributor Author

I tried to keep it somewhat backward compatible. I think only the change in parameter namespace may break an application that doesn't use the included launch file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request later Improvements or additions for the future
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants