C++ 错误:在‘;之前应为主表达式;常数’;
这是导致此错误的代码段。该行已在代码段中标记 代码C++ 错误:在‘;之前应为主表达式;常数’;,c++,ros,C++,Ros,这是导致此错误的代码段。该行已在代码段中标记 代码 class ignition::gazebo::systems::amclPrivate { public: Model model{kNullEntity}; public: bool updateAmclPose(const EntityComponentManager &_ecm); public: std::string fixed_frame_; public: std::string r
class ignition::gazebo::systems::amclPrivate
{
public: Model model{kNullEntity};
public: bool updateAmclPose(const EntityComponentManager &_ecm);
public: std::string fixed_frame_;
public: std::string robot_frame_;
public: double rate_;
};
void amcl::Configure(const Entity &_entity,
const std::shared_ptr<const sdf::Element> &_sdf,
EntityComponentManager &_ecm,
EventManager &_eventMgr)
amcl_nh_.setCallbackQueue(& amcl_queue_);
amcl_pub_ = amcl_nh_.advertise<geometry_msgs::PoseWithCovarianceStamped>("amcl",1,true);
thread_ptr_ = std::make_shared<std::thread>();
{
// Set process rate
ros::Rate r(this->rate_);
while (this->amcl_nh_.ok())
{
this->updateAmclPose(const EntityComponentManager &_ecm); ---This line gives error
this->amcl_pub_.publish(this->msg_);
this->amcl_queue_.callAvailable(ros::WallDuration(0.0));
r.sleep();
}
}
class ignition::gazebo::systems::amclPrivate
{
公共:模型模型{kNullEntity};
public:bool-updateAmclPose(const-EntityComponentManager&u-ecm);
public:std::string fixed_frame_;
public:std::string robot\u frame\u;
公众:双倍收费;
};
void amcl::Configure(常量实体和\u实体,
常数标准::共享的ptr和sdf,
实体组件管理器和ecm,
事件管理器和事件管理器)
amcl_nh_.setCallbackQueue(&amcl_queue);
amcl_pub_=amcl_nhu.advertive(“amcl”,1,true);
thread_ptr_uu=std::make_shared();
{
//设定处理速率
ros::费率r(此->费率u1);
而(这个->amcl\u nh\u.ok())
{
this->updateAmclPose(const EntityComponentManager&_ecm);--此行给出错误信息
此->amcl\u发布(此->消息);
此->amcl_队列调用可用(ros::WallDuration(0.0));
r、 睡眠();
}
}
错误
错误:“常量”之前应为主表达式
此->更新组件管理器(const EntityComponentManager&\u ecm)
错误(更改行后更新)
错误:没有用于调用的匹配函数
'ignition::gazebo::v3::systems::amcl::updateAmclPose(常量)
点火::gazebo::v3::EntityComponentManager&)
此->updateAmclPose((const EntityComponentManager&)\u ecm)
PS:上面给出的代码片段只是一个简单的例子。可以找到完整的实现
为了避免混淆,我没有粘贴完整的代码。有人能提出解决办法吗
谢谢将行更改为“this->updateAmclPose(_ecm)”,如果不起作用,则将其更改为“this->updateAmclPose((const EntityComponentManager&))ecm)”,但如果有任何效果,第一行应该起作用。@DavidBien,很抱歉,这似乎不起作用。请查看上面问题中的更新错误。好吧,这就是我为您提供的所有信息-如果您查看该方法的原型,它需要一个UpdateInfo&以及一个EntityComponentManager。代码中有语法错误。祝你好运