Rosanswers logo

I am using ROS-Indigo on Ubunu 14.04. While using MoveIt! with ros-controllers I wanted to capture the data published on coro/coro_arm_controller/state topic. However while the acceleration and effort fields, segmentation fault error is coming. Below is my code. Can anyone suggest me on what to do next ??

#include "ros/ros.h"
#include <control_msgs/JointTrajectoryControllerState.h>
#include <trajectory_msgs/JointTrajectoryPoint.h>
#include <vector>

using namespace std;

void callback(const control_msgs::JointTrajectoryControllerState& traj)
{ trajectory_msgs::JointTrajectoryPoint desired, actual, error_;
  ros::Duration t; 
  for(int j=0; j<traj.joint_names.size();++j)
      // Desired


    //   error_.effort.push_back(traj.error.effort[j]);
     for(int i= 0; i< traj.joint_names.size();++i) 
  ROS_INFO_STREAM( "position  for joint["<< i << "] :"  << desired.positions[i]);
  ROS_INFO_STREAM( "velocity  for joint["<< i << "] :"  << desired.velocities[i]);
  ROS_INFO_STREAM( "acceleration  for joint["<< i << "] :"  << desired.accelerations[i]);
  ROS_INFO_STREAM( "effort for joint["<< i << "] :"  << desired.effort[i]);
  ROS_INFO_STREAM( "time is :"  << t << "\n");

int main(int argc, char **argv)
   ros::init (argc, argv, "trajectory");
   ros::NodeHandle n;
   ros::Subscriber sub = n.subscribe("/zuti_bot/zuti_bot_arm_controller/state", 1000, callback);
    return 0;


After many iterations I found that there is some problem while capturing the acceleration and effort value of the joints.

Originally posted by Pulkit123 on ROS Answers with karma: 171 on 2018-03-23

Post score: 1


1 Answer 1


Rosanswers logo

Have you made sure the accelerations and efforts fields are actually populated?

Note in the documentation for trajectory_msgs/JointTrajectoryPoint:

# Each trajectory point specifies either positions[, velocities[, accelerations]]
# or positions[, effort] for the trajectory to be executed.

The [] in [, velocities[, accelerations]] and [, effort] indicate that these are optional. Not all implementations may populate those fields.

Originally posted by gvdhoorn with karma: 86574 on 2018-03-23

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by Pulkit123 on 2018-03-23:
Actually I am giving trajectory through MoveIt! and capturing the controller_state data. I checked using rostopic echo and found that the acceleration and effort fields are not populated by default for actual and error parts. So how to rectify this ??

Comment by gvdhoorn on 2018-03-23:
I would suggest to check that (for instance) actual.efforts.size() > 0.

Comment by Pulkit123 on 2018-03-23:
I checked it, actually the acceleration ad effort fields of actual and error parts of control_msgs::JointTrajectoryControllerState are never been filled by default. That's why it is giving segmentation fault. However only the effort field of desired part is not populated by default.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.