-
Notifications
You must be signed in to change notification settings - Fork 948
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
ROS Controllers screen added to SA #994
ROS Controllers screen added to SA #994
Conversation
cd43756
to
0bdb47e
Compare
If pull request #969 turned to need the new struct to be a class, this will too. |
Friendly ping @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.
Really great work!
@@ -277,7 +269,8 @@ class MoveItConfigData | |||
bool outputKinematicsYAML(const std::string& file_path); | |||
bool outputJointLimitsYAML(const std::string& file_path); | |||
bool outputFakeControllersYAML(const std::string& file_path); | |||
void outputFollowJointTrajectoryYAML(YAML::Emitter& emitter); | |||
void outputFollowJointTrajectoryYAML(YAML::Emitter& emitter, | |||
std::vector<ROSControlConfig>* ros_controllers_config_copy); |
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 is this called _copy
?
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.
Because this function modifies the ros_controllers_config_
object, we don't want to modify the original object here.
@@ -277,7 +269,8 @@ class MoveItConfigData | |||
bool outputKinematicsYAML(const std::string& file_path); | |||
bool outputJointLimitsYAML(const std::string& file_path); | |||
bool outputFakeControllersYAML(const std::string& file_path); | |||
void outputFollowJointTrajectoryYAML(YAML::Emitter& emitter); | |||
void outputFollowJointTrajectoryYAML(YAML::Emitter& emitter, |
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.
add function documentation for these args
ROSControlConfig* findROSControllerByName(const std::string& controller_name); | ||
|
||
/** | ||
* delete ros controller by name |
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.
Delete
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"
@@ -1132,7 +1136,7 @@ bool MoveItConfigData::inputROSControllersYAML(const std::string& file_path) | |||
std::ifstream input_stream(file_path.c_str()); | |||
if (!input_stream.good()) | |||
{ | |||
ROS_ERROR_STREAM_NAMED("ros_controller.yaml", "Unable to open file for reading " << file_path); | |||
ROS_INFO_STREAM_NAMED("ros_controller.yaml", "Does not exist " << 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.
shouldn't this be an error or warning?
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 agree a warning
maybe better here, initially the package might not has a ros_controllers.yaml
, so a warn
would do I believe.
@@ -1142,78 +1146,81 @@ bool MoveItConfigData::inputROSControllersYAML(const std::string& file_path) | |||
YAML::Node doc = YAML::Load(input_stream); | |||
// Read the robot name | |||
|
|||
for (YAML::const_iterator controller_it = doc.begin(); controller_it != doc.end(); ++controller_it) | |||
for (YAML::const_iterator map_it = doc.begin(); map_it != doc.end(); ++map_it) |
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.
can you make map_it
more descriptive / longer?
} | ||
} | ||
} | ||
} | ||
else | ||
} | ||
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.
this is very difficult to follow, please split into helper functions
@@ -1433,7 +1440,7 @@ srdf::Model::Group* MoveItConfigData::findGroupByName(const std::string& name) | |||
} | |||
|
|||
// ****************************************************************************************** | |||
// Find controller by name | |||
// Find ros controller by name |
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
} // 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.
typo
return; | ||
has_loaded = true; | ||
|
||
const std::array<std::string, 10> types = { "effort_controllers/JointTrajectoryController", |
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.
rename to default_types
* copyright notice, this list of conditions and the following | ||
* disclaimer in the documentation and/or other materials provided | ||
* with the distribution. | ||
* * Neither the name of Willow Garage nor the names of its |
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.
note "Willow Garage" is still in the license here and elsewhere. replace with your name
0bdb47e
to
ec5004b
Compare
@davetcoleman |
@@ -670,6 +671,9 @@ void MoveItConfigData::outputFollowJointTrajectoryYAML(YAML::Emitter& emitter) | |||
// ****************************************************************************************** | |||
bool MoveItConfigData::outputROSControllersYAML(const std::string& file_path) | |||
{ | |||
// Copy ros_control_config_ to a new vector to avoid modifying it | |||
std::vector<ROSControlConfig> ros_controllers_config_copy(ros_controllers_config_); |
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.
instead of copy
can we call this ros_controllers_config_output
?
* @return void | ||
*/ | ||
void outputFollowJointTrajectoryYAML(YAML::Emitter& emitter, | ||
std::vector<ROSControlConfig>* ros_controllers_config_copy); |
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.
instead of a pointer, pass this in by reference
// Loop through all controllers | ||
if (const YAML::Node& controller = controller_it->second) | ||
for (YAML::const_iterator controller_it = controllers.begin(); controller_it != controllers.end(); | ||
++controller_it) |
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.
move the contents of this for loop into a helper function to make this more readable... named perhaps processROSController(controller_it, ...)
@@ -1453,6 +1478,24 @@ ROSControlConfig* MoveItConfigData::findROSControllerByName(const std::string& c | |||
return searched_ros_controller; | |||
} | |||
|
|||
// ****************************************************************************************** | |||
// Deletes a ros controller by name |
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" and elsewhere
@@ -1473,9 +1516,9 @@ bool MoveItConfigData::addROSController(const ROSControlConfig& new_controller) | |||
// ****************************************************************************************** | |||
// Gets ros_controllers_config_ vector | |||
// ****************************************************************************************** | |||
std::vector<ROSControlConfig> MoveItConfigData::getROSControllers() | |||
std::vector<ROSControlConfig>* MoveItConfigData::getROSControllers() |
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.
return by reference, not pointer
Looks like your other PR caused merge conflicts. otherwise its looking very close! @mcevoyandy please review |
ec5004b
to
2fc77a2
Compare
@davetcoleman |
* Helper function for writing follow joint trajectory ROS controllers to ros_controllers.yaml | ||
* @param YAML Emitter - yaml emitter used to write the config to the ROS controllers yaml file | ||
* @param vector<ROSControlConfig> - a copy of ROS controllers config which will be modified in the function | ||
* @return void |
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.
no need to have this line @return
if its void, please remove
* Helper function for writting Joint State ROS controllers to ros_controller.yaml | ||
* @param YAML Emitter - yaml emitter used to write the config to the ROS controllers yaml file | ||
* @param vector<ROSControlConfig> - a copy of ROS controllers config which will be modified in the function | ||
* @return void |
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.
no need to have this line @return
if its void, please remove
@@ -352,6 +362,20 @@ class MoveItConfigData | |||
*/ | |||
bool inputKinematicsYAML(const std::string& file_path); | |||
|
|||
/** | |||
* Helper function for parsing ros_controllers.yaml file | |||
* @param YAML::Node - controllers to be parsed |
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.
"controllers" --> "individual controller"
@@ -361,8 +385,15 @@ class MoveItConfigData | |||
|
|||
/** | |||
* \brief Add a Follow Joint Trajectory action Controller for each Planning Group | |||
* \return bool if controllers were added to the ros_controllers_config_ data structure |
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.
"bool" --> "true"
|
||
/** | ||
* \brief Add a Joint State Controller for each Planning Group | ||
* \return bool if controllers were added to the ros_controllers_config_ data structure |
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.
"bool" --> "true"
@@ -1164,6 +1222,107 @@ bool MoveItConfigData::inputKinematicsYAML(const std::string& file_path) | |||
return true; // file created successfully | |||
} | |||
|
|||
// ****************************************************************************************** | |||
// Helper function for parsing ros_controllers.yaml file |
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 more descriptive in comment, currently this comment is identical to line 1272. what is different about this function from processROSControllers?
void ControllerEditWidget::loadControllersTypesComboBox() | ||
{ | ||
// Only load this combo box once | ||
static bool has_loaded = false; |
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.
do not use static, rather make this a member variable of the class
/* Author: Mohamad Ayman */ | ||
|
||
#ifndef MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONTROLLER_EDIT_WIDGET_ | ||
#define MOVEIT_ROS_MOVEIT_SETUP_ASSISTANT_WIDGETS_CONTROLLER_EDIT_WIDGET_ |
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.
add "H" at end: http://wiki.ros.org/CppStyleGuide#A.23ifndef_guards
|
||
// ****************************************************************************************** | ||
// Qt Components | ||
// ****************************************************************************************** |
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 components should be private, not public
virtual void focusGiven(); | ||
|
||
// ****************************************************************************************** | ||
// Qt Components |
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.
make private
Review from runtime:
|
1330ee8
to
a00ce3d
Compare
Is this ready for re-review? |
Yes it is ready @davetcoleman |
This segfaults when I choose a perception sensor then change screens.
|
@davetcoleman I believe this makes sense, since the pull request #1013 [fix bug in perception screen] is not merged yet. |
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.
Tested locally and it works :)
// If the setting has joints then it is a controller that needs to be parsed | ||
if (!control_setting.joints_.empty()) | ||
{ | ||
if (const YAML::Node& urdf_node = controller_it->second["type"]) |
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.
combine if statements?
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 think I can put more than one condition in an if
statement that has initialization in it, I'm not 100% if it is not possible, but I've tried and it didn't work.
@@ -667,6 +668,9 @@ void MoveItConfigData::outputFollowJointTrajectoryYAML(YAML::Emitter& emitter) | |||
// ****************************************************************************************** | |||
bool MoveItConfigData::outputROSControllersYAML(const std::string& file_path) | |||
{ | |||
// Copy ros_control_config_ to a new vector to avoid modifying it | |||
std::vector<ROSControlConfig> ros_controllers_config_output(ros_controllers_config_); |
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.
Cand the copy of outputFollowJointTrajectoryYAML be moved into outputFollowJointTrajectoryYAML()? It seems it's not used elsewhere in the function. Also, can you add a comment as to why you are erasing things from the copy?
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 believe you meant ros_controllers_config_output
which is a copy of ros_controllers_config_
, It is used in the rest of the function outputROSControllersYAML
, thats why it is defined there not in outputFollowJointTrajectoryYAML
.
I'll add a comment the explains why I erase the controller that I write to the file.
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.
addressed all comments.
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_config_output is not used in outputROSControllersYAML()
, only in outputFollowJointTrajectoryYAML()
. please move it there since its only actually used in that helper function
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_config_output
is used in outputROSControllersYAML()
here .
// This function writes FollowJointTrajectory controllers for each planning group to ros_controller.yaml. | ||
outputFollowJointTrajectoryYAML(emitter); | ||
// Writes Follow Joint Trajectory ROS controllers to ros_controller.yaml | ||
outputFollowJointTrajectoryYAML(emitter, ros_controllers_config_output); | ||
|
||
{ |
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.
Remove bracket
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.
thats right, thats scoping didn't really make sense
a00ce3d
to
c5c667c
Compare
c5c667c
to
ba56e13
Compare
cherry-picked to melodic great job! |
* Added ros controllers screen to SA * GUI and code fixes * added a ros_control namespace * better docs, moved variables from public to private * reverted joint state controllers change * adding a minor comment
* Added ros controllers screen to SA * GUI and code fixes * added a ros_control namespace * better docs, moved variables from public to private * reverted joint state controllers change * adding a minor comment
Description
This screen main purpose is to automate the process of generating ROS Controllers configuration.
The generated ROS Controllers config is launched by
ros_controllers.launch
which makes simulating a robot ingazebo
possible.This PR is part of upgrading the Setup Assistant.
Checklist