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

Use fake_components::GenericSystem from ros2_control #361

Merged
merged 11 commits into from
Mar 25, 2021

Conversation

JafarAbdi
Copy link
Member

@JafarAbdi JafarAbdi commented Feb 9, 2021

Description

Depends on ros-controls/ros2_control#323 (merged)

Allows us to stop using the fake_joint package

Checklist

  • Update servo to use the FakeSystem

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

Awesome, that means we can drop fake_joint from the .repos file, right?

@@ -28,8 +30,10 @@ def load_yaml(package_name, file_path):
def generate_launch_description():

# planning_context
robot_description_config = load_file('moveit_resources_panda_description', 'urdf/panda.urdf')
robot_description = {'robot_description' : robot_description_config}
robot_description_config = xacro.process_file(os.path.join(get_package_share_directory('run_moveit_cpp'),
Copy link
Member

Choose a reason for hiding this comment

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

What does this do differently?

@@ -0,0 +1,56 @@
<?xml version="1.0"?>
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, is this required for simulated robots and could this be generated from inline tags in the description?

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is required by all robots running on ros2_control. The generation for a robot is not so simple. This has to be actually provided with the robot's driver.

You could generate some general descriptions from the joints in URDF and assume they all have can receive position commands and provide position feedback. I have already some templates for this. This will work perfectly with the MoveIt --> Joint Trajectory Controller --> Fake System. Nevertheless, when using real hardware those interfaces have to correspond to the driver.

If you have any questions regarding the new ros2_control Architecture or FakeRobot (the same as the FakeSystem) just ping me :)

<xacro:include filename="panda.ros2_control.xacro" />
<xacro:include filename="panda_hand.ros2_control.xacro" />

<xacro:panda_ros2_control name="PandaFakeSystem" />
Copy link
Member

Choose a reason for hiding this comment

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

So, I assume this is optional... What happens when you want to run the driver? Adding face controller parameters to the description somehow feels strange

Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest injecting either the fake system of the non-fake one in the launch file or via a xacro argument, they should be considered mutually exclusive

@codecov
Copy link

codecov bot commented Feb 9, 2021

Codecov Report

Merging #361 (e40a3ef) into main (c9c61a6) will increase coverage by 0.06%.
The diff coverage is n/a.

❗ Current head e40a3ef differs from pull request most recent head de7bc90. Consider uploading reports for the commit de7bc90 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #361      +/-   ##
==========================================
+ Coverage   53.32%   53.38%   +0.06%     
==========================================
  Files         210      210              
  Lines       18814    18814              
==========================================
+ Hits        10031    10042      +11     
+ Misses       8783     8772      -11     
Impacted Files Coverage Δ
moveit_ros/moveit_servo/src/servo_calcs.cpp 80.13% <0.00%> (+0.62%) ⬆️
moveit_ros/moveit_servo/src/pose_tracking.cpp 75.17% <0.00%> (+0.66%) ⬆️
...meterization/work_space/pose_model_state_space.cpp 84.56% <0.00%> (+1.48%) ⬆️
moveit_ros/moveit_servo/src/collision_check.cpp 76.12% <0.00%> (+1.50%) ⬆️
..._core/collision_detection/src/collision_common.cpp 100.00% <0.00%> (+57.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c9c61a6...de7bc90. Read the comment docs.

Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

I'm not sure I like this. The beauty of fake_joint_driver is it launches exactly like the real hardware driver.

Notice, lines of code went up by 120. That's not a good sign.

@AndyZe
Copy link
Member

AndyZe commented Feb 10, 2021

Meh, I guess I'm OK with it. The panda_hand.ros2_control.xacro will need to get added for the hardware robot, anyway. That's where most of the new lines of code come from.

@destogl
Copy link
Contributor

destogl commented Feb 11, 2021

Notice, lines of code went up by 120. That's not a good sign.

The lines are mostly YAML and xacro files, as you mentioned. They are needed anyway for the ros2_control. So there is no additional lines compared to the hardware.

Why @JafarAbdi added some things I am also not sure. I'll provide the FakeRobot example in the ros2_control_demo repository, so you can compare it to the "real" hardware.

load_joint_state_controller = ExecuteProcess(cmd=['ros2 control load_start_controller joint_state_controller'], shell=True, output='screen')
load_controllers = [load_joint_state_controller]
# load panda_arm_controller
load_controllers += [ExecuteProcess(cmd=['ros2 control load_configure_controller panda_arm_controller'],
Copy link
Member Author

Choose a reason for hiding this comment

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

Should be removed once ros-controls/ros2_control#310 is merged

@JafarAbdi
Copy link
Member Author

Rebase on master

@JafarAbdi
Copy link
Member Author

I moved the config files to panda_moveit_config, moveit/moveit_resources#51 should be merged first

@JafarAbdi
Copy link
Member Author

Why @JafarAbdi added some things I am also not sure.

Could you please mention them in a review?

Copy link
Member

@AndyZe AndyZe left a comment

Choose a reason for hiding this comment

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

I think this change in Servo publish_fake_jog_commands.cpp would fix the timestamp issue:

  Time pub_period(0, 50 /* ms */);
  auto callback = [captured_pub, captured_node]() -> void {
    auto pub_ptr = captured_pub.lock();
    auto node_ptr = captured_node.lock();
    if (!pub_ptr || !node_ptr)
    {
      return;
    }
    auto msg = std::make_unique<geometry_msgs::msg::TwistStamped>();
    msg->header.stamp = node_ptr->now() + pub_period;
    msg->header.frame_id = "panda_link0";
    msg->twist.linear.x = 0.3;
    msg->twist.angular.z = 0.5;
    pub_ptr->publish(std::move(msg));
  };
  auto timer = node->create_wall_timer(pub_period, callback);

I don't really know how time works in ROS2 yet. That syntax is prob wrong

Copy link
Contributor

@destogl destogl left a comment

Choose a reason for hiding this comment

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

I suggest a few changes here. It is confusing for me to have so many copy-pasted launch files. This makes this really hard to maintain. Would be possible to add repetitive code in an import file?

ros2_control_node = Node(
package='controller_manager',
executable='ros2_control_node',
parameters=[robot_description, os.path.join(get_package_share_directory("moveit_resources_panda_moveit_config"), "config", "panda_ros_controllers.yaml")],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use controllers_yaml variable? What is difference between panda_controller.yaml and panda_ros_controllers.yaml?

Also, it is cleaner if the path is joint in a variable that is then used as a parameter.

Copy link
Member Author

Choose a reason for hiding this comment

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

panda_ros_controllers.yaml is the config file for ros2_controllers whereas panda_controller.yaml is used to configure moveit simple controller which is what MoveIt use to execute its trajectories by sending them to ros2_control trajectory controller

@@ -46,7 +50,7 @@ def generate_launch_description():
ompl_planning_pipeline_config['move_group'].update(ompl_planning_yaml)

# Trajectory Execution Functionality
controllers_yaml = load_yaml('run_move_group', 'config/controllers.yaml')
controllers_yaml = load_yaml('moveit_resources_panda_moveit_config', 'config/panda_controllers.yaml')
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is something MoveIt related, why not call it panda_moveit_controllers.yaml? People could misunderstand this as something ros2_control related. (This is maybe just my ros2_control background, I don't know.....)

Copy link
Member Author

@JafarAbdi JafarAbdi Mar 8, 2021

Choose a reason for hiding this comment

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

I agree with you, I'll rename it to panda_moveit_simple_controllers

@JafarAbdi JafarAbdi force-pushed the pr-ros2_control_fake_system branch from 54a89cb to b336039 Compare March 8, 2021 17:46
@JafarAbdi
Copy link
Member Author

rebase on the main branch

@JafarAbdi JafarAbdi force-pushed the pr-ros2_control_fake_system branch 3 times, most recently from d29fd81 to deece60 Compare March 20, 2021 00:54
Copy link
Contributor

@destogl destogl left a comment

Choose a reason for hiding this comment

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

Besides one comment probably resulting from my lack of understanding of the MoveIt code, everything looks very good!

Happy to see you are following ros2_control and ros2_controllers master branches :)

controllers_yaml = load_yaml('run_moveit_cpp', 'config/fake_controllers.yaml')
fake_controller = {'moveit_fake_controller_manager': controllers_yaml,
moveit_simple_controllers_yaml = load_yaml('moveit_resources_panda_moveit_config', 'config/fake_controllers.yaml')
fake_controller = {'moveit_fake_controller_manager': moveit_simple_controllers_yaml,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need CM in MoveIt? Since you are starting ros2_control with the fake hardware I am not sure what is the purpose of this. I am probably missing something....

@AndyZe
Copy link
Member

AndyZe commented Mar 23, 2021

The MoveIt cpp demo currently fails for me, any ideas?

ros2 launch run_moveit_cpp run_moveit_cpp.launch.py

`future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:271> exception=SubstitutionFailure("package 'run_moveit_cpp' found at '/home/andy/ws_schilling/install/run_moveit_cpp', but libexec directory '/home/andy/ws_schilling/install/run_moveit_cpp/lib/run_moveit_cpp' does not exist")>

@JafarAbdi
Copy link
Member Author

The MoveIt cpp demo currently fails for me, any ideas?

ros2 launch run_moveit_cpp run_moveit_cpp.launch.py

`future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/foxy/lib/python3.8/site-packages/launch/launch_service.py:271> exception=SubstitutionFailure("package 'run_moveit_cpp' found at '/home/andy/ws_schilling/install/run_moveit_cpp', but libexec directory '/home/andy/ws_schilling/install/run_moveit_cpp/lib/run_moveit_cpp' does not exist")>

Replace this line with RUNTIME DESTINATION lib/${PROJECT_NAME}

@AndyZe
Copy link
Member

AndyZe commented Mar 23, 2021

I think something is missing with the Servo demo

ros2 launch moveit_servo servo_cpp_interface_demo.launch.py

List controllers like this:

ros2 control list_controllers

Shows that the joint trajectory controller isn't active:

panda_arm_controller[joint_trajectory_controller/JointTrajectoryController] finalized

Copy link
Member

@henningkayser henningkayser left a comment

Choose a reason for hiding this comment

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

Great improvement, all demos are working great for me now. @AndyZe's issue also seems resolved. I just pushed a minor fix to the destination path for run_ompl_constrained_planning. I actually wasn't aware that bin has been exposing all executables globally when doing a symlink install (did anything change there?). We should do a repo-wide refactoring for all runtime destinations.

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.

Switch moveit2 to use ros2_control debian Use new ros2_control interfaces
5 participants