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

Kydo2's profile - activity

2013-01-30 11:16:10 -0500 received badge  Famous Question (source)
2012-10-12 01:53:14 -0500 received badge  Popular Question (source)
2012-10-12 01:53:14 -0500 received badge  Notable Question (source)
2012-06-09 09:27:21 -0500 asked a question <nao_msgs::JointAngleTrajectory> segmentation fault nao

Hi, I'm trying to subscribe and publish nao's left or right arm, to move them. In my program in c++ I can move the head and walk with choregraphe, so I'm doing well the publish and subscribe messages with them, but I don't know ho to publish and subscribe with <nao_msgs::jointangletrajectory>. I have more or less the next code:

//Movimientos de brazo izquierdo
nao_msgs::JointAngleTrajectory leftArmSubspublico;  

//Método para coger del subscriber los valores del brazo izquierdo
void leftArmSubscriber(const boost::shared_ptr<nao_msgs::JointAngleTrajectory const>& msg)
{   

    nao_msgs::JointAngleTrajectory leftArmSubs;

    leftArmSubs.joint_names = msg->joint_names;
    leftArmSubs.joint_angles = msg->joint_angles;
    leftArmSubs.times = msg->times; 

    leftArmSubspublico = leftArmSubs;




}

//Estado actual brazoIzquierdo
nao_msgs::JointAngleTrajectory estadoActualLeftArm;

......................... more code .........................

  //Para advertir a ros que vamos a publicar en el topic para mover el brazo izquierdo  
  ros::Publisher leftArm_pub = n.advertise<nao_msgs::JointAngleTrajectory>("joint_angle_trajectory",1000);

  //Para subscribirnos al brazo izquierdo del robot
  ros::Subscriber leftArm_sub = n.subscribe<nao_msgs::JointAngleTrajectory>("joint_angle_trajectory", 1000, leftArmSubscriber);



string nombreJunta = leftArmSubspublico.joint_names[0];
                cout<< nombreJunta;

When I comment the last line and I do rosmake, the program is built properly, and I can move nao's legs and head. But when I have the last line uncomment I do rosmake, I get: segmentation fault

I think I don't know how to acces to the information properly.

Thank you!