Ask Your Question
0

seg fault with points[0] [closed]

asked 2014-01-20 16:18:13 -0600

jay75 gravatar image

updated 2014-01-21 00:30:54 -0600

dornhege gravatar image

this line gives me a seg fault: grasp_data_.pre_grasp_posture_.points[0].positions.resize(1);

is there any solution for this?

it is being caused by points[0]. i know this because it happened another time when i was trying to convert manipulation_msgs::Grasp to moveit_msgs::Grasp.

here is the struct of grasp_data_ as used by dave coleman's clam arm:

namespace block_grasp_generator
{

struct RobotGraspData
{

RobotGraspData() :

    // Fill in default values where possible:
    base_link_("/base_link"), 
    grasp_depth_(0.12), 
    angle_resolution_(16),
    approach_retreat_desired_dist_(0.6),
    approach_retreat_min_dist_(0.4),
    block_size_(0.04)
  {}

  //sensor_msgs::JointState pre_grasp_posture_;

  //sensor_msgs::JointState grasp_posture_;

  trajectory_msgs::JointTrajectory pre_grasp_posture_;

  trajectory_msgs::JointTrajectory grasp_posture_;

  std::string base_link_; // name of global frame with z pointing up

  std::string ee_parent_link_; // the last link in the kinematic chain before the end effector, e.g. "/gripper_roll_link"

  double grasp_depth_; // distance from center point of object to end effector

  int angle_resolution_; // generate grasps at PI/angle_resolution increments

  double approach_retreat_desired_dist_; // how far back from the grasp position the pregrasp phase should be

  double approach_retreat_min_dist_; // how far back from the grasp position the pregrasp phase should be at minimum
  double block_size_; // for visualization

};


block_grasp_generator::RobotGraspData grasp_data_;

i have to use moveit_msgs::Grasp because pick place needs it in hydro as opposed to groovy which uses manipulation_msgs(moveit/move_group_interface/move_group.h), therefore i have changed sensor_msgs to trajectory_msgs.

i am using:

ros hydro

kubuntu 12.04 precise

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by jay75
close date 2014-01-21 03:43:55

Comments

Must be something to do with the memory resource management.

alfa_80 gravatar imagealfa_80 ( 2014-01-20 17:10:59 -0600 )edit

If you compile in debug and use GDB, you will be able to see what's in your memory when it crashes. This should tell you what you did wrong.

bchr gravatar imagebchr ( 2014-01-20 22:57:56 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-01-20 19:02:52 -0600

Wolf gravatar image

With std::vector this typically happens if you try to access the vector beyond its end. Have you checked grasp_data_.pre_grasp_posture_.points.size() to be non-zero before accessing grasp_data_.pre_grasp_posture_.points[0]?

In some cases you can also use the std::vector<T>::iterator rather than element access operator[0] to avoid seg fault...

edit flag offensive delete link more

Comments

You're welcome. Please accept the answer, if it helped you , so people can find it easily in the future..... thank you

Wolf gravatar imageWolf ( 2014-01-21 19:31:12 -0600 )edit
0

answered 2014-01-21 03:43:12 -0600

jay75 gravatar image

thanks wolf, i added the following line and it worked. grasp_data_.pre_grasp_posture_.points.resize(1);

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-01-20 16:18:13 -0600

Seen: 104 times

Last updated: Jan 21 '14