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 #include <ignition/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/sdf_config.h"
31 #include "sdf/system_util.hh"
32 
33 namespace sdf
34 {
35  // Inline bracke to help doxygen filtering.
36  inline namespace SDF_VERSION_NAMESPACE {
37  //
40  {
42  public: Animation();
43 
50  public: Errors Load(ElementPtr _sdf);
51 
54  public: const std::string &Name() const;
55 
58  public: void SetName(const std::string &_name);
59 
62  public: const std::string &Filename() const;
63 
66  public: void SetFilename(const std::string &_filename);
67 
70  public: const std::string &FilePath() const;
71 
74  public: void SetFilePath(const std::string &_filePath);
75 
78  public: double Scale() const;
79 
82  public: void SetScale(double _scale);
83 
86  public: bool InterpolateX() const;
87 
90  public: void SetInterpolateX(bool _interpolateX);
91 
93  IGN_UTILS_IMPL_PTR(dataPtr)
94  };
95 
98  {
100  public: Waypoint();
101 
108  public: Errors Load(ElementPtr _sdf);
109 
112  public: double Time() const;
113 
116  public: void SetTime(double _time);
117 
120  public: ignition::math::Pose3d Pose() const;
121 
124  public: void SetPose(const ignition::math::Pose3d &_pose);
125 
127  IGN_UTILS_IMPL_PTR(dataPtr)
128  };
129 
132  {
134  public: Trajectory();
135 
142  public: Errors Load(ElementPtr _sdf);
143 
146  public: uint64_t Id() const;
147 
150  public: void SetId(uint64_t _id);
151 
154  public: const std::string &Type() const;
155 
159  public: void SetType(const std::string &_type);
160 
163  public: double Tension() const;
164 
167  public: void SetTension(double _tension);
168 
171  public: uint64_t WaypointCount() const;
172 
178  public: const Waypoint *WaypointByIndex(uint64_t _index) const;
179 
182  public: void AddWaypoint(const Waypoint &_waypoint);
183 
185  IGN_UTILS_IMPL_PTR(dataPtr)
186  };
187 
188 
191  {
193  public: Actor();
194 
201  public: Errors Load(ElementPtr _sdf);
202 
205  public: const std::string &Name() const;
206 
209  public: void SetName(const std::string &_name);
210 
216  public: const ignition::math::Pose3d &RawPose() const;
217 
221  public: void SetRawPose(const ignition::math::Pose3d &_pose);
222 
227  public: const std::string &PoseRelativeTo() const;
228 
233  public: void SetPoseRelativeTo(const std::string &_frame);
234 
237  public: const std::string &FilePath() const;
238 
241  public: void SetFilePath(const std::string &_filePath);
242 
245  public: const std::string &SkinFilename() const;
246 
249  public: void SetSkinFilename(std::string _skinFilename);
250 
253  public: double SkinScale() const;
254 
257  public: void SetSkinScale(double _skinScale);
258 
261  public: uint64_t AnimationCount() const;
262 
268  public: const Animation *AnimationByIndex(uint64_t _index) const;
269 
273  public: bool AnimationNameExists(const std::string &_name) const;
274 
277  public: void AddAnimation(const Animation &_anim);
278 
281  public: bool ScriptLoop() const;
282 
286  public: void SetScriptLoop(bool _scriptLoop);
287 
290  public: double ScriptDelayStart() const;
291 
294  public: void SetScriptDelayStart(double _scriptDelayStart);
295 
298  public: bool ScriptAutoStart() const;
299 
303  public: void SetScriptAutoStart(bool _scriptAutoStart);
304 
307  public: uint64_t TrajectoryCount() const;
308 
314  public: const Trajectory *TrajectoryByIndex(uint64_t _index) const;
315 
319  public: bool TrajectoryIdExists(uint64_t _id) const;
320 
323  public: void AddTrajectory(const Trajectory &_traj);
324 
327  public: uint64_t LinkCount() const;
328 
334  public: const Link *LinkByIndex(uint64_t _index) const;
335 
339  public: bool LinkNameExists(const std::string &_name) const;
340 
343  public: uint64_t JointCount() const;
344 
350  public: const Joint *JointByIndex(uint64_t _index) const;
351 
355  public: bool JointNameExists(const std::string &_name) const;
356 
361  public: sdf::ElementPtr Element() const;
362 
364  IGN_UTILS_IMPL_PTR(dataPtr)
365  };
366  }
367 }
368 #endif
Provides a description of an actor.
Definition: Actor.hh:191
void SetName(const std::string &_name)
Set the name of the actor.
bool ScriptLoop() const
Get whether the animation plays in loop.
double ScriptDelayStart() const
Get the time (in seconds) of delay to start.
void AddAnimation(const Animation &_anim)
Add a new animation.
const ignition::math::Pose3d & RawPose() const
Get the pose of the actor.
uint64_t TrajectoryCount() const
Get the number of trajectories.
bool LinkNameExists(const std::string &_name) const
Get whether a link name exists.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
void SetSkinFilename(std::string _skinFilename)
Set the skin filename.
Actor()
Default constructor.
const Trajectory * TrajectoryByIndex(uint64_t _index) const
Get a trajectory based on an index.
Errors Load(ElementPtr _sdf)
Load the actor based on a element pointer.
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
void SetSkinScale(double _skinScale)
Set the skin scale.
bool AnimationNameExists(const std::string &_name) const
Get whether an animation name exists.
bool ScriptAutoStart() const
Get whether the animation plays when simulation starts.
const std::string & FilePath() const
The path to the file where this element was loaded from.
void AddTrajectory(const Trajectory &_traj)
Add a new trajectory.
void SetScriptAutoStart(bool _scriptAutoStart)
Set whether the animation plays when simulation starts.
const std::string & SkinFilename() const
Get the skin filename.
const Joint * JointByIndex(uint64_t _index) const
Get a joint based on an index.
uint64_t JointCount() const
Get the number of joints.
const Animation * AnimationByIndex(uint64_t _index) const
Get an animation based on an index.
void SetScriptLoop(bool _scriptLoop)
Set whether the animation plays in loop.
bool TrajectoryIdExists(uint64_t _id) const
Get whether a trajectory id exists.
bool JointNameExists(const std::string &_name) const
Get whether a joint name exists.
void SetScriptDelayStart(double _scriptDelayStart)
Set the delay time to start.
const std::string & Name() const
Get the name of the actor.
uint64_t AnimationCount() const
Get the number of animations.
void SetPoseRelativeTo(const std::string &_frame)
Set the name of the coordinate frame relative to which this object's pose is expressed.
const Link * LinkByIndex(uint64_t _index) const
Get a link based on an index.
uint64_t LinkCount() const
Get the number of links.
const std::string & PoseRelativeTo() const
Get the name of the coordinate frame relative to which this object's pose is expressed.
void SetRawPose(const ignition::math::Pose3d &_pose)
Set the pose of the actor.
double SkinScale() const
Get the skin scale.
Animation in Actor.
Definition: Actor.hh:40
void SetFilePath(const std::string &_filePath)
Set the path to the file where this element was loaded from.
double Scale() const
Get the scale for the animation skeleton.
Animation()
Default constructor.
void SetInterpolateX(bool _interpolateX)
Set whether the animation is interpolated on X.
Errors Load(ElementPtr _sdf)
Load the animation based on a element pointer.
void SetFilename(const std::string &_filename)
Set the filename of the animation.
void SetName(const std::string &_name)
Set the name of the animation.
const std::string & Filename() const
Get the animation filename.
bool InterpolateX() const
Get whether the animation is interpolated on X.
void SetScale(double _scale)
Set the scale of the animation skeleton.
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.
Definition: Joint.hh:86
Trajectory for Animation.
Definition: Actor.hh:132
Trajectory()
Default constructor.
const Waypoint * WaypointByIndex(uint64_t _index) const
Get a waypoint based on an index.
void SetType(const std::string &_type)
Set the animation type of the trajectory.
Errors Load(ElementPtr _sdf)
Load the trajectory based on a element pointer.
const std::string & Type() const
Get the type of the trajectory.
double Tension() const
Get the tension of the trajectory spline.
uint64_t WaypointCount() const
Get the number of waypoints.
void SetId(uint64_t _id)
Set the ID of the trajectory.
void SetTension(double _tension)
Set the tension of trajectory spline.
void AddWaypoint(const Waypoint &_waypoint)
Add a new waypoint.
uint64_t Id() const
Get the unique id of the trajectory.
Waypoint for Trajectory.
Definition: Actor.hh:98
ignition::math::Pose3d Pose() const
Get the pose to be reached.
void SetTime(double _time)
Set the time in seconds when the pose should be reached.
Waypoint()
Default constructor.
Errors Load(ElementPtr _sdf)
Load the waypoint based on a element pointer.
double Time() const
Get the time in seconds when the pose should be reached.
void SetPose(const ignition::math::Pose3d &_pose)
Set the pose to be reached.
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
namespace for Simulation Description Format parser
Definition: Actor.hh:34
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41