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 <gz/math/Pose3.hh>
24 #include <gz/utils/ImplPtr.hh>
25 
26 #include "sdf/Element.hh"
27 #include "sdf/Types.hh"
28 #include "sdf/Link.hh"
29 #include "sdf/Joint.hh"
30 #include "sdf/Plugin.hh"
31 #include "sdf/sdf_config.h"
32 #include "sdf/system_util.hh"
33 
34 namespace sdf
35 {
36  // Inline bracke to help doxygen filtering.
37  inline namespace SDF_VERSION_NAMESPACE {
38  //
41  {
43  public: Animation();
44 
51  public: Errors Load(ElementPtr _sdf);
52 
55  public: const std::string &Name() const;
56 
59  public: void SetName(const std::string &_name);
60 
63  public: const std::string &Filename() const;
64 
67  public: void SetFilename(const std::string &_filename);
68 
71  public: const std::string &FilePath() const;
72 
75  public: void SetFilePath(const std::string &_filePath);
76 
79  public: double Scale() const;
80 
83  public: void SetScale(double _scale);
84 
87  public: bool InterpolateX() const;
88 
91  public: void SetInterpolateX(bool _interpolateX);
92 
94  GZ_UTILS_IMPL_PTR(dataPtr)
95  };
96 
99  {
101  public: Waypoint();
102 
109  public: Errors Load(ElementPtr _sdf);
110 
113  public: double Time() const;
114 
117  public: void SetTime(double _time);
118 
121  public: gz::math::Pose3d Pose() const;
122 
125  public: void SetPose(const gz::math::Pose3d &_pose);
126 
128  GZ_UTILS_IMPL_PTR(dataPtr)
129  };
130 
133  {
135  public: Trajectory();
136 
143  public: Errors Load(ElementPtr _sdf);
144 
147  public: uint64_t Id() const;
148 
151  public: void SetId(uint64_t _id);
152 
155  public: const std::string &Type() const;
156 
160  public: void SetType(const std::string &_type);
161 
164  public: double Tension() const;
165 
168  public: void SetTension(double _tension);
169 
172  public: uint64_t WaypointCount() const;
173 
179  public: const Waypoint *WaypointByIndex(uint64_t _index) const;
180 
183  public: void AddWaypoint(const Waypoint &_waypoint);
184 
186  GZ_UTILS_IMPL_PTR(dataPtr)
187  };
188 
189 
192  {
194  public: Actor();
195 
202  public: Errors Load(ElementPtr _sdf);
203 
206  public: const std::string &Name() const;
207 
210  public: void SetName(const std::string &_name);
211 
217  public: const gz::math::Pose3d &RawPose() const;
218 
222  public: void SetRawPose(const gz::math::Pose3d &_pose);
223 
228  public: const std::string &PoseRelativeTo() const;
229 
234  public: void SetPoseRelativeTo(const std::string &_frame);
235 
238  public: const std::string &FilePath() const;
239 
242  public: void SetFilePath(const std::string &_filePath);
243 
246  public: const std::string &SkinFilename() const;
247 
250  public: void SetSkinFilename(std::string _skinFilename);
251 
254  public: double SkinScale() const;
255 
258  public: void SetSkinScale(double _skinScale);
259 
262  public: uint64_t AnimationCount() const;
263 
269  public: const Animation *AnimationByIndex(uint64_t _index) const;
270 
274  public: bool AnimationNameExists(const std::string &_name) const;
275 
278  public: void AddAnimation(const Animation &_anim);
279 
282  public: bool ScriptLoop() const;
283 
287  public: void SetScriptLoop(bool _scriptLoop);
288 
291  public: double ScriptDelayStart() const;
292 
295  public: void SetScriptDelayStart(double _scriptDelayStart);
296 
299  public: bool ScriptAutoStart() const;
300 
304  public: void SetScriptAutoStart(bool _scriptAutoStart);
305 
308  public: uint64_t TrajectoryCount() const;
309 
315  public: const Trajectory *TrajectoryByIndex(uint64_t _index) const;
316 
320  public: bool TrajectoryIdExists(uint64_t _id) const;
321 
324  public: void AddTrajectory(const Trajectory &_traj);
325 
328  public: uint64_t LinkCount() const;
329 
335  public: const Link *LinkByIndex(uint64_t _index) const;
336 
340  public: bool LinkNameExists(const std::string &_name) const;
341 
344  public: uint64_t JointCount() const;
345 
351  public: const Joint *JointByIndex(uint64_t _index) const;
352 
356  public: bool JointNameExists(const std::string &_name) const;
357 
362  public: sdf::ElementPtr Element() const;
363 
368  public: bool AddLink(const Link &_link);
369 
374  public: bool AddJoint(const Joint &_joint);
375 
377  public: void ClearLinks();
378 
380  public: void ClearJoints();
381 
387  public: sdf::ElementPtr ToElement() const;
388 
392  public: const sdf::Plugins &Plugins() const;
393 
397  public: sdf::Plugins &Plugins();
398 
400  public: void ClearPlugins();
401 
404  public: void AddPlugin(const Plugin &_plugin);
405 
407  GZ_UTILS_IMPL_PTR(dataPtr)
408  };
409  }
410 }
411 #endif
Provides a description of an actor.
Definition: Actor.hh:192
const Trajectory * TrajectoryByIndex(uint64_t _index) const
Get a trajectory based on an index.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
const Animation * AnimationByIndex(uint64_t _index) const
Get an animation based on an index.
const sdf::Plugins & Plugins() const
Get the plugins attached to this object.
const Link * LinkByIndex(uint64_t _index) const
Get a link based on an index.
void SetScriptLoop(bool _scriptLoop)
Set whether the animation plays in loop.
void AddPlugin(const Plugin &_plugin)
Add a plugin to this object.
Errors Load(ElementPtr _sdf)
Load the actor based on a element pointer.
const std::string & Name() const
Get the name of the actor.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
const Joint * JointByIndex(uint64_t _index) const
Get a joint based on an index.
const std::string & SkinFilename() const
Get the skin filename.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
void SetScriptDelayStart(double _scriptDelayStart)
Set the delay time to start.
void SetName(const std::string &_name)
Set the name of the actor.
bool LinkNameExists(const std::string &_name) const
Get whether a link name exists.
bool AddJoint(const Joint &_joint)
Add a joint to the actor.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this actor.
void ClearPlugins()
Remove all plugins.
void SetScriptAutoStart(bool _scriptAutoStart)
Set whether the animation plays when simulation starts.
void AddAnimation(const Animation &_anim)
Add a new animation.
uint64_t JointCount() const
Get the number of joints.
const gz::math::Pose3d & RawPose() const
Get the pose of the actor.
void SetSkinFilename(std::string _skinFilename)
Set the skin filename.
void ClearLinks()
Remove all links.
bool TrajectoryIdExists(uint64_t _id) const
Get whether a trajectory id exists.
bool ScriptLoop() const
Get whether the animation plays in loop.
double ScriptDelayStart() const
Get the time (in seconds) of delay to start.
double SkinScale() const
Get the skin scale.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void ClearJoints()
Remove all joints.
void SetSkinScale(double _skinScale)
Set the skin scale.
bool ScriptAutoStart() const
Get whether the animation plays when simulation starts.
bool JointNameExists(const std::string &_name) const
Get whether a joint name exists.
uint64_t TrajectoryCount() const
Get the number of trajectories.
void AddTrajectory(const Trajectory &_traj)
Add a new trajectory.
Actor()
Default constructor.
uint64_t LinkCount() const
Get the number of links.
bool AddLink(const Link &_link)
Add a link to the actor.
bool AnimationNameExists(const std::string &_name) const
Get whether an animation name exists.
void SetRawPose(const gz::math::Pose3d &_pose)
Set the pose of the actor.
const std::string & FilePath() const
The path to the file where this element was loaded from.
uint64_t AnimationCount() const
Get the number of animations.
sdf::Plugins & Plugins()
Get a mutable vector of plugins attached to this object.
Animation in Actor.
Definition: Actor.hh:41
Errors Load(ElementPtr _sdf)
Load the animation based on a element pointer.
void SetInterpolateX(bool _interpolateX)
Set whether the animation is interpolated on X.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
void SetName(const std::string &_name)
Set the name of the animation.
void SetFilename(const std::string &_filename)
Set the filename of the animation.
const std::string & Filename() const
Get the animation filename.
double Scale() const
Get the scale for the animation skeleton.
bool InterpolateX() const
Get whether the animation is interpolated on X.
const std::string & FilePath() const
The path to the file where this element was loaded from.
const std::string & Name() const
Get the name of the animation.
void SetScale(double _scale)
Set the scale of the animation skeleton.
Definition: Joint.hh:86
Definition: Plugin.hh:46
Trajectory for Animation.
Definition: Actor.hh:133
const std::string & Type() const
Get the type of the trajectory.
uint64_t WaypointCount() const
Get the number of waypoints.
void AddWaypoint(const Waypoint &_waypoint)
Add a new waypoint.
Errors Load(ElementPtr _sdf)
Load the trajectory based on a element pointer.
const Waypoint * WaypointByIndex(uint64_t _index) const
Get a waypoint based on an index.
uint64_t Id() const
Get the unique id of the trajectory.
double Tension() const
Get the tension of the trajectory spline.
void SetType(const std::string &_type)
Set the animation type of the trajectory.
void SetId(uint64_t _id)
Set the ID of the trajectory.
void SetTension(double _tension)
Set the tension of trajectory spline.
Waypoint for Trajectory.
Definition: Actor.hh:99
gz::math::Pose3d Pose() const
Get the pose to be reached.
double Time() const
Get the time in seconds when the pose should be reached.
Errors Load(ElementPtr _sdf)
Load the waypoint based on a element pointer.
void SetPose(const gz::math::Pose3d &_pose)
Set the pose to be reached.
void SetTime(double _time)
Set the time in seconds when the pose should be reached.
std::vector< Plugin > Plugins
A vector of Plugin.
Definition: Plugin.hh:245
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:95
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:55
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25