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

ROS Controllers screen added to SA #994

Merged
merged 6 commits into from
Aug 14, 2018

Conversation

mayman99
Copy link
Contributor

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 in gazebo possible.

This PR is part of upgrading the Setup Assistant.

Checklist

  • Required: Code is auto formatted using clang-format
  • Extended the tutorials / documentation, if necessary reference
  • Include a screenshot if changing a GUI
  • Optional: Created tests, which fail without this PR reference
  • Optional: Decide if this should be cherry-picked to other current ROS branches (Indigo, Jade, Kinetic)

@mayman99 mayman99 mentioned this pull request Jul 22, 2018
6 tasks
@mayman99 mayman99 force-pushed the ros_controllers_screen branch 2 times, most recently from cd43756 to 0bdb47e Compare July 23, 2018 12:26
@mayman99
Copy link
Contributor Author

If pull request #969 turned to need the new struct to be a class, this will too.

@mayman99
Copy link
Contributor Author

Friendly ping @davetcoleman
If pull request #969 turned to need the new struct to be a class, this probably will too.

Copy link
Member

@davetcoleman davetcoleman left a 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);
Copy link
Member

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?

Copy link
Contributor Author

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,
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete

Copy link
Member

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);
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ROS

} // namespace\
Copy link
Member

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",
Copy link
Member

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
Copy link
Member

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

@mayman99
Copy link
Contributor Author

@davetcoleman
Addressed the comments on this one.

@@ -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_);
Copy link
Member

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);
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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()
Copy link
Member

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

@davetcoleman
Copy link
Member

Looks like your other PR caused merge conflicts. otherwise its looking very close!

@mcevoyandy please review

@mayman99
Copy link
Contributor Author

mayman99 commented Aug 2, 2018

@davetcoleman
Addressed the comments both here and in the doc, I thought of not squashing the commits to the review easier and when approved I can squash them.

* 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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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;
Copy link
Member

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_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// ******************************************************************************************
// Qt Components
// ******************************************************************************************
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make private

@davetcoleman
Copy link
Member

Review from runtime:

  • Change screen title: "ROS Control Controllers"
  • Change description sentence: "Configure MoveIt! to work with ROS Control to control the robot's physical hardware."
  • Both of the "Auto" buttons have the "A" underlined, but this defeats the purpose of the hotkey shortcut. Choose a different key for the second button

@mayman99 mayman99 force-pushed the ros_controllers_screen branch 2 times, most recently from 1330ee8 to a00ce3d Compare August 6, 2018 22:33
@davetcoleman
Copy link
Member

Is this ready for re-review?

@mayman99
Copy link
Contributor Author

mayman99 commented Aug 9, 2018

Yes it is ready @davetcoleman

@davetcoleman
Copy link
Member

This segfaults when I choose a perception sensor then change screens.

  • Apply this PR to moveit source install
  • git clone franka_ros
  • catkin build
  • Start the MSA
  • Create new moveit_config package by loading URDF from ws_moveit/src/franka_ros/franka_description/robot
  • Choose the perception screen
  • Choose a sensor
  • Change screens
  • Segfault!

image

@mayman99
Copy link
Contributor Author

mayman99 commented Aug 9, 2018

@davetcoleman I believe this makes sense, since the pull request #1013 [fix bug in perception screen] is not merged yet.

Copy link
Member

@davetcoleman davetcoleman left a 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"])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

combine if statements?

Copy link
Contributor Author

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_);

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed all comments.

Copy link
Member

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

Copy link
Contributor Author

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);

{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove bracket

Copy link
Contributor Author

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

@davetcoleman davetcoleman merged commit bd7e1c1 into moveit:kinetic-devel Aug 14, 2018
@davetcoleman
Copy link
Member

cherry-picked to melodic

great job!

davetcoleman pushed a commit that referenced this pull request Aug 14, 2018
* 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
pull bot pushed a commit to shadow-robot/moveit that referenced this pull request Sep 3, 2020
* 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
JafarAbdi pushed a commit to JafarAbdi/moveit that referenced this pull request Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants