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

when I use descartes to move a specf cartesian path ,I found that the robot trajectory will cause collision to the environment #256

Open
dbdxnuliba opened this issue Aug 4, 2021 · 1 comment

Comments

@dbdxnuliba
Copy link

image

I has list part of the code of application :

int main(int argc,char** argv)
{
ros::init(argc,argv,"plan_and_run");
ros::AsyncSpinner spinner(2);
spinner.start();
moveit::planning_interface::PlanningSceneInterface scene;

// creating application
plan_and_run::DemoApplication application;

// loading parameters
application.loadParameters();
application.loadEnv(scene);

// initializing ros components
application.initRos();

// initializing descartes
application.initDescartes();

// moving to home position
application.moveHome();

// generating trajectory
plan_and_run::DescartesTrajectory traj;
application.generateTrajectory(traj);

// planning robot path
plan_and_run::DescartesTrajectory output_path;
application.planPath(traj,output_path);

// running robot path
application.runPath(output_path);

// exiting ros node
spinner.stop();

return 0;
}

void DemoApplication::initDescartes()
{
robot_model_ptr_.reset(new ur3_demo_descartes::UR3RobotModel());

// //Enable collision checking
robot_model_ptr_->setCheckCollisions(true);

if(robot_model_ptr_->initialize(ROBOT_DESCRIPTION_PARAM,
config_.group_name,
config_.world_frame,
config_.tip_link))
{
ROS_INFO_STREAM("Descartes Robot Model initialized");
}
else
{
ROS_ERROR_STREAM("Failed to initialize Robot Model");
exit(-1);
}

bool succeeded = planner_.initialize(robot_model_ptr_);
if(succeeded)
{
ROS_INFO_STREAM("Descartes Dense Planner initialized");
}
else
{
ROS_ERROR_STREAM("Failed to initialize Dense Planner");
exit(-1);
}

ROS_INFO_STREAM("Task '"<<FUNCTION<<"' completed");
}

}

void DemoApplication::loadEnv(moveit::planning_interface::PlanningSceneInterface& scene)
{
ros::NodeHandle pnh("~");

moveit::planning_interface::MoveGroupInterface move_group(config_.group_name);

std::vector<moveit_msgs::CollisionObject> objects;
 double high = 0.1;

moveit_msgs::CollisionObject obj;
obj.operation = obj.ADD;
obj.id = "box";
std::string frame_id = move_group.getPlanningFrame();
shape_msgs::SolidPrimitive shape;
shape.type = shape.BOX;
shape.dimensions.push_back(0.3);
shape.dimensions.push_back(0.3);
shape.dimensions.push_back(high);
obj.primitives.push_back(shape);
geometry_msgs::Pose pose;
pose.position.x = 0.3;
pose.position.y = 0;

//pose.position.z = -high / 2.0;
pose.position.z = 0.2;

tf::Quaternion quat;
quat.setRPY(deg2rad(0), deg2rad(0), deg2rad(0));
pose.orientation.x = quat.x();
pose.orientation.y = quat.y();
pose.orientation.z = quat.z();
pose.orientation.w = quat.w();
obj.primitive_poses.push_back(pose);

objects.push_back(obj);

std::vector<moveit_msgs::ObjectColor> colors;
moveit_msgs::ObjectColor color;
color.id = "box";
// [0,255] int, float32 [0, 1]
color.color.r = 0;
color.color.g = 255 / 255.0;
color.color.b = 0;
color.color.a = 1;
colors.push_back(color);

scene.applyCollisionObjects(objects, colors);

ROS_INFO_STREAM("Task '"<<FUNCTION<<"' completed");

}

@dbdxnuliba
Copy link
Author

I sincerely look forward to your reply

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

No branches or pull requests

1 participant