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

#include <Simulable.h>

Inheritance diagram for mvsim::Simulable:
Inheritance graph
[legend]

Public Types

using Ptr = std::shared_ptr< Simulable >
 

Public Member Functions

 Simulable (World *parent)
 
virtual void simul_pre_timestep (const TSimulContext &context)
 
virtual void simul_post_timestep (const TSimulContext &context)
 
virtual void apply_force (const mrpt::math::TVector2D &force, const mrpt::math::TPoint2D &applyPoint=mrpt::math::TPoint2D(0, 0))
 
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
 

Protected Attributes

std::string name_
 

Detailed Description

The basic virtual base class for all objects that can run in the simulated mvsim::World

Member Function Documentation

◆ apply_force()

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

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 in mvsim::VehicleBase, mvsim::HumanActor, and mvsim::Block.

◆ getComVelocityGlobal()

mrpt::math::TTwist2D mvsim::Simulable::getComVelocityGlobal ( ) const

Last time-step velocity of the Box2D center of mass point, in global coords

◆ getElevationAt()

virtual std::optional<float> mvsim::Simulable::getElevationAt ( [[maybe_unused] ] const mrpt::math::TPoint2D &  worldXY) const
inlinevirtual

If the given world-frame 2D coordinates are within the limits of this entity, this method returns the ground height or elevation or "z" coordinate of the object for the queried (x,y). If the coordinates do not affect this object, it will return nullopt.

◆ getLinearAcceleration()

mrpt::math::TVector3D mvsim::Simulable::getLinearAcceleration ( ) const

Last time-step acceleration of the ref. point (global coords). Note this is the "coordinate acceleration" vector, not the proper acceleration. It is simply estimated as a finite difference of dq_.

◆ getName()

const std::string& mvsim::Simulable::getName ( ) const
inline

User-supplied name of the vehicle (e.g. "r1", "veh1")

◆ getPose()

mrpt::math::TPose3D mvsim::Simulable::getPose ( ) const

Last time-step pose (of the ref. point, in global coords) (ground-truth)

◆ getRefVelocityGlobal()

mrpt::math::TTwist2D mvsim::Simulable::getRefVelocityGlobal ( ) const

Last time-step velocity (of the reference point, in global coords) Note this is converted from Box2D center of mass velocity into our own reference point.

◆ getRefVelocityLocal()

mrpt::math::TTwist2D mvsim::Simulable::getRefVelocityLocal ( ) const

Last time-step velocity (of the reference point, in local coords) Note this is converted from Box2D center of mass velocity into our own reference point.

◆ getRelativePose()

virtual mrpt::math::TPose3D mvsim::Simulable::getRelativePose ( ) const
inlinevirtual

Like getPose(), but gets the relative pose with respect to the parent object, or just exactly like getPose() (global pose) if this is a top-level entity.

Reimplemented in mvsim::Lidar3D, mvsim::LaserScanner, mvsim::IMU, mvsim::GNSS, mvsim::DepthCameraSensor, and mvsim::CameraSensor.

◆ getVelocityLocal()

mrpt::math::TTwist2D mvsim::Simulable::getVelocityLocal ( ) const
inline

Deprecated: replace with getRefVelocityLocal()

◆ hadCollision()

bool mvsim::Simulable::hadCollision ( ) const

Whether a collision occurred since the last time this flag was manually reset.

See also
isInCollision(), resetCollisionFlag()

◆ isInCollision()

bool mvsim::Simulable::isInCollision ( ) const

Whether is is in collision right now.

See also

◆ resetCollisionFlag()

void mvsim::Simulable::resetCollisionFlag ( )

Resets the condition reported by hadCollision() to false

◆ setName()

void mvsim::Simulable::setName ( const std::string &  s)
inline

Changes object name (e.g. "r1", "veh1")

◆ setPose()

void mvsim::Simulable::setPose ( const mrpt::math::TPose3D &  p,
bool  notifyChange = true 
) const

Manually override vehicle pose (Use with caution!) (purposely set a "const")

◆ setRefVelocityLocal()

void mvsim::Simulable::setRefVelocityLocal ( const mrpt::math::TTwist2D &  dq)

Set the body twist in the local, body frame. The linear velocity corresponds to the object local origin. It is then internally converted into the velocity of the Box2D center of mass, in global coordinates as expected by Box2D.

◆ setRelativePose()

virtual void mvsim::Simulable::setRelativePose ( const mrpt::math::TPose3D &  p)
inlinevirtual

Changes the relative pose of this object with respect to its parent, or the global frame if its a top-level entity.

Reimplemented in mvsim::Lidar3D, mvsim::LaserScanner, mvsim::IMU, mvsim::GNSS, mvsim::DepthCameraSensor, and mvsim::CameraSensor.

◆ simul_post_timestep()

virtual void mvsim::Simulable::simul_post_timestep ( const TSimulContext context)
virtual

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 in mvsim::VerticalPlane, mvsim::HorizontalPlane, mvsim::ElevationMap, mvsim::VehicleBase, mvsim::Lidar3D, mvsim::LaserScanner, mvsim::IMU, mvsim::GNSS, mvsim::DepthCameraSensor, mvsim::CameraSensor, mvsim::HumanActor, mvsim::DummyInvisibleBlock, mvsim::Block, and mvsim::PropertyRegion.

◆ simul_pre_timestep()

virtual void mvsim::Simulable::simul_pre_timestep ( const TSimulContext context)
virtual

Member Data Documentation

◆ name_

std::string mvsim::Simulable::name_
protected

User-supplied name of the vehicle (e.g. "r1", "veh1")


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