This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager
directly. All the functions provided here are meant to be used with a actor entity.
More...
#include <ignition/gazebo/Actor.hh>
Public Member Functions | |
Actor (gazebo::Entity _entity=kNullEntity) | |
Constructor. More... | |
std::optional< std::string > | AnimationName (const EntityComponentManager &_ecm) const |
Get the name of animation used by the actor. More... | |
std::optional< std::chrono::steady_clock::duration > | AnimationTime (const EntityComponentManager &_ecm) const |
Get the time of animation for this actor. More... | |
gazebo::Entity | Entity () const |
Get the entity which this Actor is related to. More... | |
std::optional< std::string > | Name (const EntityComponentManager &_ecm) const |
Get the actor's unscoped name. More... | |
std::optional< math::Pose3d > | Pose (const EntityComponentManager &_ecm) const |
Get the pose of the actor. If the actor has a trajectory, this will only return the origin pose of the trajectory and not the actual world pose of the actor. More... | |
void | ResetEntity (gazebo::Entity _newEntity) |
Reset Entity to a new one. More... | |
void | SetAnimationName (EntityComponentManager &_ecm, const std::string &_name) |
Set the name of animation to use for this actor. More... | |
void | SetAnimationTime (EntityComponentManager &_ecm, const std::chrono::steady_clock::duration &_time) |
Set the time of animation for this actor. More... | |
void | SetTrajectoryPose (EntityComponentManager &_ecm, const math::Pose3d &_pose) |
Set the trajectory pose of the actor. There are two ways that the actor can follow a trajectory: 1) SDF script, 2) manually setting trajectory pose. This function enables option 2). Manually setting the trajectory pose will override the scripted trajectory specified in SDF. More... | |
std::optional< math::Pose3d > | TrajectoryPose (const EntityComponentManager &_ecm) const |
Get the trajectory pose of the actor. There are two ways that the actor can follow a trajectory: 1) SDF script, 2) manually setting trajectory pose. This function retrieves 2) the manual trajectory pose set by the user. The Trajectory pose is given relative to the trajectory pose origin returned by Pose(). More... | |
bool | Valid (const EntityComponentManager &_ecm) const |
Check whether this actor correctly refers to an entity that has a components::Actor. More... | |
std::optional< math::Pose3d > | WorldPose (const EntityComponentManager &_ecm) const |
Get the world pose of the actor. This returns the current world pose of the actor computed by gazebo. The world pose is the combination of the actor's pose and its trajectory pose. The currently trajectory pose is either manually set via SetTrajectoryPose or interpolated from waypoints in the SDF script based on the current time. More... | |
Detailed Description
This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager
directly. All the functions provided here are meant to be used with a actor entity.
For example, given an actor's entity, find the value of its name component, one could use the entity-component manager (ecm
) directly as follows:
std::string name = ecm.Component<components::Name>(entity)->Data();
Using this class however, the same information can be obtained with a simpler function call:
Actor actor(entity); std::string name = actor.Name(ecm);
Constructor & Destructor Documentation
◆ Actor()
|
explicit |
Constructor.
- Parameters
-
[in] _entity Actor entity
Member Function Documentation
◆ AnimationName()
std::optional<std::string> AnimationName | ( | const EntityComponentManager & | _ecm | ) | const |
Get the name of animation used by the actor.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Animation name
◆ AnimationTime()
std::optional<std::chrono::steady_clock::duration> AnimationTime | ( | const EntityComponentManager & | _ecm | ) | const |
Get the time of animation for this actor.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Animation time
◆ Entity()
gazebo::Entity Entity | ( | ) | const |
◆ Name()
std::optional<std::string> Name | ( | const EntityComponentManager & | _ecm | ) | const |
Get the actor's unscoped name.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Actor's name or nullopt if the entity does not have a components::Name component
◆ Pose()
std::optional<math::Pose3d> Pose | ( | const EntityComponentManager & | _ecm | ) | const |
Get the pose of the actor. If the actor has a trajectory, this will only return the origin pose of the trajectory and not the actual world pose of the actor.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Pose of the actor or nullopt if the entity does not have a components::Pose component.
- See also
- WorldPose
◆ ResetEntity()
void ResetEntity | ( | gazebo::Entity | _newEntity | ) |
Reset Entity to a new one.
- Parameters
-
[in] _newEntity New actor entity.
◆ SetAnimationName()
void SetAnimationName | ( | EntityComponentManager & | _ecm, |
const std::string & | _name | ||
) |
Set the name of animation to use for this actor.
- Parameters
-
[in] _ecm Entity Component manager. [in] _name Animation name
◆ SetAnimationTime()
void SetAnimationTime | ( | EntityComponentManager & | _ecm, |
const std::chrono::steady_clock::duration & | _time | ||
) |
Set the time of animation for this actor.
- Parameters
-
[in] _ecm Entity Component manager. [in] _time Animation time
◆ SetTrajectoryPose()
void SetTrajectoryPose | ( | EntityComponentManager & | _ecm, |
const math::Pose3d & | _pose | ||
) |
Set the trajectory pose of the actor. There are two ways that the actor can follow a trajectory: 1) SDF script, 2) manually setting trajectory pose. This function enables option 2). Manually setting the trajectory pose will override the scripted trajectory specified in SDF.
- Parameters
-
[in] _ecm Entity Component manager. [in] _name Trajectory pose w.r.t. to the trajectory origin
- See also
- Pose
◆ TrajectoryPose()
std::optional<math::Pose3d> TrajectoryPose | ( | const EntityComponentManager & | _ecm | ) | const |
Get the trajectory pose of the actor. There are two ways that the actor can follow a trajectory: 1) SDF script, 2) manually setting trajectory pose. This function retrieves 2) the manual trajectory pose set by the user. The Trajectory pose is given relative to the trajectory pose origin returned by Pose().
- Parameters
-
[in] _ecm Entity Component manager.
- Returns
- Trajectory pose of the actor w.r.t. to trajectory origin.
- See also
- Pose
◆ Valid()
bool Valid | ( | const EntityComponentManager & | _ecm | ) | const |
Check whether this actor correctly refers to an entity that has a components::Actor.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- True if it's a valid actor in the manager.
◆ WorldPose()
std::optional<math::Pose3d> WorldPose | ( | const EntityComponentManager & | _ecm | ) | const |
Get the world pose of the actor. This returns the current world pose of the actor computed by gazebo. The world pose is the combination of the actor's pose and its trajectory pose. The currently trajectory pose is either manually set via SetTrajectoryPose or interpolated from waypoints in the SDF script based on the current time.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- World pose of the actor or nullopt if the entity does not have a components::WorldPose component.
- See also
- Pose
The documentation for this class was generated from the following file: