Actor.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 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 SDF_ACTOR_HH_
18 #define SDF_ACTOR_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <ignition/math/Pose3.hh>
24 
25 #include "sdf/Element.hh"
26 #include "sdf/Types.hh"
27 #include "sdf/Link.hh"
28 #include "sdf/Joint.hh"
29 #include "sdf/sdf_config.h"
30 #include "sdf/system_util.hh"
31 
32 namespace sdf
33 {
34  // Inline bracke to help doxygen filtering.
35  inline namespace SDF_VERSION_NAMESPACE {
36  //
37 
38  // Forward declare private data class.
39  class AnimationPrivate;
40 
41  // Forward declare private data class.
42  class WaypointPrivate;
43 
44  // Forward declare private data class.
45  class TrajectoryPrivate;
46 
47  // Forward declare private data class.
48  class ActorPrivate;
49 
52  {
54  public: Animation();
55 
58  public: Animation(const Animation &_animation);
59 
62  public: Animation(Animation &&_animation) noexcept;
63 
65  public: ~Animation();
66 
70  public: Animation &operator=(Animation &&_animation);
71 
75  public: Animation &operator=(const Animation &_animation);
76 
83  public: Errors Load(ElementPtr _sdf);
84 
87  public: const std::string &Name() const;
88 
91  public: void SetName(const std::string &_name);
92 
95  public: const std::string &Filename() const;
96 
99  public: void SetFilename(const std::string &_filename);
100 
103  public: const std::string &FilePath() const;
104 
107  public: void SetFilePath(const std::string &_filePath);
108 
111  public: double Scale() const;
112 
115  public: void SetScale(double _scale);
116 
119  public: bool InterpolateX() const;
120 
123  public: void SetInterpolateX(bool _interpolateX);
124 
127  public: void CopyFrom(const Animation &_animation);
128 
130  private: AnimationPrivate *dataPtr = nullptr;
131  };
132 
135  {
137  public: Waypoint();
138 
141  public: Waypoint(const Waypoint &_waypoint);
142 
145  public: Waypoint(Waypoint &&_waypoint) noexcept;
146 
148  public: ~Waypoint();
149 
153  public: Waypoint &operator=(Waypoint &&_waypoint);
154 
158  public: Waypoint &operator=(const Waypoint &_waypoint);
159 
166  public: Errors Load(ElementPtr _sdf);
167 
170  public: double Time() const;
171 
174  public: void SetTime(double _time);
175 
178  public: ignition::math::Pose3d Pose() const;
179 
182  public: void SetPose(const ignition::math::Pose3d &_pose);
183 
186  public: void CopyFrom(const Waypoint &_waypoint);
187 
189  private: WaypointPrivate *dataPtr = nullptr;
190  };
191 
194  {
196  public: Trajectory();
197 
200  public: Trajectory(const Trajectory &_trajectory);
201 
204  public: Trajectory(Trajectory &&_trajectory) noexcept;
205 
207  public: ~Trajectory();
208 
212  public: Trajectory &operator=(Trajectory &&_trajectory);
213 
217  public: Trajectory &operator=(const Trajectory &_trajectory);
218 
225  public: Errors Load(ElementPtr _sdf);
226 
229  public: uint64_t Id() const;
230 
233  public: void SetId(uint64_t _id);
234 
237  public: const std::string &Type() const;
238 
242  public: void SetType(const std::string &_type);
243 
246  public: double Tension() const;
247 
250  public: void SetTension(double _tension);
251 
254  public: uint64_t WaypointCount() const;
255 
261  public: const Waypoint *WaypointByIndex(uint64_t _index) const;
262 
265  public: void AddWaypoint(const Waypoint &_waypoint);
266 
269  public: void CopyFrom(const Trajectory &_trajectory);
270 
272  private: TrajectoryPrivate *dataPtr = nullptr;
273  };
274 
275 
278  {
280  public: Actor();
281 
284  public: Actor(const Actor &_actor);
285 
288  public: Actor(Actor &&_actor) noexcept;
289 
291  public: ~Actor();
292 
296  public: Actor &operator=(Actor &&_actor);
297 
301  public: Actor &operator=(const Actor &_actor);
302 
305  public: void CopyFrom(const Actor &_actor);
306 
313  public: Errors Load(ElementPtr _sdf);
314 
317  public: std::string &Name() const;
318 
321  public: void SetName(const std::string &_name);
322 
328  public: const ignition::math::Pose3d &RawPose() const;
329 
333  public: void SetRawPose(const ignition::math::Pose3d &_pose);
334 
339  public: const std::string &PoseRelativeTo() const;
340 
345  public: void SetPoseRelativeTo(const std::string &_frame);
346 
349  public: const std::string &FilePath() const;
350 
353  public: void SetFilePath(const std::string &_filePath);
354 
357  public: const std::string &SkinFilename() const;
358 
361  public: void SetSkinFilename(std::string _skinFilename);
362 
365  public: double SkinScale() const;
366 
369  public: void SetSkinScale(double _skinScale);
370 
373  public: uint64_t AnimationCount() const;
374 
380  public: const Animation *AnimationByIndex(uint64_t _index) const;
381 
385  public: bool AnimationNameExists(const std::string &_name) const;
386 
389  public: void AddAnimation(const Animation &_anim);
390 
393  public: bool ScriptLoop() const;
394 
398  public: void SetScriptLoop(bool _scriptLoop);
399 
402  public: double ScriptDelayStart() const;
403 
406  public: void SetScriptDelayStart(double _scriptDelayStart);
407 
410  public: bool ScriptAutoStart() const;
411 
415  public: void SetScriptAutoStart(bool _scriptAutoStart);
416 
419  public: uint64_t TrajectoryCount() const;
420 
426  public: const Trajectory *TrajectoryByIndex(uint64_t _index) const;
427 
431  public: bool TrajectoryIdExists(uint64_t _id) const;
432 
435  public: void AddTrajectory(const Trajectory &_traj);
436 
439  public: uint64_t LinkCount() const;
440 
446  public: const Link *LinkByIndex(uint64_t _index) const;
447 
451  public: bool LinkNameExists(const std::string &_name) const;
452 
455  public: uint64_t JointCount() const;
456 
462  public: const Joint *JointByIndex(uint64_t _index) const;
463 
467  public: bool JointNameExists(const std::string &_name) const;
468 
473  public: sdf::ElementPtr Element() const;
474 
476  private: ActorPrivate *dataPtr = nullptr;
477  };
478  }
479 }
480 #endif
Provides a description of an actor.
Definition: Actor.hh:277
Definition: Joint.hh:82
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
Waypoint for Trajectory.
Definition: Actor.hh:134
Animation in Actor.
Definition: Actor.hh:51
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:48
A Time class, can be used to hold wall- or sim-time.
Definition: Types.hh:159
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
namespace for Simulation Description Format parser
Definition: Actor.hh:32
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
Trajectory for Animation.
Definition: Actor.hh:193