MVSim
Lightweight simulator for 2.5D vehicles and robots
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mvsim::HumanActor Class Reference

#include <HumanActor.h>

Inheritance diagram for mvsim::HumanActor:
Inheritance graph
[legend]
Collaboration diagram for mvsim::HumanActor:
Collaboration graph
[legend]

Classes

struct  Waypoint
 

Public Types

enum class  AnimationState {
  Idle , Walking , Running , Turning ,
  Custom
}
 
using Ptr = std::shared_ptr< HumanActor >
 
- Public Types inherited from mvsim::Simulable
using Ptr = std::shared_ptr< Simulable >
 

Public Member Functions

 HumanActor (World *parent)
 
 HumanActor (const HumanActor &)=delete
 
HumanActoroperator= (const HumanActor &)=delete
 
 HumanActor (HumanActor &&)=delete
 
HumanActoroperator= (HumanActor &&)=delete
 
void simul_pre_timestep (const TSimulContext &context) override
 
void simul_post_timestep (const TSimulContext &context) override
 
void apply_force (const mrpt::math::TVector2D &force, const mrpt::math::TPoint2D &applyPoint=mrpt::math::TPoint2D(0, 0)) override
 
void setPath (const std::vector< Waypoint > &waypoints, bool loop=true)
 
void clearPath ()
 
AnimationState getAnimationState () const
 
void setAnimation (const std::string &animationName)
 
void setAutomaticAnimation ()
 
double getWalkingSpeed () const
 
void setWalkingSpeed (double speed)
 
double getRunningSpeed () const
 
void setRunningSpeed (double speed)
 
double getHeight () const
 
void setHeight (double h)
 
double getCollisionRadius () const
 
double getCollisionHeight () const
 
- Public Member Functions inherited from mvsim::VisualObject
 VisualObject (World *parent, bool insertCustomVizIntoViz=true, bool insertCustomVizIntoPhysical=true)
 
 VisualObject (const VisualObject &)=delete
 
VisualObjectoperator= (const VisualObject &)=delete
 
 VisualObject (VisualObject &&)=delete
 
VisualObjectoperator= (VisualObject &&)=delete
 
virtual void guiUpdate (const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &viz, const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &physical)
 
Worldparent ()
 
const Worldparent () const
 
void customVisualVisible (const bool visible)
 
bool customVisualVisible () const
 
const std::optional< Shape2p5 > & collisionShape () const
 
void showCollisionShape (bool show)
 
- Public Member Functions inherited from mvsim::Simulable
 Simulable (World *parent)
 
virtual VisualObjectmeAsVisualObject ()
 
mrpt::math::TTwist2D getRefVelocityLocal () const
 
mrpt::math::TTwist2D getVelocityLocal () const
 
mrpt::math::TTwist2D getRefVelocityGlobal () const
 
mrpt::math::TTwist2D getComVelocityGlobal () const
 
mrpt::math::TPose3D getPose () const
 
virtual mrpt::math::TPose3D getRelativePose () const
 
mrpt::math::TPose3D getPoseNoLock () const
 No thread-safe version. Used internally only.
 
mrpt::math::TVector3D getLinearAcceleration () const
 
void setPose (const mrpt::math::TPose3D &p, bool notifyChange=true) const
 
virtual void setRelativePose (const mrpt::math::TPose3D &p)
 
void setRefVelocityLocal (const mrpt::math::TTwist2D &dq)
 
mrpt::poses::CPose2D getCPose2D () const
 Alternative to getPose()
 
mrpt::poses::CPose3D getCPose3D () const
 Alternative to getPose()
 
const std::string & getName () const
 
void setName (const std::string &s)
 
bool isInCollision () const
 
bool hadCollision () const
 
void resetCollisionFlag ()
 
virtual void registerOnServer (mvsim::Client &c)
 
const b2Body * b2d_body () const
 
b2Body * b2d_body ()
 
WorldgetSimulableWorldObject ()
 
const WorldgetSimulableWorldObject () const
 
virtual void freeOpenGLResources ()
 
virtual std::optional< float > getElevationAt ([[maybe_unused]] const mrpt::math::TPoint2D &worldXY) const
 

Static Public Member Functions

static Ptr factory (World *parent, const rapidxml::xml_node< char > *xml_node)
 
static void register_actor_class (const World &parent, const rapidxml::xml_node< char > *xml_node)
 
- Static Public Member Functions inherited from mvsim::VisualObject
static void FreeOpenGLResources ()
 

Protected Member Functions

void internalGuiUpdate (const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &viz, const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &physical, bool childrenOnly) override
 
- Protected Member Functions inherited from mvsim::VisualObject
bool parseVisual (const rapidxml::xml_node< char > &rootNode)
 Returns true if there is at least one <visual>...</visual> entry.
 
bool parseVisual (const JointXMLnode<> &rootNode)
 
void addCustomVisualization (const mrpt::opengl::CRenderizable::Ptr &glModel, const mrpt::poses::CPose3D &modelPose={}, const float modelScale=1.0f, const std::string &modelName="group", const std::optional< std::string > &modelURI=std::nullopt, const bool initialShowBoundingBox=false, const std::optional< double > &scaleOverride=std::nullopt)
 
void setCollisionShape (const Shape2p5 &cs)
 

Protected Attributes

double walkingSpeed_ = 1.4
 m/s (typical human walking speed)
 
double runningSpeed_ = 3.5
 m/s
 
double height_ = 1.75
 meters
 
double collisionRadius_ = 0.3
 
double collisionHeight_ = 1.7
 
std::string animNameIdle_ = "idle"
 
std::string animNameWalk_ = "walk"
 
std::string animNameRun_ = "run"
 
const TParameterDefinitions params_
 
- Protected Attributes inherited from mvsim::VisualObject
Worldworld_
 
std::shared_ptr< mrpt::opengl::CSetOfObjects > glCustomVisual_
 
std::shared_ptr< mrpt::opengl::CSetOfObjects > glCollision_
 
int32_t glCustomVisualId_ = -1
 
const bool insertCustomVizIntoViz_ = true
 
const bool insertCustomVizIntoPhysical_ = true
 
- Protected Attributes inherited from mvsim::Simulable
std::string name_
 

Additional Inherited Members

- Static Public Attributes inherited from mvsim::VisualObject
static double GeometryEpsilon
 

Detailed Description

A walking human actor with skeletal animation support.

Actors follow predefined paths (waypoints) and play appropriate animations (idle, walk, run) based on movement speed. They are purely kinematic: they do not respond to external forces.

XML usage example:

<actor:class name="pedestrian">
<walking_speed>1.4</walking_speed>
<animation_walk>walk</animation_walk>
<animation_idle>idle</animation_idle>
<visual>
<model_uri>https://example.com/human.glb</model_uri>
</visual>
</actor:class>
<actor name="person1" class="pedestrian">
<init_pose>5 10 0</init_pose>
<path type="waypoints" loop="true">
<waypoint>0 0 0</waypoint>
<waypoint>10 0 0</waypoint>
<waypoint>10 10 90</waypoint>
</path>
</actor>

Member Enumeration Documentation

◆ AnimationState

Animation state machine states

Member Function Documentation

◆ apply_force()

void mvsim::HumanActor::apply_force ( const mrpt::math::TVector2D &  force,
const mrpt::math::TPoint2D &  applyPoint = mrpt::math::TPoint2D(0, 0) 
)
inlineoverridevirtual

Override to register external forces exerted by other WorldElements. Force is (fx,fy) in global coordinates. Application point is (local_ptx,local_pty) in the body local frame

Reimplemented from mvsim::Simulable.

◆ clearPath()

void mvsim::HumanActor::clearPath ( )

Clear current path.

◆ factory()

static Ptr mvsim::HumanActor::factory ( World parent,
const rapidxml::xml_node< char > *  xml_node 
)
static

Class factory: Creates an actor from XML "<actor>...</actor>"

◆ getAnimationState()

AnimationState mvsim::HumanActor::getAnimationState ( ) const
inline

Get current animation state.

◆ register_actor_class()

static void mvsim::HumanActor::register_actor_class ( const World parent,
const rapidxml::xml_node< char > *  xml_node 
)
static

Register a new actor class from "<actor:class name='xxx'>...</actor:class>"

◆ setAnimation()

void mvsim::HumanActor::setAnimation ( const std::string &  animationName)

Manually set animation (overrides automatic selection).

◆ setAutomaticAnimation()

void mvsim::HumanActor::setAutomaticAnimation ( )

Return to automatic animation selection based on movement.

◆ setPath()

void mvsim::HumanActor::setPath ( const std::vector< Waypoint > &  waypoints,
bool  loop = true 
)

Set waypoint-based path.

◆ simul_post_timestep()

void mvsim::HumanActor::simul_post_timestep ( const TSimulContext context)
overridevirtual

Override to do any required process right after the integration of dynamic equations for each timestep. IMPORTANT: Reimplementations MUST also call this base method, since it is in charge of important tasks (e.g. update q_, dq_)

Reimplemented from mvsim::Simulable.

◆ simul_pre_timestep()

void mvsim::HumanActor::simul_pre_timestep ( const TSimulContext context)
overridevirtual

Process right before the integration of dynamic equations for each timestep: set action forces from motors, update friction models, etc.

Reimplemented from mvsim::Simulable.

Member Data Documentation

◆ params_

const TParameterDefinitions mvsim::HumanActor::params_
protected
Initial value:
= {
{"walking_speed", {"%lf", &walkingSpeed_}},
{"running_speed", {"%lf", &runningSpeed_}},
{"height", {"%lf", &height_}},
{"collision_radius", {"%lf", &collisionRadius_}},
{"collision_height", {"%lf", &collisionHeight_}},
{"animation_idle", {"%s", &animNameIdle_}},
{"animation_walk", {"%s", &animNameWalk_}},
{"animation_run", {"%s", &animNameRun_}},
}
double runningSpeed_
m/s
Definition: HumanActor.h:162
double walkingSpeed_
m/s (typical human walking speed)
Definition: HumanActor.h:161
double height_
meters
Definition: HumanActor.h:163

XML-parseable parameter table, follows the Block pattern. Addresses point to the member variables above.


The documentation for this class was generated from the following file: