11 #include <mrpt/opengl/CCylinder.h>
12 #include <mrpt/opengl/CSetOfObjects.h>
13 #include <mrpt/opengl/CSphere.h>
14 #include <mrpt/poses/CPose3DInterpolator.h>
15 #include <mrpt/version.h>
16 #include <mvsim/ClassFactory.h>
17 #include <mvsim/Simulable.h>
18 #include <mvsim/TParameterDefinitions.h>
19 #include <mvsim/VisualObject.h>
21 #define MIN_MRPT_VERSION_ANIMATED_ASSIMP 0x020f08
23 #if MRPT_VERSION >= MIN_MRPT_VERSION_ANIMATED_ASSIMP
24 #include <mrpt/opengl/CAnimatedAssimpModel.h>
26 #include <mrpt/opengl/CAssimpModel.h>
69 using Ptr = std::shared_ptr<HumanActor>;
95 const mrpt::math::TVector2D& force,
96 const mrpt::math::TPoint2D& applyPoint = mrpt::math::TPoint2D(0, 0))
override
108 mrpt::math::TPose3D pose;
124 void setPath(
const std::vector<Waypoint>& waypoints,
bool loop =
true);
141 void setWalkingSpeed(
double speed) {
walkingSpeed_ = speed; }
144 void setRunningSpeed(
double speed) {
runningSpeed_ = speed; }
146 double getHeight()
const {
return height_; }
147 void setHeight(
double h) {
height_ = h; }
151 double getCollisionRadius()
const {
return collisionRadius_; }
152 double getCollisionHeight()
const {
return collisionHeight_; }
155 void internalGuiUpdate(
156 const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& viz,
157 const mrpt::optional_ref<mrpt::opengl::COpenGLScene>& physical,
bool childrenOnly)
override;
166 double collisionRadius_ = 0.3;
167 double collisionHeight_ = 1.7;
170 std::string animNameIdle_ =
"idle";
171 std::string animNameWalk_ =
"walk";
172 std::string animNameRun_ =
"run";
180 {
"collision_radius", {
"%lf", &collisionRadius_}},
181 {
"collision_height", {
"%lf", &collisionHeight_}},
182 {
"animation_idle", {
"%s", &animNameIdle_}},
183 {
"animation_walk", {
"%s", &animNameWalk_}},
184 {
"animation_run", {
"%s", &animNameRun_}},
190 std::vector<Waypoint> path_;
191 bool pathLoop_ =
true;
192 size_t currentWaypointIdx_ = 0;
193 double waypointPauseTimer_ = 0.0;
194 bool isAtWaypoint_ =
false;
197 mrpt::math::TPose3D pathStartPose_;
198 mrpt::math::TPose3D pathTargetPose_;
199 double pathSegmentProgress_ = 0.0;
200 double pathSegmentLength_ = 0.0;
202 void initializePathFromCurrentPose();
207 bool manualAnimationOverride_ =
false;
208 std::string manualAnimationName_;
210 double currentAnimTime_ = 0.0;
211 double currentMovementSpeed_ = 0.0;
214 #if MRPT_VERSION >= MIN_MRPT_VERSION_ANIMATED_ASSIMP
215 mrpt::opengl::CAnimatedAssimpModel::Ptr glModel_;
217 mrpt::opengl::CAssimpModel::Ptr glModel_;
219 bool glInitialized_ =
false;
223 std::string modelFilePath_;
237 void updateAnimationState(
double dt);
240 void updateSkeletalAnimation(
double dt);
243 double computeDesiredSpeed()
const;
246 void advanceToNextWaypoint();
249 mrpt::math::TPose3D interpolatePathPose(
double progress)
const;
254 void upgradeToAnimatedModel();
Definition: HumanActor.h:67
void simul_post_timestep(const TSimulContext &context) override
AnimationState
Definition: HumanActor.h:115
double runningSpeed_
m/s
Definition: HumanActor.h:162
void apply_force(const mrpt::math::TVector2D &force, const mrpt::math::TPoint2D &applyPoint=mrpt::math::TPoint2D(0, 0)) override
Definition: HumanActor.h:94
static Ptr factory(World *parent, const rapidxml::xml_node< char > *xml_node)
void simul_pre_timestep(const TSimulContext &context) override
double walkingSpeed_
m/s (typical human walking speed)
Definition: HumanActor.h:161
void setPath(const std::vector< Waypoint > &waypoints, bool loop=true)
const TParameterDefinitions params_
Definition: HumanActor.h:176
void setAnimation(const std::string &animationName)
static void register_actor_class(const World &parent, const rapidxml::xml_node< char > *xml_node)
double height_
meters
Definition: HumanActor.h:163
void setAutomaticAnimation()
AnimationState getAnimationState() const
Definition: HumanActor.h:130
Definition: Simulable.h:40
Definition: VisualObject.h:36
Definition: HumanActor.h:107
std::string animationHint
"walk", "run", "idle", or empty
Definition: HumanActor.h:110
double pauseDuration
seconds to pause at this waypoint
Definition: HumanActor.h:109
Definition: basic_types.h:58