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

Memory Access Error

asked 2015-06-25 09:41:46 -0500

Carl gravatar image

updated 2015-06-25 10:53:12 -0500

Hi ROS community,

I just got my robot model running with the RVIZ-plugin, at least it follows the desired path. The planned path gets stored in the topic: /move_group/display_planned_path I wanted to sent the angles of that path to my real robot.

To get the data I wrote a Subscriber Node:

#include "ros/ros.h"
#include "moveit_msgs/DisplayTrajectory.h"
#include "moveit_msgs/RobotTrajectory.h"
#include "trajectory_msgs/JointTrajectory.h"
#include "std_msgs/String.h"
#include "std_msgs/Float32MultiArray.h"
#include <math.h>
#include <iostream>
#include <vector>

void chatterCallback(const moveit_msgs::DisplayTrajectory::ConstPtr& msg)
{

 ROS_INFO("I just got a new path.");

for(int i=0;i <= msg->trajectory[0].joint_trajectory.points.size();i++){
for(int k=0; k<=5; k++){

  float d= msg-> trajectory[0].joint_trajectory.points[i].positions[k]*360/2/M_PI;
  std::cout << d << " ";
}
}
}


int main(int argc, char **argv)
{

  ros::init(argc, argv, "path_listener");


  ros::NodeHandle n;


  ros::Subscriber sub = n.subscribe("/move_group/display_planned_path", 1000, chatterCallback);

  ros::spin();

  return 0;
}

Even if the code compiles successfully, i jot a memory issue.

The output in the shell (from the std::cout in the callback_function) sometimes only shows the first 1024 digits, anothertime it prints me 2048 on the screen. Sometimes it just prints me the Error "Speicherzugriffsfehler (Speicherabzug geschrieben)" on the screen without any angles. The Error Message means in english as much as "Memory Access Error (Worte Core Dump)".

Is that a permission issue or is that some kind of problem with my system? After running the node, I can still see the message data in the topic via "rostopic echo /move_group/display_planned_path", so the data is not deleted.

$ rosrun path_listener path_listener 
-22.34 -3.32329 40.8816 -4.43908 100.791 172.155 -19.454 -4.78194 43.2446 -8.87411 96.1687 166.409 -16.568 -6.2406 45.6075 -13.3091 91.5466 160.664 -13.6819 -7.69926 47.9704 -17.7442 86.9245 154.919 -10.7959 -9.15792 50.3334 -22.1792 82.3024 149.174 -7.90989 -10.6166 52.6963 -26.6142 77.6803 143.429 -5.02386 -12.0752 55.0593 -31.0492 73.0581 137.684 -2.13783 -13.5339 57.4222 -35.4843 68.436 131.938 0.748201 -14.9926 59.7851 -39.9193 63.8139 126.193 3.63423 -16.4512 62.1481 -44.3543 59.1918 120.448 6.52026 -17.9099 64.511 -48.7893 54.5697 114.703 9.40629 -19.3685 66.874 -53.2243 49.9476 108.958 12.2923 -20.8272 69.2369 -57.6594 45.3255 103.212 15.1783 -22.2858 71.5998 -62.0944 40.7033 97.4673 18.0644 -23.7445 73.9628 -66.5294 36.0812 91.7221 20.9504 -25.2032 76.3257 -70.9644 31.4591 85.9769 23.8364 -26.6618 78.6887 -75.3995 26.837 80.2317 26.7225 -28.1205 81.0516 -79.8345 22.2149 74.4865 29.6085 -29.5791 83.4145 -84.2695 17.5928 68.7414 32 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-06-25 10:35:08 -0500

mgruhler gravatar image

Is this all of the code?

If so, you definitely run into problems with accessing the vector the way you do. I suggest you familiarize yourself with the std::vector class of C++. You have an empty vector (i.e. without ANY elements) and try to access some element i and k.

This has nothing to do with ROS but is a general C++ issue.

edit flag offensive delete link more

Comments

I forgot to delete the Vector, that has nothing to do with my problem.

I'm going to post the output i get so far.

Carl gravatar image Carl  ( 2015-06-25 10:42:04 -0500 )edit

Question Tools

Stats

Asked: 2015-06-25 09:41:46 -0500

Seen: 884 times

Last updated: Jun 25 '15