seg fault with points[0]
this line gives me a seg fault: graspdata.pregraspposture_.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 manipulationmsgs::Grasp to moveitmsgs::Grasp.
here is the struct of graspdata 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 moveitmsgs::Grasp because pick place needs it in hydro as opposed to groovy which uses manipulationmsgs(moveit/movegroupinterface/movegroup.h), therefore i have changed sensormsgs to trajectory_msgs.
i am using:
ros hydro
kubuntu 12.04 precise
Asked by jay75 on 2014-01-20 17:18:13 UTC
Answers
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...
Asked by Wolf on 2014-01-20 20:02:52 UTC
Comments
You're welcome. Please accept the answer, if it helped you , so people can find it easily in the future..... thank you
Asked by Wolf on 2014-01-21 20:31:12 UTC
thanks wolf, i added the following line and it worked. grasp_data_.pre_grasp_posture_.points.resize(1);
Asked by jay75 on 2014-01-21 04:43:12 UTC
Comments
Must be something to do with the memory resource management.
Asked by alfa_80 on 2014-01-20 18:10:59 UTC
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.
Asked by bchr on 2014-01-20 23:57:56 UTC