|
MVSim
Lightweight simulator for 2.5D vehicles and robots
|
#include <HumanActor.h>


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 | |
| HumanActor & | operator= (const HumanActor &)=delete |
| HumanActor (HumanActor &&)=delete | |
| HumanActor & | operator= (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 | |
| VisualObject & | operator= (const VisualObject &)=delete |
| VisualObject (VisualObject &&)=delete | |
| VisualObject & | operator= (VisualObject &&)=delete |
| virtual void | guiUpdate (const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &viz, const mrpt::optional_ref< mrpt::opengl::COpenGLScene > &physical) |
| World * | parent () |
| const World * | parent () 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 VisualObject * | meAsVisualObject () |
| 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 () |
| World * | getSimulableWorldObject () |
| const World * | getSimulableWorldObject () 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 | |
| World * | world_ |
| 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 |
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:
|
strong |
Animation state machine states
|
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.
| void mvsim::HumanActor::clearPath | ( | ) |
Clear current path.
|
static |
Class factory: Creates an actor from XML "<actor>...</actor>"
|
inline |
Get current animation state.
|
static |
Register a new actor class from "<actor:class name='xxx'>...</actor:class>"
| void mvsim::HumanActor::setAnimation | ( | const std::string & | animationName | ) |
Manually set animation (overrides automatic selection).
| void mvsim::HumanActor::setAutomaticAnimation | ( | ) |
Return to automatic animation selection based on movement.
| void mvsim::HumanActor::setPath | ( | const std::vector< Waypoint > & | waypoints, |
| bool | loop = true |
||
| ) |
Set waypoint-based path.
|
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.
|
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.
|
protected |
XML-parseable parameter table, follows the Block pattern. Addresses point to the member variables above.