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

expected primary-expression before ‘*’ token

asked 2017-03-02 05:09:02 -0600

user_123 gravatar image

updated 2017-03-02 06:11:14 -0600

I have written a code that converts a std::string in sensor_msgs::Laserscan::constPtr structure. The code is given below:

std::vector<char> scan_vectr;
  boost::system::error_code ignored_error;
  std::size_t lens=tcp_socket.read_some(boost::asio::buffer(scan_vectr),ignored_error);
  std::string scan_str(scan_vectr.begin(),scan_vectr.end());

  //Deserialize the std::string in sensor_msgs::LaserScan structure
  std::size_t serial_size = scan_str.size();
  boost::shared_array<uint8_t> buffer(new uint8_t[serial_size]);
  for (std::size_t i = 0; i < serial_size; ++i)

  {
    buffer[i] = scan_str[i];
  }
  ros::serialization::IStream stream(buffer.get(), serial_size);
  const sensor_msgs::LaserScan::ConstPtr scan;
  ros::serialization::Serializer<const sensor_msgs::LaserScan>::read(stream,sensor_msgs::LaserScan::ConstPtr *scan);

In the last line of the code, I am getting this error...

/opt/ros/indigo/include/ros/serialization.h: In instantiation of ‘static void ros::serialization::Serializer<T>::read(Stream&, typename boost::call_traits<T>::reference) [with Stream = ros::serialization::IStream; T = const sensor_msgs::LaserScan_<std::allocator<void> >; typename boost::call_traits<T>::reference = const sensor_msgs::LaserScan_<std::allocator<void> >&]’:
/home/collab/catkin_ws/src/slam_gmapping/gmapping_server/src/slam_gmapping.cpp:315:82:   required from here
/opt/ros/indigo/include/ros/serialization.h:136:5: error: ‘const struct sensor_msgs::LaserScan_<std::allocator<void> >’ has no member named ‘deserialize’
     t.deserialize(stream.getData());
 ^

I don't know how to handle it, please someone help me to get rid of this error. Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-03-02 06:05:26 -0600

gvdhoorn gravatar image

This is a C++ problem more than anything else: you can only pass variables to functions, nothing else. Your current line:

ros::serialization::Serializer<const sensor_msgs::LaserScan>::read(stream,sensor_msgs::LaserScan::ConstPtr *scan);

is passing sensor_msgs::LaserScan::ConstPtr *scan to read(..). sensor_msgs::LaserScan::ConstPtr *scan is not valid C++: it's a variable declaration inside a call to a function.

If you just want to pass scan itself, you should remove sensor_msgs::LaserScan::ConstPtr from that line.

edit flag offensive delete link more

Comments

After removing sensor_msgs::LaserScan::ConstPtr I am getting a new set of error edited in the question. Please check and help me.

user_123 gravatar image user_123  ( 2017-03-02 06:12:04 -0600 )edit

You'll need to make sure you're passing the correct variables to the functions that you're calling. This is not ROS-specific, but basic C++. Unfortunately I won't have the time to debug your code with you.

gvdhoorn gravatar image gvdhoorn  ( 2017-03-02 06:15:44 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-02 05:09:02 -0600

Seen: 2,944 times

Last updated: Mar 02 '17