# Draw a circle with a robotic arm?

I believe the technical term for this would be "arm navigation planning with hard dynamic geometric constraints". But my question would be how can I implement trajectory planning of a circle or similar geometric path with a robotic arm?

Using a series of concentrated waypoints in the arm navigation would be one way I would guess. But slow to compute and carry out?

To want to draw a circle or other geometric object with a robotic arm seems fairly fundamental, yet it actually appears to be quite complicated.

Any advice?

Originally posted by Jeremy Corbett on ROS Answers with karma: 397 on 2012-08-01

Post score: 2

### Original comments

Comment by martimorta on 2012-08-02:
I don't work with arms but I suppose you can set something similar to a nav_msgs/Path sampling your trajectory.

## 3 Answers

Look at the ROS Scan and Plane application from ROS-Industrial. you can use the Descartes planner for that.

Here is a link to the ROS-Industrial training examples. I just took the training and I made a UR-5 Arm follow a complex trajectory. Getting the robot to move in a circle will be very easy to do. You need to feed the Descartes planner a list of trajectory points for your circle and it will take care of the rest.

http://aeswiki.datasys.swri.edu/rositraining/indigo/Exercises/

Review Session 4 and then do Application Demo - Descartes Planning and Execution

that will get you want you need.

Originally posted by Shawn Schaerer with karma: 106 on 2015-11-26

This answer was ACCEPTED on the original site

Post score: 2

Pretty much all the code I'm aware of that Willow Garage has produced in the arm navigation space is focused on getting the arm from Point A to Point B, generally in order to perform a manipulation operation. We allow users to impose constraints on the path - keep the end effector upright, for instance - but the path constraints are still designed to condition the path from point A to point B, not change the purpose of the planner.

Having the end effector follow a shape is a different kind of planning problem, one where the purpose is the path, not moving from one point to another, and we really don't have much code for such things. Coverage algorithm - for instance, plan a path that would paint an irregular surface as quickly as possible - are other examples of areas Willow Garage hasn't really focused on. There may be other code in the larger ROS landscape that does such things, but I'm not aware of it.

If I were to attempt to address such problems I'd look at the literature and try a few things out, using some of the lower-level tools from arm_navigation, like collision-checking and inverse kinematics. An approach that might work ok for attempting a geometric path would be to discretize the shape into a series of end effector positions, call IK for each one, and try to interpolate between the poses, making sure that the arm didn't hit joint limits or singularities. This might not give a great path, but could get the job done.

I suspect that general code that would do for coverage/path-focused problems what arm_navigation does for Point to Point travel would be a protracted research/tech-transfer project.

Originally posted by egiljones with karma: 2031 on 2012-08-02

This answer was NOT ACCEPTED on the original site

Post score: 4

I use the waypoints by following this Tutorial http://docs.ros.org/indigo/api/pr2_moveit_tutorials/html/planning/src/doc/move_group_interface_tutorial.html#cartesian-paths

Note that, you can specify the the interpotion resolution between two consecutive waypoints. Here is my implementation

  //2. Create Cartesian Paths
std::vector<geometry_msgs::Pose> waypoints;
geometry_msgs::Pose ee_point_goal; //end_effector_trajectory
ee_point_goal.orientation.w = 1.0;
ee_point_goal.position.z = 0.8;
// Trajectory parameters (circle)
double d_angle = angle_resolution*3.14/180;
double angle= 0;

//----------------------------------------------------------------------
//3. Plan for the trajectory
for (int i= 0; i< (360/angle_resolution); i++)
{
//discretize the trajectory
angle+= d_angle;
ee_point_goal.position.x = x_center + radius*cos(angle);
ee_point_goal.position.y = y_center + radius*sin(angle);
waypoints.push_back(ee_point_goal);
//ROS_INFO("%d",i);
}

ROS_INFO("There are %d number of waypoints", waypoints.size());
// We want cartesian path to be interpolated at a eef_resolution
double eef_resolution = std::min(0.01,radius*angle_resolution);
double jump_threshold = 0.0; //disable the jump threshold =0
moveit_msgs::RobotTrajectory trajectory;
double fraction =plan_group.computeCartesianPath(waypoints, eef_resolution,jump_threshold, trajectory);

ROS_INFO("Visualizing plan 4 (cartesian path) (%.2f%% acheived)",  fraction * 100.0);


Originally posted by Chuong Nguyen with karma: 136 on 2015-11-19

This answer was NOT ACCEPTED on the original site

Post score: 1

### Original comments

Comment by Fredylucas on 2015-11-27:
Hi! I'm following this tutorial you have shared (it looks really helpful), but, the robot only plans the trajectory, it doesn't execute the trajectory, how can I execute it? Usually I use group.move() for moving my robot, but in this case, it doesn't work.

Comment by Chuong Nguyen on 2015-11-27:
You can add the following code to make it move. Hope this help

moveit::planning_interface::MoveGroup::Plan my_plan;
my_plan.trajectory_ = trajectory;
sleep(5.0);
plan_group.execute(my_plan);


Comment by Fredylucas on 2015-11-30:
Thank you very much, indeed it moves; nevertheless, it is very slow.

Comment by WuJeff on 2016-05-06:
what's the"angle_resolution"mean ,where is its definition?@Freaylucas

Comment by Fredylucas on 2016-05-06:
That is just a constant you set, it means the resolution in degrees you want for the rotational movement; d_angle is the same but in radians. I.e, in this way you set the number of points you want for interpolating your trajectory.

Comment by WuJeff on 2016-05-14:
@Fredylucas It's just move the first waypoints,not a circle,how to do ?