Gazebo 机器人仿真流程之 WorldPrivate 类
在 Gazebo 中,World
类可以认为是场景容器,包含了仿真场景中的所有对象。其中,绝大多数成员变量以 WorldPrivate
类的形式存放,参见 gazebo/gazebo/physics/WorldPrivate.hh
在 WorldPrivate
类中,则主要定义了仿真场景中所需包含的对象、数据等信息。主要成员变量有:
(1)物理引擎
/// \brief Pointer the physics engine.
public: PhysicsEnginePtr physicsEngine;
(2)元素/对象根节点
/// \brief The root of all entities in the world.
public: BasePtr rootElement;
(3)仿真相关的时间、标志位等
/// \brief thread in which the world is updated.
public: std::thread *thread;
/// \brief True to stop the world from running.
public: bool stop;
/// \brief Name of the world.
public: std::string name;
/// \brief Current simulation time.
public: common::Time simTime;
/// \brief Amount of time simulation has been paused.
public: common::Time pauseTime;
/// \brief Clock time when simulation was started.
public: common::Time startTime;
/// \brief True if simulation is paused.
public: bool pause;
/// \brief Number of steps in increment by.
public: int stepInc;
(4)事件链
/// \brief All the event connections.
public: event::Connection_V connections;
(5)信息相关,订阅/发布/信息
/// \brief Transportation node.
public: transport::NodePtr node;
/// \brief Publisher for world statistics messages.
public: transport::PublisherPtr statPub;
/// \brief Publisher for request response messages.
public: transport::PublisherPtr responsePub;
/// \brief Publisher for model messages.
public: transport::PublisherPtr modelPub;
/// \brief Publisher for gui messages.
public: transport::PublisherPtr guiPub;
/// \brief Publisher for light modify messages.
public: transport::PublisherPtr lightPub;
/// \brief Publisher for light factory messages.
public: transport::PublisherPtr lightFactoryPub;
/// \brief Publisher for pose messages.
public: transport::PublisherPtr posePub;
/// \brief Publisher for local pose messages.
public: transport::PublisherPtr poseLocalPub;
/// \brief Subscriber to world control messages.
public: transport::SubscriberPtr controlSub;
/// \brief Subscriber to log playback control messages.
public: transport::SubscriberPtr playbackControlSub;
/// \brief Subscriber to factory messages.
public: transport::SubscriberPtr factorySub;
/// \brief Subscriber to joint messages.
public: transport::SubscriberPtr jointSub;
/// \brief Subscriber to light messages.
public: transport::SubscriberPtr lightSub;
/// \brief Subscriber to light factory messages.
public: transport::SubscriberPtr lightFactorySub;
/// \brief Subscriber to light modify messages.
public: transport::SubscriberPtr lightModifySub;
/// \brief Subscriber to model messages.
public: transport::SubscriberPtr modelSub;
/// \brief Subscriber to request messages.
public: transport::SubscriberPtr requestSub;
/// \brief Outgoing world statistics message.
public: msgs::WorldStatistics worldStatsMsg;
/// \brief Outgoing scene message.
public: msgs::Scene sceneMsg;
(6)模型更新函数
/// \brief Function pointer to the model update function.
public: void (World::*modelUpdateFunc)();
(7)插件类
/// \brief All the plugins.
public: std::vector<WorldPluginPtr> plugins;
(8)
/// \brief List of entities to delete.
public: std::list<std::string> deleteEntity;
(9)Ray Test
/// \brief Ray used to test for collisions when placing entities.
public: RayShapePtr testRay;
(10)场景中对象的状态
/// \brief Alternating buffer of states.
public: std::deque<WorldState> states[2];
/// \brief Keep track of current state buffer being updated
public: int currentStateBuffer;
/// \brief Buffer of prev states
public: WorldState prevStates[2];
/// \brief Previous unfiltered state. Used for determining insertions
/// and deletions
public: WorldState prevUnfilteredState;
/// \brief Int used to toggle between prevStates
public: int stateToggle;
(11)模型对象
/// \brief A cached list of models. This is here for performance.
public: Model_V models;
/// \brief A cached list of lights.
public: Light_V lights;
(12)道路类
/// \brief A list of roads in the world
public: std::vector<RoadPtr> roads;
(13)状态更新回调函数
/// \brief Callback function intended to call the scene with updated Poses
public: UpdateScenePosesFunc updateScenePoses;
其中,还有一些对于理解仿真流程和逻辑次要的变量,这里并没有全部列举