Pogosim
Loading...
Searching...
No Matches
Pogowall Class Reference

Class representing a simulated Pogowall. More...

#include <robot.h>

Inheritance diagram for Pogowall:
PogobotObject PhysicalObject Object MembraneObject

Public Member Functions

 Pogowall (uint16_t _id, float _x, float _y, ObjectGeometry &geom, b2WorldId world_id, size_t _userdatasize, float _communication_radius=80.0f, std::unique_ptr< MsgSuccessRate > _msg_success_rate=std::make_unique< ConstMsgSuccessRate >(0.5), float _temporal_noise_stddev=0.0f, float _linear_damping=0.0f, float _angular_damping=0.0f, float _density=10.0f, float _friction=0.3f, float _restitution=0.5f, float _max_linear_speed=100.0f, float _max_angular_speed=1.0f, float _linear_noise_stddev=0.0f, float _angular_noise_stddev=0.0f, std::string const &_category="robots")
 Pogowall (Simulation *simulation, uint16_t _id, float _x, float _y, b2WorldId world_id, size_t _userdatasize, Configuration const &config, std::string const &_category="robots")
 Constructs a PogobotObject from a configuration entry.
virtual void set_motor (motor_id motor, int speed) override
 Updates the motor speed of the robot and recalculates its velocities. Pogobjects do not move, so this method will always set the motors to 0.
virtual b2Vec2 get_IR_emitter_position (ir_direction dir) const override
 Retrieves the IR emitters current positions.
virtual float get_IR_emitter_angle (ir_direction dir) const override
 World-frame bearing of the chosen IR emitter.
virtual void render (SDL_Renderer *, b2WorldId) const override
 Renders the robot on the given SDL renderer.
virtual void render_communication_channels (SDL_Renderer *, b2WorldId) const override
 Renders the communication channels originating from this robot.
virtual bool is_tangible () const override
 Returns whether this object is tangible (e.g. collisions, etc) or not.
virtual void move (float x, float y, float theta=NAN) override
 Move the object to a given coordinate.
Public Member Functions inherited from PogobotObject
 PogobotObject (uint16_t _id, float _x, float _y, ObjectGeometry &geom, b2WorldId world_id, size_t _userdatasize, float _communication_radius=80.0f, std::unique_ptr< MsgSuccessRate > _msg_success_rate=std::make_unique< ConstMsgSuccessRate >(0.5), float _temporal_noise_stddev=0.0f, float _linear_damping=0.0f, float _angular_damping=0.0f, float _density=10.0f, float _friction=0.3f, float _restitution=0.5f, float _max_linear_speed=100.0f, float _max_angular_speed=1.0f, float _linear_noise_stddev=0.0f, float _angular_noise_stddev=0.0f, bool _rotate_LEDs_45_deg=false, std::pair< int16_t, int16_t > angular_systematic_bias_domain={0, 0}, std::pair< int16_t, int16_t > photosensors_systematic_bias_domain={0, 0}, float _photosensors_noise_stddev=0.0f, std::string const &_category="robots", bool dummy=false)
 PogobotObject (Simulation *simulation, uint16_t _id, float _x, float _y, b2WorldId world_id, size_t _userdatasize, Configuration const &config, std::string const &_category="robots")
 Constructs a PogobotObject from a configuration entry.
virtual void launch_user_step (float t) override
 Launches the user-defined step function.
void register_stop_watch (time_reference_t *sw)
 Registers a stop watch with the robot.
void enable_stop_watches ()
 Enables all registered stop watches.
void disable_stop_watches ()
 Disables all registered stop watches.
virtual void update_time ()
 Updates the object's current time.
virtual b2Vec2 get_photosensor_position (uint8_t sensor_number) const
 Returns the position of a photosensor.
void send_to_neighbors (ir_direction dir, short_message_t *const message)
 Sends a short message to neighboring robots.
void send_to_neighbors (ir_direction dir, message_t *const message)
 Sends a message to neighboring robots.
void receive_message (message_t *const message, PogobotObject *source)
 Receive a message from another robot.
bool enable_user_steps () const
 Check if user steps are enabled.
void sleep_µs (uint64_t microseconds)
 Simulate a sleep on a single robot.
Public Member Functions inherited from PhysicalObject
 PhysicalObject (uint16_t _id, float _x, float _y, ObjectGeometry &geom, b2WorldId world_id, float _linear_damping=0.0f, float _angular_damping=0.0f, float _density=10.0f, float _friction=0.3f, float _restitution=0.5f, std::string const &_category="objects")
 Constructs a PhysicalObject.
 PhysicalObject (Simulation *simulation, uint16_t _id, float _x, float _y, b2WorldId world_id, Configuration const &config, std::string const &_category="objects")
 Constructs a PhysicalObject from a configuration entry.
virtual b2Vec2 get_position () const
 Retrieves the object's current position.
float get_angle () const
 Retrieves the object's current orientation angle.
float get_angular_velocity () const
 Retrieves the object's current angular velocity.
b2Vec2 get_linear_acceleration () const
 Retrieves the object's current angular velocity.
virtual arena_polygons_t generate_contours (std::size_t points_per_contour=0) const override
 Return one or more polygonal contours that represent the geometry of the object.
Public Member Functions inherited from Object
 Object (float _x, float _y, ObjectGeometry &_geom, std::string const &_category="objects")
 Constructs an Object.
 Object (Simulation *simulation, float _x, float _y, Configuration const &config, std::string const &_category="objects")
 Constructs an Object from a configuration entry.
virtual ~Object ()
 Destructor.
ObjectGeometryget_geometry ()
 Return the object's geometry.

Additional Inherited Members

Public Attributes inherited from PogobotObject
void * data = nullptr
 Pointer to user data.
void(* user_init )(void) = nullptr
 Pointer to a user-defined initialization function.
void(* user_step )(void) = nullptr
 Pointer to a user-defined step function.
bool _enable_user_steps = true
 Whether we allow user programs to be executed.
void(* callback_export_data )(void) = nullptr
 Callback to export data.
uint32_t pogobot_ticks = 0
 Simulation ticks counter.
uint8_t main_loop_hz = 60
 Main loop frequency in Hz.
uint8_t max_nb_processed_msg_per_tick = 3
 Maximum number of messages processed per tick.
void(* msg_rx_fn )(message_t *) = nullptr
 Function pointer for message reception.
bool(* msg_tx_fn )(void) = nullptr
 Function pointer for message transmission.
int8_t error_codes_led_idx = 3
 LED index for error codes.
time_reference_t _global_timer
 Global timer reference.
time_reference_t timer_main_loop
 Main loop timer reference.
uint32_t _current_time_milliseconds = 0
 Current time in milliseconds.
uint32_t _error_code_initial_time = 0
 Initial time for error code reporting.
uint8_t percent_msgs_sent_per_ticks = 20
 Percentage of messages sent per tick.
uint32_t nb_msgs_sent = 0
 Counter for messages sent.
uint32_t nb_msgs_recv = 0
 Counter for messages received.
std::set< time_reference_t * > stop_watches
 Set of registered stop watches.
float radius
 Radius of this robot.
float left_motor_speed = 0
 Current speed of the left motor.
float right_motor_speed = 0
 Current speed of the right motor.
bool show_lateral_leds = false
 Whether to render lateral LEDs.
std::vector< color_tleds = std::vector<color_t>(5, {0, 0, 0})
 LED colors for the robot.
std::vector< std::vector< PogobotObject * > > neighbors {ir_all+1}
 Pointers to neighboring robots.
std::queue< message_tmessages
 Queue of incoming messages.
float communication_radius
 Communication radius of each IR emitter.
std::unique_ptr< MsgSuccessRatemsg_success_rate
 Probability of successfully sending a message.
uint64_t current_time_microseconds = 0LL
 Current time in microseconds.
uint8_t motor_dir_mem [3] = {0, 1, 0}
 Motors current direction and power ([R, L, B]).
uint8_t motor_dir [3] = {0, 1, 0}
uint16_t motor_power_mem [3] = {512, 512, 0}
std::vector< int16_t > photosensors_biases = {0, 0, 0}
 Level of systematic bias to apply to each photosensor.
float photosensors_noise_stddev = 0.0f
 Stddev of the Gaussian noise to apply to photosensors light levels.
int16_t angular_bias = 0
Public Attributes inherited from PhysicalObject
uint16_t id
 Object identifier.
Public Attributes inherited from Object
float x
 X position.
float y
 Y position.
float theta
 Orientation (in rad).
std::string category
 Category of the object.
Protected Member Functions inherited from PogobotObject
void create_robot_body (b2WorldId world_id)
 Creates the object's physical body in the simulation.
void initialize_time ()
 Initialize time-related operations.
virtual void parse_configuration (Configuration const &config, Simulation *simulation) override
 Parse a provided configuration and set associated members values.
virtual void initialize_photosensors_bias (std::pair< int16_t, int16_t > &domain)
 Initialize the level of bias each photosensor has, based on provided configuration/parameters.
virtual void initialize_angular_bias (std::pair< int16_t, int16_t > &domain)
 Initialize the level of angular bias, based on provided configuration/parameters.
Protected Member Functions inherited from PhysicalObject
virtual void create_body (b2WorldId world_id)
 Creates the object's physical body in the simulation.
Protected Attributes inherited from PogobotObject
float temporal_noise = 0
float temporal_noise_stddev
float max_linear_speed
float max_angular_speed
float linear_noise_stddev
float angular_noise_stddev
bool rotate_LEDs_45_deg
Protected Attributes inherited from PhysicalObject
float linear_damping
float angular_damping
float density
float friction
float restitution
b2BodyId body_id
 Box2D body identifier.
float _estimated_dt = 0.0f
float _last_time = 0.0f
b2Vec2 _prev_v = {NAN, NAN}
b2Vec2 _lin_acc = {NAN, NAN}
Protected Attributes inherited from Object
ObjectGeometrygeom
 Geometry of the object.

Detailed Description

Class representing a simulated Pogowall.

Constructor & Destructor Documentation

◆ Pogowall() [1/2]

Pogowall::Pogowall ( uint16_t _id,
float _x,
float _y,
ObjectGeometry & geom,
b2WorldId world_id,
size_t _userdatasize,
float _communication_radius = 80.0f,
std::unique_ptr< MsgSuccessRate > _msg_success_rate = std::make_unique<ConstMsgSuccessRate>(0.5),
float _temporal_noise_stddev = 0.0f,
float _linear_damping = 0.0f,
float _angular_damping = 0.0f,
float _density = 10.0f,
float _friction = 0.3f,
float _restitution = 0.5f,
float _max_linear_speed = 100.0f,
float _max_angular_speed = 1.0f,
float _linear_noise_stddev = 0.0f,
float _angular_noise_stddev = 0.0f,
std::string const & _category = "robots" )

Initializes a new Pogobject robot with the specified identifier, user data size, initial position, radius, associated Box2D world, and message success rate. It also allows customization of the body's physical properties (linear and angular damping, density, friction, and restitution).

Parameters
_idUnique object identifier.
xInitial x-coordinate in the simulation.
yInitial y-coordinate in the simulation.
geomObject's geometry.
world_idThe Box2D world identifier.
_userdatasizeSize of the memory block allocated for user data.
_communication_radiuscommunication radius of each IR emitter
_msg_success_ratestd::unique_ptr<MsgSuccessRate> describing the probability of successfully sending a message.
_temporal_noise_stddevStandard deviation of the gaussian noise to apply to time on each object, or 0.0 for deterministic time
_linear_dampingLinear damping value for the physical body (default is 0.0f).
_angular_dampingAngular damping value for the physical body (default is 0.0f).
_densityDensity of the body shape (default is 10.0f).
_frictionFriction coefficient of the body shape (default is 0.3f).
_restitutionRestitution (bounciness) of the body shape (default is 0.5f).
_linear_noise_stddevStandard deviation of the gaussian noise to apply to linear velocity, or 0.0 for deterministic velocity
_angular_noise_stddevStandard deviation of the gaussian noise to apply to angular velocity, or 0.0 for deterministic velocity
categoryName of the category of the object.

◆ Pogowall() [2/2]

Pogowall::Pogowall ( Simulation * simulation,
uint16_t _id,
float _x,
float _y,
b2WorldId world_id,
size_t _userdatasize,
Configuration const & config,
std::string const & _category = "robots" )

Constructs a PogobotObject from a configuration entry.

Parameters
simulationPointer to the underlying simulation.
_idUnique object identifier.
xInitial x-coordinate in the simulation.
yInitial y-coordinate in the simulation.
world_idThe Box2D world identifier.
_userdatasizeSize of the memory block allocated for user data.
configConfiguration entry describing the object properties.

Member Function Documentation

◆ get_IR_emitter_angle()

float Pogowall::get_IR_emitter_angle ( ir_direction dir) const
overridevirtual

World-frame bearing of the chosen IR emitter.

For the four perimeter LEDs the bearing is the angle of the outward normal of the robot’s hull at that LED (i.e. ±90° from the tangent). For dir == MIDDLE we return the robot’s forward heading, so the caller still receives a meaningful direction.

Reimplemented from PogobotObject.

◆ get_IR_emitter_position()

b2Vec2 Pogowall::get_IR_emitter_position ( ir_direction dir) const
overridevirtual

Retrieves the IR emitters current positions.

Returns the position of one of the robot's IR emitter as a Box2D vector.

Returns
b2Vec2 The current position.

Reimplemented from PogobotObject.

◆ is_tangible()

virtual bool Pogowall::is_tangible ( ) const
inlineoverridevirtual

Returns whether this object is tangible (e.g. collisions, etc) or not.

Reimplemented from PhysicalObject.

Reimplemented in MembraneObject.

◆ move()

virtual void Pogowall::move ( float x,
float y,
float theta = NAN )
inlineoverridevirtual

Move the object to a given coordinate.

Parameters
xX coordinate.
yY coordinate.
thetaOrientation, in rad.

Reimplemented from PhysicalObject.

Reimplemented in MembraneObject.

◆ render()

virtual void Pogowall::render ( SDL_Renderer * ,
b2WorldId  ) const
inlineoverridevirtual

Renders the robot on the given SDL renderer.

Parameters
rendererPointer to the SDL_Renderer.
world_idThe Box2D world identifier (unused in rendering).

Reimplemented from PogobotObject.

Reimplemented in MembraneObject.

◆ render_communication_channels()

virtual void Pogowall::render_communication_channels ( SDL_Renderer * ,
b2WorldId  ) const
inlineoverridevirtual

Renders the communication channels originating from this robot.

Parameters
rendererPointer to the SDL_Renderer.
world_idThe Box2D world identifier (unused in rendering).

Reimplemented from PogobotObject.

◆ set_motor()

virtual void Pogowall::set_motor ( motor_id motor,
int speed )
inlineoverridevirtual

Updates the motor speed of the robot and recalculates its velocities. Pogobjects do not move, so this method will always set the motors to 0.

Parameters
motorThe identifier of the motor to update.
speed(Ignored) speed value for the selected motor.

Reimplemented from PogobotObject.

Reimplemented in MembraneObject.


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