首页 > 解决方案 > 错误:“IGN_PROFILE”未在此范围内声明

问题描述

在我的代码中,我检查了两次所有大括号是否平衡。缩进为 2 个空格。尽管如此,我还是收到了这个奇怪的编译错误

error: ‘IGN_PROFILE’ was not declared in this scope   

我的代码

void amcl::PostUpdate(const ignition::gazebo::UpdateInfo &_info,ignition::gazebo::EntityComponentManager &_ecm)

{
  IGN_PROFILE("amcl::PostUpdate"); ---->Error in this line
  // Nothing left to do if paused.
   if (_info.paused)
  
   {
     return;

   }
   this->dataPtr->updateAmclPose();

}


bool amcl::updateAmclPose()

{
  IGN_PROFILE("amcl::updateAmclPose");  ---->Error in this line

   bool isok {false};

   try
        
   {
     if(tfBuffer_.canTransform(fixed_frame_, robot_frame_, ros::Time(0)))
        
     {

        read_transformation_ = tfBuffer_.lookupTransform(fixed_frame_, robot_frame_, ros::Time(0), ros::Duration(60.0));

        msg_.header.frame_id = fixed_frame_;
        msg_.header.stamp = ros::Time::now();

        msg_.pose.pose.position.x = read_transformation_.transform.translation.x;
        msg_.pose.pose.position.y = read_transformation_.transform.translation.y;
        msg_.pose.pose.position.z = read_transformation_.transform.translation.z;

        msg_.pose.pose.orientation.x = read_transformation_.transform.rotation.x;
        msg_.pose.pose.orientation.y = read_transformation_.transform.rotation.y;
        msg_.pose.pose.orientation.z = read_transformation_.transform.rotation.z;
        msg_.pose.pose.orientation.w = read_transformation_.transform.rotation.w;
     }
      
     isok = true;
        
   } 
  
   catch(const tf2::TimeoutException & e)
        
   {

     ROS_ERROR_STREAM(ros::this_node::getName() << " " << __func__ <<" timeout exception: " << e.what());    
        
     return isok;
    
   }
        
   catch(const tf2::TransformException & e)
        
   {
        
     ROS_ERROR_STREAM(ros::this_node::getName() << " " << __func__ <<" transform exception: " << e.what());
        
     return isok;
    
   }

   return isok;

}

PS:我已经在代码中标记了引发此错误的行。我知道这是一个有点愚蠢的问题,但我已经尝试了一切,但仍然无法摆脱这个错误。

有人可以帮忙吗?谢谢

标签: c++ros

解决方案


推荐阅读