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