Ask Your Question

ROS-i ABB Unable to access some members of industrial_msgs/CmdJointTrajectory

asked 2016-12-03 10:14:26 -0500

ninanona gravatar image

updated 2016-12-04 07:59:55 -0500

gvdhoorn gravatar image

Dear all,

I am basically trying to subscribe to the rostopic which broadcast the sensor_msgs/JointState and then call the /joint_path_command service to move the ABB robot in robot studio simulation. Hence, Whenever there is new joint positions in that topic, I will call /joint_path_command to mvoe the robot accordingly.

I have managed to receive the joint states from the rostopic. However, I have encountered problem when trying to create industrial_msgs/CmdJointTrajectory message which is required for the /joint_path_command service.

void chatterCallback(const sensor_msgs::JointState::ConstPtr &msg)
  for(int i = 0; i<msg->position.size(); i++)

  for(int i = 0; i<msg->velocity.size(); i++)

  for(int i = 0; i<6; i++)

  for(int i = 0; i<msg->effort.size(); i++)

  ros::NodeHandle n;
  ros::ServiceClient client = n.serviceClient<industrial_msgs::CmdJointTrajectory>("joint_path_command");
  industrial_msgs:CmdJointTrajectory srv;
  srv.request.trajectory.header = msg->header;
  srv.request.trajectory.joint_names = jointnames;
  srv.request.trajectory.points.positions = posi;
  srv.velocities = velo;
  srv.accelerations = acc;
  srv.effort = eff;

  //  srv.request.trajectory.points = srvvv;

  //  srv.time_from_start = ros::Time::now();


above is my program that tries to call the joint_path_command service with the information gathered from a sensor_msg/JointState msg.

Below is the compilation result

[100%] [100%] Built target add_two_ints_client
Built target add_two_ints_server
/home/colin/catkin_ws/src/armpost_listener/src/listen_armpost.cpp: In function 'void chatterCallback(const ConstPtr&)':
/home/colin/catkin_ws/src/armpost_listener/src/listen_armpost.cpp:66:33: error: 'trajectory_msgs::JointTrajectory_<std::allocator<void> >::_points_type' has no member named 'positions'

srv.request.trajectory.points.positions = posi;

/home/colin/catkin_ws/src/armpost_listener/src/listen_armpost.cpp:67:33: error: 'trajectory_msgs::JointTrajectory_<std::allocator<void> >::_points_type' has no member named 'velocities'

   srv.request.trajectory.points.velocities = velo;

/home/colin/catkin_ws/src/armpost_listener/src/listen_armpost.cpp:68:33: error: 'trajectory_msgs::JointTrajectory_<std::allocator<void> >::_points_type' has no member named 'accelerations'

   srv.request.trajectory.points.accelerations = acc;
/home/colin/catkin_ws/src/armpost_listener/src/listen_armpost.cpp:69:33: error: 'trajectory_msgs::JointTrajectory_<std::allocator<void> >::_points_type' has no member named 'effort'

   srv.request.trajectory.points.effort = eff;
make[2]: *** [armpost_listener/CMakeFiles/listen_armpost.dir/src/listen_armpost.cpp.o] Error 1

make[1]: *** [armpost_listener/CMakeFiles/listen_armpost.dir/all] Error 2

make: *** [all] Error 2

Invoking "make -j8 -l8" failed

As you can see, The compiler does not recognize the members of the points struct within trajectory/points (positions, velocities, effort, accelerations) of the industrial_msgs/CmdJointTrajectory when it is clearly stated in the rossrv show(shown below)

colin@Colin-GF:~$ rossrv show industrial_msgs/CmdJointTrajectory
trajectory_msgs/JointTrajectory trajectory
  std_msgs/Header header
    uint32 seq
    time stamp
    string frame_id
  string[] joint_names
  trajectory_msgs/JointTrajectoryPoint[] points
    float64[] positions
    float64[] velocities
    float64[] accelerations
    float64[] effort
    duration time_from_start
industrial_msgs/ServiceReturnCode code
  int8 SUCCESS=1
  int8 FAILURE=-1
  int8 val

Am I doing something wrong? Any help will be greatly appreciated!

Thank you!

edit retag flag offensive close merge delete


Just curious: what are you trying to achieve exactly? The code you include above seems to be sending the robot back to where it already is (ie: setpoint == current_state).

gvdhoorn gravatar image gvdhoorn  ( 2016-12-04 08:00:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-12-03 15:57:10 -0500

jsanch2s gravatar image

updated 2016-12-03 16:00:00 -0500

points in srv.request.trajectory.points is an array as you correctly note in your question. Thus, you should access its elements in order to access their members (e.g. positions, velocities and accelerations). Instead of




where i is the joint you want to specify.

You might also benefit from this answer.

edit flag offensive delete link more



Thank you so much! I didn't realise the point array meant the trajectory points. It solved my problem!

ninanona gravatar image ninanona  ( 2016-12-03 23:01:05 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-12-03 10:14:26 -0500

Seen: 227 times

Last updated: Dec 04 '16