Class jalansim::Sim

template <typename T, typename DynamicsModelT, typename CollisionT, typename RangeT>

ClassList > jalansim > Sim

Main simulation class for Sim .More...

  • #include <sim.hpp>

Public Types

Type Name
typedef CollisionT Collision
typedef dynamics::Dynamics< T, DynamicsModelT > Dynamics
typedef DynamicsModelT DynamicsModel
typedef map::Map< T > Map

Public Static Attributes

Type Name
std::size_t INPUT_DIM = DynamicsModelT::INPUT\_DIM
std::size_t STATE_DIM = DynamicsModelT::STATE\_DIM

Public Functions

Type Name
constexpr Sim () = default
Default constructor.
JALANSIM_HOST_DEVICE Sim (const DynamicsModelT & dm)
Constructor with dynamics model.
JALANSIM_HOST_DEVICE Sim (const DynamicsModelT & dm, const CollisionT & cp)
Constructor with dynamics model and collision checker.
JALANSIM_HOST_DEVICE bool collided () const
Check if agent has collided at current position.
JALANSIM_HOST_DEVICE bool collided (T x, T y, T theta=T(0.0)) const
Check if agent has collided at specified position.
JALANSIM_HOST_DEVICE Dynamics & dynamics ()
Get reference to dynamics object.
JALANSIM_HOST_DEVICE const Dynamics & dynamics () const
Get reference to dynamics object (const version).
JALANSIM_HOST_DEVICE Map * get_map ()
Get the simulation map.
JALANSIM_HOST_DEVICE Map * get_map () const
Get the simulation map (const version).
std::vector< T > get_range (int num_beams, T fov, T max_range) const
Get range measurements for all beams in the sensor array.
JALANSIM_HOST_DEVICE T get_range_single (int num_beams, T fov, T max_range, int beam_idx) const
Get range measurement for a single beam.
JALANSIM_HOST_DEVICE T * get_state ()
Get pointer to agent's state vector.
JALANSIM_HOST_DEVICE const T * get_state () const
Get pointer to agent's state vector (const version).
JALANSIM_HOST_DEVICE void reset ()
Reset the agent's state to initial conditions.
JALANSIM_HOST_DEVICE void set_map (Map * m)
Set the simulation map.
JALANSIM_HOST_DEVICE void set_state (const T * state)
Set the agent's state.
JALANSIM_HOST_DEVICE void step (const T * u, T dt, dynamics::Scheme scheme=dynamics::Scheme::Euler)
Advance simulation by one time step.

Detailed Description

Provides vehicle dynamics, collision checking, and range sensing for a simulated agent in a 2D map environment. Supports customizable dynamics, collision, and range models via template parameters.

Template parameters:

  • T Numeric type (e.g., float, double)
  • DynamicsModelT Vehicle dynamics model type
  • CollisionT Collision checking model type (default: PolygonCollision)
  • RangeT Range sensing model type (default: Bresenham)

Public Types Documentation

typedef Collision

using jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::Collision =  CollisionT;

typedef Dynamics

using jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::Dynamics =  dynamics::Dynamics<T, DynamicsModelT>;

typedef DynamicsModel

using jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::DynamicsModel =  DynamicsModelT;

typedef Map

using jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::Map =  map::Map<T>;

Public Static Attributes Documentation

variable INPUT_DIM

std::size_t jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::INPUT_DIM;

variable STATE_DIM

std::size_t jalansim::Sim< T, DynamicsModelT, CollisionT, RangeT >::STATE_DIM;

Public Functions Documentation

function Sim [1/3]

Default constructor.

constexpr jalansim::Sim::Sim () = default

function Sim [2/3]

Constructor with dynamics model.

inline explicit JALANSIM_HOST_DEVICE jalansim::Sim::Sim (
    const DynamicsModelT & dm
) 

Parameters:

  • dm Dynamics model to use for simulation

function Sim [3/3]

Constructor with dynamics model and collision checker.

inline JALANSIM_HOST_DEVICE jalansim::Sim::Sim (
    const DynamicsModelT & dm,
    const CollisionT & cp
) 

Parameters:

  • dm Dynamics model to use for simulation
  • cp Collision checker configuration

function collided [1/2]

Check if agent has collided at current position.

inline JALANSIM_HOST_DEVICE bool jalansim::Sim::collided () const

Returns:

True if collision detected, false otherwise


function collided [2/2]

Check if agent has collided at specified position.

inline JALANSIM_HOST_DEVICE bool jalansim::Sim::collided (
    T x,
    T y,
    T theta=T(0.0)
) const

Parameters:

  • x X coordinate to check
  • y Y coordinate to check
  • theta Orientation angle (default: 0.0)

Returns:

True if collision detected, false otherwise


function dynamics [1/2]

Get reference to dynamics object.

inline JALANSIM_HOST_DEVICE Dynamics & jalansim::Sim::dynamics () 

Returns:

Reference to dynamics object


function dynamics [2/2]

Get reference to dynamics object (const version).

inline JALANSIM_HOST_DEVICE const Dynamics & jalansim::Sim::dynamics () const

Returns:

Reference to dynamics object


function get_map [1/2]

Get the simulation map.

inline JALANSIM_HOST_DEVICE Map * jalansim::Sim::get_map () 

Returns:

Pointer to the map object


function get_map [2/2]

Get the simulation map (const version).

inline JALANSIM_HOST_DEVICE Map * jalansim::Sim::get_map () const

Returns:

Pointer to the map object


function get_range

Get range measurements for all beams in the sensor array.

inline std::vector< T > jalansim::Sim::get_range (
    int num_beams,
    T fov,
    T max_range
) const

Parameters:

  • num_beams Total number of beams
  • fov Field of view in radians
  • max_range Maximum sensing range

Returns:

Vector of range measurements for all beams


function get_range_single

Get range measurement for a single beam.

inline JALANSIM_HOST_DEVICE T jalansim::Sim::get_range_single (
    int num_beams,
    T fov,
    T max_range,
    int beam_idx
) const

Parameters:

  • num_beams Total number of beams in the sensor
  • fov Field of view in radians
  • max_range Maximum sensing range
  • beam_idx Index of the beam to compute

Returns:

Range measurement for the specified beam


function get_state [1/2]

Get pointer to agent's state vector.

inline JALANSIM_HOST_DEVICE T * jalansim::Sim::get_state () 

Returns:

Pointer to state array


function get_state [2/2]

Get pointer to agent's state vector (const version).

inline JALANSIM_HOST_DEVICE const T * jalansim::Sim::get_state () const

Returns:

Pointer to state array


function reset

Reset the agent's state to initial conditions.

inline JALANSIM_HOST_DEVICE void jalansim::Sim::reset () 

function set_map

Set the simulation map.

inline JALANSIM_HOST_DEVICE void jalansim::Sim::set_map (
    Map * m
) 

Parameters:

  • m Pointer to the map object

function set_state

Set the agent's state.

inline JALANSIM_HOST_DEVICE void jalansim::Sim::set_state (
    const T * state
) 

Parameters:

  • state Array containing new state values

function step

Advance simulation by one time step.

inline JALANSIM_HOST_DEVICE void jalansim::Sim::step (
    const T * u,
    T dt,
    dynamics::Scheme scheme=dynamics::Scheme::Euler
) 

Parameters:

  • u Control input array
  • dt Time step size
  • scheme Integration scheme (default: Euler)


The documentation for this class was generated from the following file include/jalansim/sim.hpp