ROS GAZEBO:向GAZEBO GZ_REGISTER_MODELPLUGIN注册插件时出现问题 我试图创建一个插件,它使用C++编写的物理模型来移动一个立方体。这是我将用C++与物理模型进行交互的代码。

ROS GAZEBO:向GAZEBO GZ_REGISTER_MODELPLUGIN注册插件时出现问题 我试图创建一个插件,它使用C++编写的物理模型来移动一个立方体。这是我将用C++与物理模型进行交互的代码。,c++,plugins,simulation,ros,gazebo-simu,C++,Plugins,Simulation,Ros,Gazebo Simu,即使这不是我的第一个gazebo插件,我也不明白为什么它不能编译。我尝试过许多不同的方法。也许有人发现了问题 接下来是我的头文件、代码和控制台中的错误。谢谢你的帮助 错误涉及头文件的最后几行 error: expected constructor, destructor, or type conversion before ‘}’ token 101 | } // namespace gazebo | ^ 此文件是我的头文件model2gazebo.hh #ifndef MOD

即使这不是我的第一个gazebo插件,我也不明白为什么它不能编译。我尝试过许多不同的方法。也许有人发现了问题

接下来是我的头文件、代码和控制台中的错误。谢谢你的帮助

错误涉及头文件的最后几行

error: expected constructor, destructor, or type conversion before ‘}’ token
  101 | } // namespace gazebo
      | ^
此文件是我的头文件model2gazebo.hh

#ifndef MODEL_TO_GAZEBO_HH
#define MODEL_TO_GAZEBO_HH

// ROS
#include <ros/ros.h>

// ROS Msgs
#include <geometry_msgs/Vector3Stamped.h>

// Includes
#include <eigen3/Eigen/Dense>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Pose3.hh>
#include <algorithm>
#include <fstream>
#include <mutex>
#include <thread>
#include <chrono>
#include <thread>
#include <string>

// Gazebo
#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>

namespace gazebo
{

    class ModelToGazebo : public ModelPlugin
    {

    public:
        ModelToGazebo();

        virtual ~ModelToGazebo();

        virtual void Reset();

        void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);

    private:
        void Update();

        bool isLoopTime(const common::Time &time, double &dt);

        void SetState();
        void GetState();

        void UpdateModel(const double &dt);

        void PublishStateTruth();

        Eigen::VectorXd gaz_ace, gaz_vel, gaz_pos;
        Eigen::VectorXd new_ace, new_vel, new_pos;

        ros::Publisher pub_state_truth_ace;
        ros::Publisher pub_state_truth_vel;
        ros::Publisher pub_state_truth_pos;

        boost::shared_ptr<ros::NodeHandle> nh;

        std::mutex mutex;

        event::ConnectionPtr updateConnection;

        transport::NodePtr gznode;

        physics::ModelPtr model;

        common::Time last_sim_time;
        double dt_required;
    };

    GZ_REGISTER_MODELPLUGIN(ModelToGazebo)

} // namespace gazebo

#endif // MODEL_TO_GAZEBO_HH
\ifndef模型到凉亭
#定义模型到凉亭
//活性氧
#包括
//ROS Msgs
#包括
//包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
//凉亭
#包括
#包括
#包括
#包括
名称空间露台
{
类ModelToGazebo:publicmodelplugin
{
公众:
ModelToGazebo();
虚拟~ModelToGazebo();
虚拟空位重置();
无效载荷(物理::ModelPtr\u父级,sdf::ElementPtr\u sdf);
私人:
无效更新();
bool isLoopTime(const common::Time&Time,double&dt);
void SetState();
void GetState();
void UpdateModel(const double&dt);
虚无真理();
本征值:矢量增益,增益电平,增益位置;
特征::矢量xd新空间、新水平、新位置;
出版社:pub_state_truth_ace;
ros::出版商pub_state_truth_Level;
ros::出版商pub_state_truth_pos;
boost::shared_ptr nh;
std::互斥互斥;
事件::ConnectionPtr updateConnection;
传输::NodePtr gznode;
物理:模型PTR模型;
公共::上次模拟时间;
需要双dt_;
};
GZ_寄存器_模型插件(ModelToGazebo)
}//名称空间凉亭
#endif//MODEL_TO_GAZEBO_HH
#ifndef MODEL_TO_GAZEBO_HH
#define MODEL_TO_GAZEBO_HH

// ROS
#include <ros/ros.h>

// ROS Msgs
#include <geometry_msgs/Vector3Stamped.h>

// Includes
#include <eigen3/Eigen/Dense>
#include <ignition/math/Vector3.hh>
#include <ignition/math/Pose3.hh>
#include <algorithm>
#include <fstream>
#include <mutex>
#include <thread>
#include <chrono>
#include <thread>
#include <string>

// Gazebo
#include <functional>
#include <gazebo/gazebo.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>

namespace gazebo
{

    class ModelToGazebo : public ModelPlugin
    {

    public:
        ModelToGazebo();

        virtual ~ModelToGazebo();

        virtual void Reset();

        void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);

    private:
        void Update();

        bool isLoopTime(const common::Time &time, double &dt);

        void SetState();
        void GetState();

        void UpdateModel(const double &dt);

        void PublishStateTruth();

        Eigen::VectorXd gaz_ace, gaz_vel, gaz_pos;
        Eigen::VectorXd new_ace, new_vel, new_pos;

        ros::Publisher pub_state_truth_ace;
        ros::Publisher pub_state_truth_vel;
        ros::Publisher pub_state_truth_pos;

        boost::shared_ptr<ros::NodeHandle> nh;

        std::mutex mutex;

        event::ConnectionPtr updateConnection;

        transport::NodePtr gznode;

        physics::ModelPtr model;

        common::Time last_sim_time;
        double dt_required;
    };

    GZ_REGISTER_MODELPLUGIN(ModelToGazebo)

} // namespace gazebo

#endif // MODEL_TO_GAZEBO_HH