##

Actor.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_PHYSICS_ACTOR_HH_
#define GAZEBO_PHYSICS_ACTOR_HH_
#include <string>
#include <map>
#include <vector>
#include <ignition/math/Color.hh>
#include "gazebo/physics/Model.hh"
#include "gazebo/common/Time.hh"
#include "gazebo/common/Animation.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class Mesh;
class Skeleton;
}
namespace physics
{
class GZ_PHYSICS_VISIBLE TrajectoryInfo
{
public: TrajectoryInfo();
public: unsigned int id;
public: std::string type;
public: double duration;
public: double startTime;
public: double endTime;
public: bool translated;
};
class GZ_PHYSICS_VISIBLE Actor : public Model
{
public: typedef std::map<std::string, common::SkeletonAnimation *>
SkeletonAnimation_M;
public: explicit Actor(BasePtr _parent);
public: virtual ~Actor();
public: void Load(sdf::ElementPtr _sdf);
public: virtual void Init();
public: virtual void Play();
public: virtual void Stop();
public: virtual bool IsActive() const;
public: void Update();
public: virtual void Fini();
public: virtual void UpdateParameters(sdf::ElementPtr _sdf);
public: virtual const sdf::ElementPtr GetSDF();
public: void Reset();
using Model::Reset;
public: void SetScriptTime(const double _time);
public: double ScriptTime() const;
public: const SkeletonAnimation_M &SkeletonAnimations() const;
public: void SetCustomTrajectory(TrajectoryInfoPtr &_trajInfo);
public: const common::Mesh *Mesh() const;
public: TrajectoryInfoPtr CustomTrajectory() const;
public: void ResetCustomTrajectory();
public: virtual bool GetSelfCollide() const;
public: virtual void SetSelfCollide(bool _selfCollide);
public: virtual bool WindMode() const;
public: virtual void SetWindMode(const bool _enabled);
private: void AddSphereInertia(const sdf::ElementPtr &_linkSdf,
const ignition::math::Pose3d &_pose,
const double _mass, const double _radius);
private: void AddSphereCollision(const sdf::ElementPtr &_linkSdf,
const std::string &_name,
const ignition::math::Pose3d &_pose,
const double _radius);
private: void AddBoxCollision(const sdf::ElementPtr &_linkSdf,
const std::string &_name,
const ignition::math::Pose3d &_pose,
const ignition::math::Vector3d &_size);
private: void AddSphereVisual(const sdf::ElementPtr &_linkSdf,
const std::string &_name,
const ignition::math::Pose3d &_pose, const double _radius,
const std::string &_material,
const ignition::math::Color &_ambient);
private: void AddBoxVisual(const sdf::ElementPtr &_linkSdf,
const std::string &_name,
const ignition::math::Pose3d &_pose,
const ignition::math::Vector3d &_size,
const std::string &_material,
const ignition::math::Color &_ambient);
private: void AddActorVisual(const sdf::ElementPtr &_linkSdf,
const std::string &_name,
const ignition::math::Pose3d &_pose);
private: bool LoadSkin(sdf::ElementPtr _sdf);
private: void LoadAnimation(sdf::ElementPtr _sdf);
private: void LoadScript(sdf::ElementPtr _sdf);
private: void SetPose(
std::map<std::string, ignition::math::Matrix4d> _frame,
std::map<std::string, std::string> _skelMap,
const double _time);
protected: const common::Mesh *mesh = nullptr;
protected: common::Skeleton *skeleton = nullptr;
protected: std::string skinFile;
protected: double skinScale;
protected: double startDelay;
protected: double scriptLength;
protected: bool loop;
protected: bool active;
protected: bool autoStart;
protected: LinkPtr mainLink;
protected: common::Time prevFrameTime;
protected: common::Time playStartTime;
protected: std::map<unsigned int, common::PoseAnimation *> trajectories;
protected: std::vector<TrajectoryInfo> trajInfo;
protected: SkeletonAnimation_M skelAnimation;
protected: std::map<std::string, std::map<std::string, std::string> >
skelNodesMap;
// direction.
protected: std::map<std::string, bool> interpolateX;
protected: ignition::math::Vector3d lastPos;
protected: double pathLength;
protected: unsigned int lastTraj;
protected: std::string visualName;
protected: uint32_t visualId;
protected: transport::PublisherPtr bonePosePub;
private: double scriptTime;
private: TrajectoryInfoPtr customTrajectoryInfo;
};
}
}
#endif
gazebo::physics::Actor::lastTraj
unsigned int lastTraj
Id of the last trajectory.
Definition: Actor.hh:360
gazebo::physics::TrajectoryInfo::startTime
double startTime
Start time of this keyframe within the trajectory, in seconds.
Definition: Actor.hh:59
gazebo::physics::Actor::trajInfo
std::vector< TrajectoryInfo > trajInfo
A vector of trajectory information, which contains information such as their durations,...
Definition: Actor.hh:327
Time.hh
gazebo::physics::Actor::SetWindMode
virtual void SetWindMode(const bool _enabled)
Override set wind mode method to make it impossible to set it to true for actors.
gazebo::physics::Actor::Fini
virtual void Fini()
Finalize the actor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::Actor::scriptLength
double scriptLength
Total time length of the script, in seconds.
Definition: Actor.hh:297
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::physics::Actor::skelNodesMap
std::map< std::string, std::map< std::string, std::string > > skelNodesMap
Skeleton to node map:
Definition: Actor.hh:344
gazebo::physics::Actor::SetScriptTime
void SetScriptTime(const double _time)
Set the current script time.
gazebo::physics::Actor::skeleton
common::Skeleton * skeleton
The actor's skeleton.
Definition: Actor.hh:284
gazebo::physics::Actor::lastPos
ignition::math::Vector3d lastPos
Last position of the actor.
Definition: Actor.hh:354
gazebo::physics::Actor::visualName
std::string visualName
Name of the visual representing the skin.
Definition: Actor.hh:363
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
gazebo::physics::Actor::mesh
const common::Mesh * mesh
Pointer to the actor's mesh.
Definition: Actor.hh:281
common
common
Definition: FuelModelDatabase.hh:37
gazebo::physics::Actor::GetSelfCollide
virtual bool GetSelfCollide() const
Get whether the links in the actor can collide with each other.
gazebo::physics::Actor::CustomTrajectory
TrajectoryInfoPtr CustomTrajectory() const
Get the custom trajectory.
gazebo::physics::Actor::SkeletonAnimations
const SkeletonAnimation_M & SkeletonAnimations() const
Returns a dictionary of all the skeleton animations associated with the actor.
Animation.hh
system.hh
gazebo::physics::Actor::Mesh
const common::Mesh * Mesh() const
Returns the actor's mesh.
gazebo::physics::Actor::Stop
virtual void Stop()
Stop playing the script.
gazebo::physics::Actor::visualId
uint32_t visualId
ID for the visual representing the skin.
Definition: Actor.hh:366
gazebo::physics::TrajectoryInfo::id
unsigned int id
ID of the trajectory.
Definition: Actor.hh:49
gazebo::physics::Actor::SetCustomTrajectory
void SetCustomTrajectory(TrajectoryInfoPtr &_trajInfo)
Set a custom trajectory for the actor, using one of the existing animations.
gazebo::physics::Actor::Play
virtual void Play()
Start playing the script.
gazebo::physics::TrajectoryInfo::endTime
double endTime
End time of this keyframe within the trajectory, in seconds.
Definition: Actor.hh:62
gazebo::physics::Actor::pathLength
double pathLength
Length of the actor's path.
Definition: Actor.hh:357
gazebo::physics::TrajectoryInfo::duration
double duration
Duration of this keyframe in seconds.
Definition: Actor.hh:56
gazebo::physics::Actor::skelAnimation
SkeletonAnimation_M skelAnimation
Map of skeleton animations, indexed by their names.
Definition: Actor.hh:333
gazebo::physics::TrajectoryInfo::TrajectoryInfo
TrajectoryInfo()
Constructor.
gazebo::common::Skeleton
A skeleton.
Definition: Skeleton.hh:52
gazebo::physics::Actor::ScriptTime
double ScriptTime() const
Get the current script time.
gazebo::physics::Actor::~Actor
virtual ~Actor()
Destructor.
Model.hh
gazebo::physics::Actor::Update
void Update()
Update the actor.
gazebo::physics::Actor::mainLink
LinkPtr mainLink
Pointer to the actor's canonical link.
Definition: Actor.hh:310
gazebo::physics::Model::Reset
void Reset()
Reset the model.
gazebo::physics::Actor::skinFile
std::string skinFile
Filename for the skin.
Definition: Actor.hh:287
gazebo::physics::Actor::Load
void Load(sdf::ElementPtr _sdf)
Load the actor.
gazebo::physics::Actor::skinScale
double skinScale
Scaling factor to apply to the skin.
Definition: Actor.hh:290
gazebo::physics::Actor::SetSelfCollide
virtual void SetSelfCollide(bool _selfCollide)
Override set self collide method to make it impossible to set it to true for actors.
gazebo::physics::Actor::autoStart
bool autoStart
True if the actor should start running automatically, otherwise it will only start once Play is calle...
Definition: Actor.hh:307
gazebo::physics::TrajectoryInfoPtr
std::shared_ptr< TrajectoryInfo > TrajectoryInfoPtr
Definition: PhysicsTypes.hh:101
gazebo::physics::Model
A model is a collection of links, joints, and plugins.
Definition: Model.hh:59
gazebo::physics::Actor::UpdateParameters
virtual void UpdateParameters(sdf::ElementPtr _sdf)
Update the parameters using new sdf values.
gazebo::physics::BasePtr
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
gazebo::physics::TrajectoryInfo
Information about a trajectory for an Actor.
Definition: Actor.hh:43
gazebo::physics::Actor::prevFrameTime
common::Time prevFrameTime
Time of the previous frame.
Definition: Actor.hh:313
gazebo::physics::Actor::IsActive
virtual bool IsActive() const
Returns true when actor is playing animation.
gazebo::physics::Actor::WindMode
virtual bool WindMode() const
Get whether the links in the actor are affected by wind.
gazebo::physics::Actor::playStartTime
common::Time playStartTime
Time when the animation was started.
Definition: Actor.hh:316
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::physics::LinkPtr
boost::shared_ptr< Link > LinkPtr
Definition: PhysicsTypes.hh:109
gazebo::physics::Actor::startDelay
double startDelay
Time to wait before starting the script.
Definition: Actor.hh:294
gazebo::physics::Actor::Actor
Actor(BasePtr _parent)
Constructor.
gazebo::physics::Actor::GetSDF
virtual const sdf::ElementPtr GetSDF()
Get the SDF values for the actor.
gazebo::common::Mesh
A 3D mesh.
Definition: Mesh.hh:42
gazebo::physics::TrajectoryInfo::translated
bool translated
True if the trajectory is translated.
Definition: Actor.hh:65
gazebo::physics::Actor::Reset
void Reset()
Reset the actor.
gazebo::physics::TrajectoryInfo::type
std::string type
Type of trajectory.
Definition: Actor.hh:53
gazebo::physics::Actor::SkeletonAnimation_M
std::map< std::string, common::SkeletonAnimation * > SkeletonAnimation_M
Typedef the skeleton animation map, indexed by their names.
Definition: Actor.hh:78
gazebo::physics::Actor::active
bool active
True if the actor is being updated.
Definition: Actor.hh:303
gazebo::physics::Actor::ResetCustomTrajectory
void ResetCustomTrajectory()
Reset custom trajectory of the actor.
gazebo::physics::Actor::loop
bool loop
True if the animation should loop.
Definition: Actor.hh:300
gazebo::physics::Actor
Actor class enables GPU based mesh model / skeleton scriptable animation.
Definition: Actor.hh:74
gazebo::physics::Actor::trajectories
std::map< unsigned int, common::PoseAnimation * > trajectories
Map of all the trajectories (pose animations) and their indices.
Definition: Actor.hh:321
gazebo::physics::Actor::interpolateX
std::map< std::string, bool > interpolateX
Map of animation types (the same name as in skelAnimation and skelNodesMap) and whether they should b...
Definition: Actor.hh:351
gazebo::physics::Actor::bonePosePub
transport::PublisherPtr bonePosePub
Publisher to send bone info.
Definition: Actor.hh:369
gazebo::physics::Actor::Init
virtual void Init()
Initialize the actor.