首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >c++错误:“{”令牌之前的预期类名

c++错误:“{”令牌之前的预期类名
EN

Stack Overflow用户
提问于 2020-04-01 13:47:43
回答 1查看 398关注 0票数 0

Pose.hpp截图,我正在尝试catkin_make一个简单的包,并且我得到了错误

代码语言:javascript
复制
.../Pose.hpp:17:1: expected class-name before token...
.../Odometry.cpp:12:3: expected class-name before token...

在此对负责任的Pose头文件进行采样如下:

代码语言:javascript
复制
#ifndef POSE_HPP
#define POSE_HPP
#include <string>
#include <vector>
#include <ostream>
#include "ros/serialization.h"
#include "ros/builtin_message_traits.h"
#include "ros/message_operations.h"
#include "ros/message.h"
#include "ros/time.h"


namespace turtle
{//line 17
template <class ContainerAllocator>
struct Pose_ : public ros::Message
{
  typedef Pose_<ContainerAllocator> Type;

}; // struct Pose
...
} // namespace turtle

在引用的头文件上,在odometry.cpp中引用,如

代码语言:javascript
复制
#include <geometry_msgs/TwistWithCovarianceStamped.h>
#include <tf/transform_datatypes.h>
#include <robot_localization_demo/odometry.hpp>

namespace robot_localization_demo {

  TurtleOdometry::TurtleOdometry(ros::NodeHandle node_handle, double frequency):
    node_handle_{node_handle},
    turtle_pose_subscriber_{node_handle_.subscribe("turtle1/pose", 16, &TurtleOdometry::turtlePoseCallback, this)},
    turtle_twist_publisher_{node_handle_.advertise<geometry_msgs::TwistWithCovarianceStamped>("turtle1/sensors/twist", 16)},
    frequency_{frequency},
  {//line 12
    ;
  }

测定仪也包括姿势。我在这里错过了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-01 13:57:16

ros::Message的官方文件说:

对于基于模板的序列化和特性系统来说,这个基类是不可取的。

官方源代码中,它看起来仍然是定义的,但是在我发现的一个控制版本中,整个类定义#if 0删除了

代码语言:javascript
复制
namespace ros {
#if 0
class Message {
    //
};
#endif
}

因此,您很可能需要找到一个不同的基类。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60972362

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档