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

Read and write ROS controllers yaml file #951

Merged

Conversation

mayman99
Copy link
Contributor

@mayman99 mayman99 commented Jun 13, 2018

Description

Adding functions to read and write ros_contollers.yaml file.
Adding an automated way to add FollowJointTrajectory action controller for each planning group, e.g.

  controller_list:
  - name: g1_controller
    action_ns: follow_joint_trajectory
    default: True
    type: FollowJointTrajectory
    joints:
      - joint1
      - joint2

@davetcoleman @mcevoyandy

Checklist

  • Required: Code is auto formatted using clang-format
  • [needed] 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)

This was referenced Jun 13, 2018
@mayman99 mayman99 force-pushed the gazebo_integration_trials branch 2 times, most recently from 96d30f6 to 4979db2 Compare June 14, 2018 11:01
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.

Great work! Sorry for the intense review, I just care a lot about quality :)

{
std::string name_; // controller name
std::string type_; // controller type
std::vector<std::string> joints_; // joints names this controller
Copy link
Member

Choose a reason for hiding this comment

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

comment: "joints controlled by this controller"

/**
* Controllers settings which may be set in the config files
*/
struct Controller
Copy link
Member

Choose a reason for hiding this comment

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

more descriptive name for the struct... maybe "ROSControlConfig"?

"Controller" is way too generic

@@ -221,6 +231,15 @@ class MoveItConfigData
/// Email of the author of this config
std::string author_email_;

/// Name of the group that holds all the joints to be used by sim contollers
std::string controllers_initial_group_;
Copy link
Member

Choose a reason for hiding this comment

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

rename sim_controllers_initial_group_

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 removed the sim_controllers part as it is still to be decided which is the best screen to put them, I put it in the description.

std::string controllers_initial_group_;

/// Name of the initial pose to be used by sim contollers
std::string controllers_initial_pose_;
Copy link
Member

Choose a reason for hiding this comment

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

sim_controllers_...

/// Name of the initial pose to be used by sim contollers
std::string controllers_initial_pose_;

/// Controllers config data
Copy link
Member

Choose a reason for hiding this comment

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

more descriptive comment, define "controller" please

void editSelected();

/// Called from Double List widget to highlight a joint
// void previewClickedJoint( std::string name );
Copy link
Member

Choose a reason for hiding this comment

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

remove

@@ -282,6 +282,7 @@ void PlanningGroupsWidget::loadGroupsTree()
btn_delete_->hide();
}

current_edit_group_.clear();
Copy link
Member

Choose a reason for hiding this comment

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

these kinds of changes should be in a separate PR... this one is way too big already

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 wasn't so sure too, but from the feedback I got from PR where I removed the unused variable, "it is advised not to open too small PR"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Yes there's a middle ground :-)

One line change is a bit small, but many hundreds of lines is getting large.

@@ -431,6 +431,10 @@ bool StartScreenWidget::loadExistingFiles()
.append(kinematics_yaml_path.make_preferred().native().c_str()));
}

fs::path controllers_yaml_path = config_data_->config_pkg_path_;
Copy link
Member

Choose a reason for hiding this comment

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

add comment explaining what this is

}

// ******************************************************************************************
// Add a Follow Joint Trajectory action Controller for each Planning Group
Copy link
Member

Choose a reason for hiding this comment

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

"Add a FollowJointTrajectory action controller from ros_control for each Planning Group"

// ******************************************************************************************
// Add a Follow Joint Trajectory action Controller for each Planning Group
// ******************************************************************************************
void ControllersWidget::addDefaultControllers()
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 also, by default, add a joint_state_controller/JointStateController? those are equally important

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mayman99 mayman99 force-pushed the gazebo_integration_trials branch 3 times, most recently from 12067a5 to 09d4cac Compare June 18, 2018 19:54
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.

This is looking really good! All it needs is the unit test.

@@ -220,6 +221,7 @@ private Q_SLOTS:
EndEffectorsWidget* efw_;
VirtualJointsWidget* vjw_;
PassiveJointsWidget* pjw_;
ControllersWidget* cw_;
Copy link
Member

Choose a reason for hiding this comment

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

these abbreviated variable names are bad practice, but they are my fault 7 years ago when I was a younger programmer. can you add a TODO to make them not abbreviated? I don't want to make this PR any bigger itself.

@mayman99 mayman99 mentioned this pull request Jun 21, 2018
5 tasks
@mayman99 mayman99 force-pushed the gazebo_integration_trials branch 2 times, most recently from c385519 to 87f7177 Compare June 21, 2018 13:33
@mayman99
Copy link
Contributor Author

As suggested by @davecoleman this PR now does only deal with reading and writing the ros_controllers.yaml file.

moveit::core::RobotModelConstPtr robot_model;
};

TEST(MoveItConfigData, ReadingControllers)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test is still not completely implemented, I've a problem setting the robot_model in config_data. I've spend some time trying to figure out how to set it in the test, so for efficiency I thought I would ask for ideas here.

find_package(moveit_resources REQUIRED)
include_directories(${moveit_resources_INCLUDE_DIRS})

catkin_add_gtest(test_writting_ros_controllers test/moveit_config_data_test.cpp)
Copy link
Member

Choose a reason for hiding this comment

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

"writing" (misspelled)

@@ -459,107 +614,6 @@ std::vector<OMPLPlannerDescription> MoveItConfigData::getOMPLPlanners()
return planner_des;
}

// ******************************************************************************************
Copy link
Member

Choose a reason for hiding this comment

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

just curious - why move these files? it makes reviewing harder because i can't tell what has actually changed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry I didn't understand, which files?

Copy link
Member

Choose a reason for hiding this comment

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

oops i mean functions.... why move the functions to a different location in the file?

#include <boost/filesystem.hpp> // for creating folders/files
#include <moveit/setup_assistant/tools/moveit_config_data.h>

// #include <moveit/setup_assistant/src/widgets/controllers_widget.h>
Copy link
Member

Choose a reason for hiding this comment

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

remove


// #include <moveit/setup_assistant/src/widgets/controllers_widget.h>

// This tests adding FollowJointTrajectory controllers for each planning group to ros_controller.yaml
Copy link
Member

Choose a reason for hiding this comment

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

"This test adds..."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This tests adding FollowJointTrajectory controllers, isn't that Okay?


srdf_model.reset(new srdf::Model());
std::string xml_string;
std::fstream xml_file((res_path / "pr2_description/urdf/robot.xml").string().c_str(), std::fstream::in);
Copy link
Member

Choose a reason for hiding this comment

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

lets move away from using the PR2 but rather the Franka Emika robot instead. we might need to add Franka Emika into moveit_resources. @mlautman any opinions?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm strongly in favor of replacing the PR2 with the Panda wherever possible. @mohmadAyman a small side project that would be a huge improvement would be to add the Panda to moveit_resources so that it can be used in this test.

Copy link
Contributor Author

@mayman99 mayman99 Jun 27, 2018

Choose a reason for hiding this comment

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

Sure, will add it in a separate PR.

// Read ros_controllers.yaml
// config_data_->inputROSControllersYAML("ros_controllers.yaml");

// Verify that we read the file correctly
Copy link
Member

Choose a reason for hiding this comment

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

seems to be on the right track!

@mayman99 mayman99 changed the title Added a new screen for controllers Read and write ROS controllers yaml file Jun 27, 2018
// ******************************************************************************************
// Output kinematic config files
// ******************************************************************************************
bool MoveItConfigData::outputKinematicsYAML(const std::string& file_path)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davetcoleman
I didnt change anything in these functions, does git sees that as a diff because I've added the setRobotModel function above?

Copy link
Member

Choose a reason for hiding this comment

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

not sure what you mean 'diff'?

Choose a reason for hiding this comment

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

Looks like you moved them up in the file? I think this is why git sees this as a large diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry just saw the comment, I mean the difference that git saw.

@mayman99
Copy link
Contributor Author

mayman99 commented Jul 3, 2018

Ping @davetcoleman @mcevoyandy
are there any further comments concerning this PR?

void MoveItConfigData::setRobotModel(robot_model::RobotModelPtr robot_model)
{
robot_model_ = robot_model;
robot_model_const_ = robot_model;
Copy link
Member

Choose a reason for hiding this comment

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

just curious: do you know why i originally had to add a const and non-const version of robot_model? this is very hacky. shame on me (~6 years ago)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well the robot_model_const_ is only used in getRobotModel, while robot_model_ is used whenever we are to edit sth in the robot model.

We can remove robot_model_const_ and just const_cast the robot_model_ in the getRobotModel(), does that sound better?

// ******************************************************************************************
// Output kinematic config files
// ******************************************************************************************
bool MoveItConfigData::outputKinematicsYAML(const std::string& 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.

not sure what you mean 'diff'?

@davetcoleman
Copy link
Member

@mcevoyandy please review

@mcevoyandy
Copy link

@davetcoleman lgtm.

@davetcoleman davetcoleman merged commit c657650 into moveit:kinetic-devel Jul 9, 2018
@davetcoleman
Copy link
Member

Great job @mohmadAyman !!

@mayman99
Copy link
Contributor Author

mayman99 commented Jul 9, 2018

Thank you 😺

rhaschke pushed a commit that referenced this pull request Jul 17, 2018
dg-shadow pushed a commit to shadow-robot/moveit that referenced this pull request Jul 30, 2018
mayman99 added a commit to mayman99/moveit that referenced this pull request Aug 25, 2018
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.

4 participants