Ignition Gazebo

API Reference

7.0.0~pre1
Server.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_GAZEBO_SERVER_HH_
18 #define IGNITION_GAZEBO_SERVER_HH_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <optional>
23 #include <string>
24 #include <ignition/gazebo/config.hh>
26 #include <ignition/gazebo/Export.hh>
29 
30 namespace ignition
31 {
32  namespace gazebo
33  {
34  // Inline bracket to help doxygen filtering.
35  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
36  // Forware declarations
37  class ServerPrivate;
38 
108  class IGNITION_GAZEBO_VISIBLE Server
109  {
114  public: explicit Server(const ServerConfig &_config = ServerConfig());
115 
117  public: ~Server();
118 
125  public: void SetUpdatePeriod(
126  const std::chrono::steady_clock::duration &_updatePeriod,
127  const unsigned int _worldIndex = 0);
128 
144  public: bool Run(const bool _blocking = false,
145  const uint64_t _iterations = 0,
146  const bool _paused = true);
147 
155  public: bool RunOnce(const bool _paused = true);
156 
162  public: bool Running() const;
163 
172  public: std::optional<bool> Running(const unsigned int _worldIndex) const;
173 
181  public: bool SetPaused(const bool _paused,
182  const unsigned int _worldIndex = 0) const;
183 
190  public: std::optional<bool> Paused(
191  const unsigned int _worldIndex = 0) const;
192 
197  public: std::optional<uint64_t> IterationCount(
198  const unsigned int _worldIndex = 0) const;
199 
203  public: std::optional<size_t> EntityCount(
204  const unsigned int _worldIndex = 0) const;
205 
209  public: std::optional<size_t> SystemCount(
210  const unsigned int _worldIndex = 0) const;
211 
218  public: std::optional<bool> AddSystem(
219  const SystemPluginPtr &_system,
220  const unsigned int _worldIndex = 0);
221 
228  public: std::optional<bool> AddSystem(
229  const std::shared_ptr<System> &_system,
230  const unsigned int _worldIndex = 0);
231 
240  public: std::optional<Entity> EntityByName(const std::string &_name,
241  const unsigned int _worldIndex = 0) const;
242 
249  public: bool HasEntity(const std::string &_name,
250  const unsigned int _worldIndex = 0) const;
251 
265  public: bool RequestRemoveEntity(const std::string &_name,
266  bool _recursive = true,
267  const unsigned int _worldIndex = 0);
268 
280  public: bool RequestRemoveEntity(const Entity _entity,
281  bool _recursive = true,
282  const unsigned int _worldIndex = 0);
283 
285  private: std::unique_ptr<ServerPrivate> dataPtr;
286  };
287  }
288  }
289 }
290 
291 #endif
The server instantiates and controls simulation.
Definition: Server.hh:108
Configuration parameters for a Server. An instance of this object can be used to construct a Server w...
Definition: ServerConfig.hh:43
STL class.
This library is part of the Ignition Robotics project.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light. At its core, an Entity is just an identifier.
Definition: Entity.hh:59