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

base operand of '->' has non-pointer type 'const JointState'

asked 2015-02-18 05:31:54 -0600

215 gravatar image

updated 2015-02-18 05:33:08 -0600

Hi guys.. I am trying to write a simple publisher and subscriber, but having some problems with my subscriber...

The message type i am using is sensor_msgs::JointState msg (doc) for my subscriber i have this callback function.

void ChatterCallback(const sensor_msgs::JointState& msg){
  ROS_INFO("i've heard: " ,msg->position);
}

but somehow i end up getting this error message saying

error: base operand of '->' has non-pointer type 'const JointState'

which just doesn't make sense for me..

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2015-02-18 06:43:45 -0600

215 gravatar image

updated 2015-03-19 12:19:02 -0600

I found the error.

    void ChatterCallback(const sensor_msgs::JointState::ConstPtr& msg)
{
      ROS_INFO("i've heard: [%f]" ,msg->position[0]);
    }
edit flag offensive delete link more
3

answered 2015-02-18 06:37:08 -0600

gvdhoorn gravatar image

updated 2015-02-18 06:39:15 -0600

This is more a C++ issue: the error is telling you that the variable msg is not a pointer. And it isn't: it's a reference to a JointState object.

Edit: so replace the -> with a . (dot).

Note: you can't directly pass the position member to ROS_INFO(..) though. Unlike Python, C++ doesn't have auto-conversions to strings.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-18 05:31:54 -0600

Seen: 2,880 times

Last updated: Mar 19 '15