-
Notifications
You must be signed in to change notification settings - Fork 938
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
Setup assistant automating generation of controllers configs #908
Setup assistant automating generation of controllers configs #908
Conversation
// fake_controllers.yaml -------------------------------------------------------------------------------------- | ||
file.file_name_ = "fake_controllers.yaml"; | ||
// controllers.yaml -------------------------------------------------------------------------------------- | ||
file.file_name_ = "controllers.yaml"; |
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.
ros_controller.yaml
@@ -251,7 +251,7 @@ class MoveItConfigData | |||
bool outputOMPLPlanningYAML(const std::string& file_path); | |||
bool outputKinematicsYAML(const std::string& file_path); | |||
bool outputJointLimitsYAML(const std::string& file_path); | |||
bool outputFakeControllersYAML(const std::string& file_path); |
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.
lets keep the fake controllers also
@@ -0,0 +1,17 @@ | |||
<?xml version="1.0"?> |
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.
ros_controllers.launch
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.
Great work!
{ | ||
// Cache the joints' names. | ||
std::vector<std::vector<std::string>> groups; | ||
std::vector<std::string> groupJoints; |
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.
please use underscore for var names per ros style guidelines
bool MoveItConfigData::outputControllersYAML(const std::string& file_path) | ||
{ | ||
// Cache the joints' names. | ||
std::vector<std::vector<std::string>> groups; |
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.
use more specific name than just groups
std::vector<std::vector<std::string>> groups; | ||
std::vector<std::string> groupJoints; | ||
|
||
// Loop through groups |
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.
expand comment: why loop through?
if (joint->isPassive() || joint->getMimic() != NULL || joint->getType() == robot_model::JointModel::FIXED) | ||
continue; | ||
else | ||
{ |
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.
don't mix using brackets without using brackets... all or none
// Get list of associated joints | ||
const robot_model::JointModelGroup* joint_model_group = getRobotModel()->getJointModelGroup(group_it->name_); | ||
const std::vector<const robot_model::JointModel*>& joint_models = joint_model_group->getActiveJointModels(); | ||
// Iterate through the joints |
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.
explain why you are iterating through the joints
emitter << YAML::Value << YAML::BeginSeq; | ||
|
||
// Iterate through the joints | ||
for (int j = 0; j < groups[i].size(); j++) |
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.
std::size_t
emitter << YAML::Newline << YAML::Comment("Creates the /joint_states topic necessary in ROS"); | ||
emitter << YAML::EndMap; | ||
|
||
emitter << YAML::BeginMap; |
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.
what if in order to track the begin and end of maps, brackets were used to indent these sections? e.g.
emitter << YAML::BeginMap;
{
emitter << YAML::Key << "joint_state_controller";
emitter << YAML::Value << YAML::BeginMap;
...
}
emitter << YAML::EndMap;
output_stream << emitter.c_str(); | ||
output_stream.close(); | ||
|
||
return true; // file created successfully |
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.
this function is very long and readability is low. can it be separated out into a few smaller functions for each section of the yaml?
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.
I think I can split it, but I think later we will have to change this function when we expose some of the options to be configured by the GUI, would it be okay to leave it as a one piece until then?
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.
Sure, no problem.
std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc); | ||
if (!output_stream.good()) | ||
{ | ||
ROS_ERROR_STREAM("Unable to open file for writing " << file_path); |
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.
use ROS_ERROR_STREAM_NAMED
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.
Why do you recommend using the Named version here?
All the functions here that cant output a file uses this
ROS_ERROR_STREAM("Unable to open file for writing " << file_path);
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.
See the style guidelines under "ROS":
http://moveit.ros.org/documentation/contributing/code/
It makes filtering all the command line output much easier and cleaner. All of the MSA should be updated to use NAMED, but that belongs in a separate simple PR that doesn't clutter this one.
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.
Okay I understand, Thanks.
<!-- Load joint controller configurations from YAML file to parameter server --> | ||
<rosparam file="$(find [GENERATED_PACKAGE_NAME])/config/controllers.yaml" command="load"/> | ||
|
||
<!-- load the controllers --> |
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.
be consistent with capitalization in comments. i personally prefer capitalizing
@mcevoyandy please review |
…into setup_assistant_controllers
Sorry didn't see the comments till now, I'll have a look at them later today. |
Thanks for the review! |
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.
Generally approve. Some minor comments remain.
|
||
<!-- Load the controllers --> | ||
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" | ||
output="screen" ns="/[GENERATED_PACKAGE_NAME]" args="spawn joint_state_controller position_trajectory_controller"/> |
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.
@willcbaker Is using absolute namespaces compatible to 4598f66?
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.
I don't believe so, I would advise against absolute namespacing.
Unable to test or review until next week, seems changing this way with generated package name will require pushing down into package name namespace?
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.
So you recommend to remove the ns
argument from here and from the robot_state_publisher
node? right?
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.
Yes, I think so.
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.
This ros_controllers.launch
is intended to be used with gazebo
, and according to ros_control
tutorials, this is how gazebo_ros_control
plugin is defined in the urdf
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/MYROBOT</robotNamespace>
</plugin>
</gazebo>
So if we were to launch the controllers with not the robot_name
as a namespace
, and leave the plugin element <robotNamespace>
blank, how would we be able to use simulate multiple robot for example?
Is there a solution for a situation like that?
<!-- Convert joint states to TF transforms for rviz, etc --> | ||
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" | ||
respawn="false" output="screen"> | ||
<remap from="/joint_states" to="/[GENERATED_PACKAGE_NAME]/joint_states" /> |
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.
Same here.
@@ -254,6 +254,7 @@ class MoveItConfigData | |||
bool outputKinematicsYAML(const std::string& file_path); | |||
bool outputJointLimitsYAML(const std::string& file_path); | |||
bool outputFakeControllersYAML(const std::string& file_path); | |||
bool outputControllersYAML(const std::string& file_path); |
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.
outputROSControllersYAML?
…into setup_assistant_controllers
…d ros_error by ros_error_named
@@ -732,7 +732,7 @@ bool MoveItConfigData::outputControllersYAML(const std::string& file_path) | |||
std::ofstream output_stream(file_path.c_str(), std::ios_base::trunc); | |||
if (!output_stream.good()) | |||
{ | |||
ROS_ERROR_STREAM("Unable to open file for writing " << file_path); | |||
ROS_ERROR_STREAM_NAMED("ros_controllers_config", "Unable to open file for writing " << file_path); |
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.
how about namespace = "setup_assistant"
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.
-1 The package name (which is moveit_setup_assistant) is already part of the logger name. No need for an additional name at all!
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 point about the duplicate namespace, I should have recommended the file name "moveit_config_data" as that's the standard we usually follow. I really do like using _NAMED though. I've just attempted to document this standard better:
moveit/moveit.ros.org#166
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.
So do we go back to ROS_ERROR_STREAM
?
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.
That's my suggestion. @davetcoleman?
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.
I prefer the consistency of always using NAMED as I've just attempted to document in moveit/moveit.ros.org#166. Perhaps a Github issue should be opened to specifically debate this. Either way, having the namespace certainly does not hurt anything so I would like to just merge this PR.
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.
@davetcoleman I don't agree. If you just have a redundant logger name like xxx.xxx, there is no reason to insist in NAMED
. When we recently reworked the logging in some other MoveIt packages, we also dropped the extra NAME in such cases.
@@ -6,12 +6,12 @@ | |||
|
|||
<!-- Load the controllers --> | |||
<node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" | |||
output="screen" ns="/[GENERATED_PACKAGE_NAME]" args="spawn joint_state_controller position_trajectory_controller"/> | |||
output="screen" ns="[ROBOT_NAME]" args="spawn joint_state_controller position_trajectory_controller"/> |
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.
Looks like the ns prefix is very specific to your application. Why do you prefer ROBOT_NAME
over GENERATED_PACKAGE_NAME
now?
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.
After looking at gazebo_ros_demos/rrbot_control.launch , I've found we use the robot name not the package name for the namespace.
Which is also done in the ros_control tutorial here.
…into setup_assistant_controllers
…into setup_assistant_controllers
- ros_controllers.launch - ros_controllers.yaml
@MohmadAyman Please do not merge the devel branch into pull-request branches - never ever. I manually merged this now in 89f55aa. |
- ros_controllers.launch - ros_controllers.yaml
- ros_controllers.launch - ros_controllers.yaml
Description
This PR automates the generation of the ros_controller config files through the Setup Assistant, this is a part of upgrading the setup assistant. Issue 894
This ros_controllers.yaml was produced using this PR foe the PR2 Robot.
I'll follow this PR with another one that exposes the options through a GUI, and add documentation for it.
Checklist