ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Moveit-PathPlanner giving strange trajectories? Here's one good fix!!

asked 2022-02-20 09:38:48 -0500

Prasanth Suresh gravatar image

Hi Guys,

I'm not here to ask a question but rather to answer an age-old one! I hope this helps someone because I was struggling with this problem for 3 years until I found this fix recently. If you're like me and don't like reading long posts, skip to the solution.

Problem description: I work with 2 manipulators - Sawyer and UR3e. Sawyer has 7 DOF and hence can generate hundreds of IK solutions for any given end-effector pose. UR3e has 6, however, the issue here is that all 6 are 360 deg joints and hence, the same problem. I need the robots to sort objects on a table and since the object locations are dynamic I get them using a 3D camera and CV techniques. Since the locations aren't fixed I need the planner(currently using RRTConnect, but tried almost every planner available) to find a path there and dip down straight, grasp the object and lift up straight! Thanks to Jeroen, we have a way to impose constraints along an axis and here's an example usage. However, the planner comes up with all sorts of weird unintuitive plans to move between simple straightforward locations and this used to mess up my sort by knocking off some objects on the table or failing to pick, etc (I do have accurate collision objects setup and this happens still!).

I've turned over every rock I could to find a fix, read several GitHub issue threads, tutorials, and forum posts but nothing helped. I switched to the enhanced IK solver - TRAC IK which helped to an extent with Sawyer's trajectories but not with UR. Restricting all the joint angles to (-180, +180) or (-270, +270) helped a bit with UR(This can also be done on the teach pendant, or here if you're on Gazebo). So how did I fix it you ask? Here it is:

THE SOLUTION:

  • Caveat:

    Since with UR, the robot is small, always above the table, and can't physically reach beyond 0.5m radius, this fix won't be a problem. Sawyer could run into issues because it's a long bulky manipulator, however, as long as you always start from above the table and make sure your coordinates are valid and above the table, you'll be fine.

Step 1: Switch back to the default KDL kinematics solver if you're using something else. This can be done here for UR3e. This helps because TRAC IK doesn't allow approximate IK solutions through code!

Step 2: I believe you'd be using something like this to send your eef coordinates to Moveit planner:

    group = self.group
    # Allow some leeway in position(meters) and orientation (radians)
    group.set_goal_position_tolerance(thresh)
    group.set_goal_orientation_tolerance(thresh)

    pose_goal = geometry_msgs.msg.Pose()
    pose_goal.orientation.x = ox
    pose_goal.orientation.y = oy
    pose_goal.orientation.z = oz
    pose_goal.orientation.w = ow
    pose_goal.position.x = px
    pose_goal.position.y = py
    pose_goal.position.z = pz
    group.set_pose_target(pose_goal)
    group.allow_replanning(allow_replanning ...
(more)
edit retag flag offensive close merge delete

Comments

I have been checking in "moveit::planning_interface::MoveGroup Class Reference" and there is no equivalent method to setPoseReferenceFrame for setJointValueTarget. Is there any way to change the reference frame of the commanded positions with your solution? I have been having problems for many months like the ones you describe in your post, and I have tried everything mentioned and more without success. I'm going to explore your solution, I hope it works. Thank you very much!

angcorcue2 gravatar image angcorcue2  ( 2023-05-23 02:20:36 -0500 )edit

@angcorcue2 I haven't tested this myself but setPoseReferenceFrame should still work for setJointValueTarget because both methods belong to this same class: http://docs.ros.org/en/jade/api/movei... and the setPoseReferenceFrame just sets a reference frame for all methods of this class to access. Let me know if the setJointValueTarget method works better for you! All the best.

Prasanth Suresh gravatar image Prasanth Suresh  ( 2023-05-23 13:50:05 -0500 )edit

@angcorcue2 The link I shared in the previous comment is for ROS Jade which has been deprecated, however, the class methods haven't changed wrt the ones we're talking about. Refer to:

https://moveit.picknik.ai/main/api/ht...

https://moveit.picknik.ai/main/api/ht...

Prasanth Suresh gravatar image Prasanth Suresh  ( 2023-05-23 13:55:35 -0500 )edit

2 Answers

Sort by » oldest newest most voted
0

answered 2022-09-22 14:06:36 -0500

Prasanth Suresh gravatar image

Hi @GG,

I think you missed a key point I mentioned in the above post. Sending a set of joint angles as the FK solution instead is a well known method. The beauty of the aforementioned solution is that you can send it 3D pose locations (x,y,z, q1,q2,q3,q4) like you would send to group.set_pose_goal() and the planner will plan in Joint-space/Configuration-space instead of Cartesian-space. This makes all the difference.

Coming to your problem, a simple fix for yours would be to just find few close enough points along the curve and send it to to set_joint_value_target(pose_goal) and run this within a loop, with each iteration executing one of those points.

This might still cause jerky motion and if it does, a slightly more sophisticated solution would be to find the mathematical equation of that curve and let that equation dictate the next waypoint based on the current start state along the way.

If this still doesn't work well, you can try using smoothing filters on top of your existing path planner. For instance, STOMP or CHOMP could be used as a smoothing filter over OMPL. Check out this link.

Hope that helps. :)

edit flag offensive delete link more
0

answered 2022-09-22 12:44:42 -0500

GG gravatar image

Hi, I'm glad that I found this "fix" faster ;-) but it's only the half way to the solution of my problem. So I ask the question after your answer:

I want the robot to follow a curved path, and as it is near a singularity all the way, I calculated waypoints with the above method. Now I can call go() or execute() for the next point, but this leads to a slow stop-go-stop-go movement instead of a smooth path. I would like to feed these joint positions into a path planner, ideally compute_cartesian_path(), to make this a faster motion. That seems to refuse the joint angle data .. somehow plausible, but not helpful - because the planner apparently doesn't care for the joint constraints I set up before. I could make the point spacing small enough so that linear interpolation between joint angles should be valid, but I don't see how to do it. How to make a trajectory out of a list of joint positions?

P.S. To add to your suggestion of using set_joint_value_target(): you may check the solution with get_joint_value_target(), figure out some fixes and send the modified joint angles back with another set_joint_value_target(), e.g. if you know for sure that that a certain joint should be 0.0 or if you need to find the "closest" of a 360° periodic solution (which may not be the one with the smallest value or within a 0..2pi range).

edit flag offensive delete link more

Comments

If you were using C++ (it sounds like you aren't), the TOTG time parameterization function can do smoothing. It's here:

https://github.com/ros-planning/movei...

AndyZe gravatar image AndyZe  ( 2022-09-22 15:43:43 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2022-02-20 09:38:48 -0500

Seen: 1,001 times

Last updated: Sep 22 '22