Pogosim
Loading...
Searching...
No Matches
spogobot.h File Reference
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
#include "FifoBuffer.h"

Go to the source code of this file.

Classes

union  emitting_power_list_t
struct  slip_error_counter_s
struct  message_header_t
struct  message_t
struct  message_short_header_t
struct  short_message_t
struct  time_reference_t

Macros

#define SIMULATOR
#define main   robot_main
#define IR_RX_COUNT   4
#define MAX_PAYLOAD_SIZE_BYTES   382
#define MAX_NUMBER_OF_WORD   20
#define pogobot_infrared_emitter_power_max   3
#define pogobot_infrared_emitter_power_twoThird   2
#define pogobot_infrared_emitter_power_oneThird   1
#define pogobot_infrared_emitter_power_null   0
#define pogobot_infrared_emitter_width_bits   2
#define pogobot_infrared_emitting_power_list(front, right, back, left)
#define get_infrared_emitter_dir(dir, emitting_power_list)
#define pogobot_infrared_emitter_front_mask   ( 1 << 0 )
#define pogobot_infrared_emitter_right_mask   ( 1 << 8 )
#define pogobot_infrared_emitter_back_mask   ( 1 << 16 )
#define pogobot_infrared_emitter_left_mask   ( 1 << 24 )
#define pogobot_infrared_emitter_mask_byindex(index)
#define NUMEL   20
#define init_from_configuration(x)
#define init_array_from_configuration(a)
#define printf   pogosim_printf
#define putchar   pogosim_putchar

Typedefs

typedef union emitting_power_list_t emitting_power_list_t
typedef struct message_header_t message_header_t
typedef struct message_t message_t
typedef struct message_short_header_t message_short_header_t
typedef struct short_message_t short_message_t
typedef struct time_reference_t time_reference_t

Enumerations

enum  {
  pogobot_infrared_emitting_power_list_front_full , pogobot_infrared_emitting_power_list_right_full , pogobot_infrared_emitting_power_list_back_full , pogobot_infrared_emitting_power_list_left_full ,
  pogobot_infrared_emitting_power_list_all_full
}
enum  ir_direction {
  ir_front = 0 , ir_right = 1 , ir_back = 2 , ir_left = 3 ,
  ir_all = 4
}
enum  ir_type_message { ir_t_cmd = 1 , ir_t_flash = 2 , ir_t_short = 3 , ir_t_user = 16 }
enum  photosensor_id { p_FL = 1 , p_FR = 2 , p_B = 0 }
enum  motor_id { motorR = 0 , motorL = 1 , motorB = 2 }
enum  motor_range {
  motorStop = 0 , motorQuarter = 256 , motorHalf = 512 , motorThreeQuarter = 716 ,
  motorFull = 1023
}

Functions

void pogobot_init (void)
 FifoBuffer_typedef (message_t, Messagefifo)
void pogobot_infrared_ll_init (void)
void pogobot_infrared_update (void)
int pogobot_infrared_message_available (void)
void pogobot_infrared_recover_next_message (message_t *mes)
void pogobot_infrared_clear_message_queue (void)
void pogobot_infrared_set_power (uint8_t power)
uint32_t pogobot_infrared_sendRawLongMessage (message_t *const message)
uint32_t pogobot_infrared_sendRawShortMessage (ir_direction dir, short_message_t *const message)
uint32_t pogobot_infrared_sendLongMessage_uniSpe (ir_direction dir, uint8_t *message, uint16_t message_size)
uint32_t pogobot_infrared_sendLongMessage_omniGen (uint8_t *message, uint16_t message_size)
uint32_t pogobot_infrared_sendLongMessage_omniSpe (uint8_t *message, uint16_t message_size)
uint32_t pogobot_infrared_sendShortMessage_uni (ir_direction dir, uint8_t *message, uint16_t message_size)
uint32_t pogobot_infrared_sendShortMessage_omni (uint8_t *message, uint16_t message_size)
void pogobot_infrared_get_receiver_error_counter (slip_error_counter_s *error_counter, uint8_t ir_index)
void pogobot_infrared_reset_receiver_error_counter (void)
void pogobot_led_setColor (const uint8_t r, const uint8_t g, const uint8_t b)
void pogobot_led_setColors (const uint8_t r, const uint8_t g, const uint8_t b, uint8_t id)
int16_t pogobot_photosensors_read (uint8_t sensor_number)
void pogobot_imu_read (float *acc, float *gyro)
float pogobot_imu_readTemp (void)
int16_t pogobot_battery_voltage_read (void)
void pogobot_motor_power_set (motor_id motor, uint16_t value)
void pogobot_motor_set (motor_id motor, uint16_t value)
uint32_t pogobot_motor_dir_current_status (void)
int8_t pogobot_motor_dir_mem_get (uint8_t *p_directions)
int8_t pogobot_motor_dir_mem_set (uint8_t *p_directions)
void pogobot_motor_dir_set (motor_id motor, uint8_t value)
uint8_t pogobot_motor_power_mem_get (uint16_t *p_powers)
uint8_t pogobot_motor_power_mem_set (uint16_t *p_powers)
uint16_t pogobot_helper_getid (void)
int16_t pogobot_helper_getRandSeed (void)
void pogobot_helper_print_version (void)
void pli_timer_sleep_stopwatch_init (void)
void pogobot_stopwatch_reset (time_reference_t *stopwatch)
int32_t pogobot_stopwatch_lap (time_reference_t *stopwatch)
int32_t pogobot_stopwatch_get_elapsed_microseconds (time_reference_t *stopwatch)
void pogobot_stopwatch_offset_origin_microseconds (time_reference_t *stopwatch, int32_t microseconds_offset)
void pogobot_timer_init (time_reference_t *timer, int32_t microseconds_to_go)
int32_t pogobot_timer_get_remaining_microseconds (time_reference_t *timer)
bool pogobot_timer_has_expired (time_reference_t *timer)
void pogobot_timer_wait_for_expiry (time_reference_t *timer)
void pogobot_timer_offset_origin_microseconds (time_reference_t *timer, int32_t microseconds_offset)
void msleep (int milliseconds)
void pogosim_printf (const char *format,...)
int pogosim_putchar (int ch)
uint32_t get_nb_robots (void)
void stop_simulation (void)
void data_add_column_int8 (char const *name)
void data_add_column_int16 (char const *name)
void data_add_column_int32 (char const *name)
void data_add_column_int64 (char const *name)
void data_add_column_double (char const *name)
void data_add_column_string (char const *name)
void data_add_column_bool (char const *name)
void data_add_column_float16 (char const *name)
void enable_data_export (void)
void disable_data_export (void)
void data_set_value_int8 (char const *name, int8_t value)
void data_set_value_int16 (char const *name, int16_t value)
void data_set_value_int32 (char const *name, int32_t value)
void data_set_value_int64 (char const *name, int64_t value)
void data_set_value_double (char const *name, double value)
void data_set_value_string (char const *name, char const *value)
void data_set_value_bool (char const *name, bool value)
void data_set_value_float16 (char const *name, float value)
void init_bool_from_configuration (bool *var, char const *name, bool const default_value)
void init_double_from_configuration (double *var, char const *name, double const default_value)
void init_float_from_configuration (float *var, char const *name, float const default_value)
void init_int32_from_configuration (int32_t *var, char const *name, int32_t const default_value)
void init_uint32_from_configuration (uint32_t *var, char const *name, uint32_t const default_value)
void init_int16_from_configuration (int16_t *var, char const *name, int16_t const default_value)
void init_uint16_from_configuration (uint16_t *var, char const *name, uint16_t const default_value)
void init_int8_from_configuration (int8_t *var, char const *name, int8_t const default_value)
void init_uint8_from_configuration (uint8_t *var, char const *name, uint8_t const default_value)
void init_float_array_from_configuration (float *var, char const *name, size_t const size)
void init_double_array_from_configuration (double *var, char const *name, size_t const size)
void init_string_from_configuration (char *var, char const *name, size_t const size)

Variables

Messagefifo my_mes_fifo
Messagefifo * my_mes_fifo_p

Macro Definition Documentation

◆ get_infrared_emitter_dir

#define get_infrared_emitter_dir ( dir,
emitting_power_list )
Value:
(((emitting_power_list) >> ((pogobot_infrared_emitter_width_bits) * (dir))) & 0x03)
#define pogobot_infrared_emitter_width_bits
Definition spogobot.h:80

◆ init_array_from_configuration

#define init_array_from_configuration ( a)
Value:
_Generic (&(a), \
)((a), #a, sizeof(a) / sizeof((a)[0]))
void init_double_array_from_configuration(double *var, char const *name, size_t const size)
Definition spogobot.cpp:692
void init_string_from_configuration(char *var, char const *name, std::size_t size)
Definition spogobot.cpp:650
void init_float_array_from_configuration(float *var, char const *name, size_t const size)
Definition spogobot.cpp:676

◆ init_from_configuration

#define init_from_configuration ( x)
Value:
_Generic ((x), \
)(&(x), #x, (x))
void init_uint16_from_configuration(uint16_t *var, char const *name, uint16_t const default_value)
Definition spogobot.cpp:623
void init_double_from_configuration(double *var, char const *name, double const default_value)
Definition spogobot.cpp:602
void init_uint32_from_configuration(uint32_t *var, char const *name, uint32_t const default_value)
Definition spogobot.cpp:615
void init_int16_from_configuration(int16_t *var, char const *name, int16_t const default_value)
Definition spogobot.cpp:619
void init_float_from_configuration(float *var, char const *name, float const default_value)
Definition spogobot.cpp:606
void init_int32_from_configuration(int32_t *var, char const *name, int32_t const default_value)
Definition spogobot.cpp:611
void init_int8_from_configuration(int8_t *var, char const *name, int8_t const default_value)
Definition spogobot.cpp:627
void init_uint8_from_configuration(uint8_t *var, char const *name, uint8_t const default_value)
Definition spogobot.cpp:631
void init_bool_from_configuration(bool *var, char const *name, bool const default_value)
Definition spogobot.cpp:598

◆ IR_RX_COUNT

#define IR_RX_COUNT   4

◆ main

#define main   robot_main

◆ MAX_NUMBER_OF_WORD

#define MAX_NUMBER_OF_WORD   20

Maximum number of word from IR recovers in one step

MAX_NUMBER_OF_WORD 20

◆ MAX_PAYLOAD_SIZE_BYTES

#define MAX_PAYLOAD_SIZE_BYTES   382

Maximum size of a payload in a IR message

MAX_PAYLOAD_SIZE_BYTES 384

◆ NUMEL

#define NUMEL   20

◆ pogobot_infrared_emitter_back_mask

#define pogobot_infrared_emitter_back_mask   ( 1 << 16 )

◆ pogobot_infrared_emitter_front_mask

#define pogobot_infrared_emitter_front_mask   ( 1 << 0 )

◆ pogobot_infrared_emitter_left_mask

#define pogobot_infrared_emitter_left_mask   ( 1 << 24 )

◆ pogobot_infrared_emitter_mask_byindex

#define pogobot_infrared_emitter_mask_byindex ( index)
Value:
( 1 << ( 8 * index ) )

◆ pogobot_infrared_emitter_power_max

#define pogobot_infrared_emitter_power_max   3

IR power level values:

  • pogobot_infrared_emitter_power_max - 3
  • pogobot_infrared_emitter_power_twoThird - 2
  • pogobot_infrared_emitter_power_oneThird - 1
  • pogobot_infrared_emitter_power_null - 0

◆ pogobot_infrared_emitter_power_null

#define pogobot_infrared_emitter_power_null   0

◆ pogobot_infrared_emitter_power_oneThird

#define pogobot_infrared_emitter_power_oneThird   1

◆ pogobot_infrared_emitter_power_twoThird

#define pogobot_infrared_emitter_power_twoThird   2

◆ pogobot_infrared_emitter_right_mask

#define pogobot_infrared_emitter_right_mask   ( 1 << 8 )

◆ pogobot_infrared_emitter_width_bits

#define pogobot_infrared_emitter_width_bits   2

◆ pogobot_infrared_emitting_power_list

#define pogobot_infrared_emitting_power_list ( front,
right,
back,
left )
Value:
( front ) | ( ( right ) << ( pogobot_infrared_emitter_width_bits ) ) | \
( ( back ) << ( 2 * pogobot_infrared_emitter_width_bits ) ) | \
( ( left ) << ( 3 * pogobot_infrared_emitter_width_bits ) )

◆ printf

#define printf   pogosim_printf

◆ putchar

#define putchar   pogosim_putchar

◆ SIMULATOR

#define SIMULATOR

Typedef Documentation

◆ emitting_power_list_t

typedef union emitting_power_list_t emitting_power_list_t

◆ message_header_t

typedef struct message_header_t message_header_t

IR message header structure

message_header_t :

The parameters that begin with "_" are not completed by the user

  • uint8_t _packet_type - allows to give type of a packet (fixed for now)
  • uint8_t _emitting_power_list - used to define the emission power on each IR
  • uint16_t _sender_id - id of the robot which send the message
  • uint8_t _sender_ir_index - IR id direction of the sender robot
  • uint8_t _receiver_ir_index - IR id direction that received the message
  • uint16_t payload_length - size of the payload

◆ message_short_header_t

typedef struct message_short_header_t message_short_header_t

IR short message header structure

message_short_header_t :

The parameters that begin with "_" are not completed by the user

  • uint8_t _packet_type - allows to give type of a packet (fixed for now)
  • uint16_t payload_length - size of the payload

◆ message_t

typedef struct message_t message_t

IR message header structure

message_t :

  • message_header_t header - header of the message
  • uint8_t payload[MAX_PAYLOAD_SIZE_BYTES] - payload of the message

◆ short_message_t

typedef struct short_message_t short_message_t

IR short message header structure

short_message_t :

  • message_short_header_t header - header of the message
  • uint8_t payload[MAX_PAYLOAD_SIZE_BYTES] - payload of the message

◆ time_reference_t

typedef struct time_reference_t time_reference_t

Timer structure

time_reference_t :

  • uint32_t hardware_value_at_time_origin - timer reference

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
pogobot_infrared_emitting_power_list_front_full 
pogobot_infrared_emitting_power_list_right_full 
pogobot_infrared_emitting_power_list_back_full 
pogobot_infrared_emitting_power_list_left_full 
pogobot_infrared_emitting_power_list_all_full 

◆ ir_direction

IR direction id list

  • ir_front - 0
  • ir_right - 1
  • ir_back - 2
  • ir_left - 3
  • ir_all - 4
Enumerator
ir_front 
ir_right 
ir_back 
ir_left 
ir_all 

◆ ir_type_message

IR type message list

  • ir_t_cmd : type use to send command to the robot
  • ir_t_flash : type use to send part of a program
  • ir_t_short : type use to send short message between robot in user space
  • ir_t_user : type use to send message between robot in user space
Enumerator
ir_t_cmd 
ir_t_flash 
ir_t_short 
ir_t_user 

◆ motor_id

enum motor_id

Motors API Values

Motor id definition :

  • motorR - 0
  • motorL - 1
  • motorB - 2
Enumerator
motorR 
motorL 
motorB 

◆ motor_range

Motor range :

  • motorStop - 0
  • motorQuarter - 256
  • motorHalfmotorThreeQuarter - 716
  • motorFull - 1023
Enumerator
motorStop 
motorQuarter 
motorHalf 
motorThreeQuarter 
motorFull 

◆ photosensor_id

Photosensors API Values

Photosensor id definition

  • 0 is the back sensor
  • 1 is the front-left sensor
  • 2 is the front-right sensor
Enumerator
p_FL 
p_FR 
p_B 

Function Documentation

◆ data_add_column_bool()

void data_add_column_bool ( char const * name)

◆ data_add_column_double()

void data_add_column_double ( char const * name)

◆ data_add_column_float16()

void data_add_column_float16 ( char const * name)

◆ data_add_column_int16()

void data_add_column_int16 ( char const * name)

◆ data_add_column_int32()

void data_add_column_int32 ( char const * name)

◆ data_add_column_int64()

void data_add_column_int64 ( char const * name)

◆ data_add_column_int8()

void data_add_column_int8 ( char const * name)

◆ data_add_column_string()

void data_add_column_string ( char const * name)

◆ data_set_value_bool()

void data_set_value_bool ( char const * name,
bool value )

◆ data_set_value_double()

void data_set_value_double ( char const * name,
double value )

◆ data_set_value_float16()

void data_set_value_float16 ( char const * name,
float value )

◆ data_set_value_int16()

void data_set_value_int16 ( char const * name,
int16_t value )

◆ data_set_value_int32()

void data_set_value_int32 ( char const * name,
int32_t value )

◆ data_set_value_int64()

void data_set_value_int64 ( char const * name,
int64_t value )

◆ data_set_value_int8()

void data_set_value_int8 ( char const * name,
int8_t value )

◆ data_set_value_string()

void data_set_value_string ( char const * name,
char const * value )

◆ disable_data_export()

void disable_data_export ( void )

◆ enable_data_export()

void enable_data_export ( void )

◆ FifoBuffer_typedef()

FifoBuffer_typedef ( message_t ,
Messagefifo  )

◆ get_nb_robots()

uint32_t get_nb_robots ( void )

(get_nb_robots) Returns the number of robots in the simulation

Return

the number of robots in the simulation

◆ init_bool_from_configuration()

void init_bool_from_configuration ( bool * var,
char const * name,
bool const default_value )

◆ init_double_array_from_configuration()

void init_double_array_from_configuration ( double * var,
char const * name,
size_t const size )

◆ init_double_from_configuration()

void init_double_from_configuration ( double * var,
char const * name,
double const default_value )

◆ init_float_array_from_configuration()

void init_float_array_from_configuration ( float * var,
char const * name,
size_t const size )

◆ init_float_from_configuration()

void init_float_from_configuration ( float * var,
char const * name,
float const default_value )

◆ init_int16_from_configuration()

void init_int16_from_configuration ( int16_t * var,
char const * name,
int16_t const default_value )

◆ init_int32_from_configuration()

void init_int32_from_configuration ( int32_t * var,
char const * name,
int32_t const default_value )

◆ init_int8_from_configuration()

void init_int8_from_configuration ( int8_t * var,
char const * name,
int8_t const default_value )

◆ init_string_from_configuration()

void init_string_from_configuration ( char * var,
char const * name,
size_t const size )

◆ init_uint16_from_configuration()

void init_uint16_from_configuration ( uint16_t * var,
char const * name,
uint16_t const default_value )

◆ init_uint32_from_configuration()

void init_uint32_from_configuration ( uint32_t * var,
char const * name,
uint32_t const default_value )

◆ init_uint8_from_configuration()

void init_uint8_from_configuration ( uint8_t * var,
char const * name,
uint8_t const default_value )

◆ msleep()

void msleep ( int milliseconds)

◆ pli_timer_sleep_stopwatch_init()

void pli_timer_sleep_stopwatch_init ( void )

Time API

This is a simple timer implementation based on the available hardware timer.

The benefit is that the only hardware timer we have is configured only once, and all software that depend on it just works without conflict.

The drawback is that we can't use the interrupt of the hardware timer, if available.

To keep the implementation simple, we only rely on the 32bit timer0 counter. This limit the timespan to 2^31/CLOCKRATE, which is 107 seconds with a 20MHz system clock. We can extent the implementation by maintaining a rollover count in some function that we promise to call often enough, add a rollover count in time_reference_t, and extend computations accordingly.

Sample code:

One time interval, measuring duration, think "get elapsed microseconds".

time_reference_t mystopwatch; pogobot_stopwatch_reset( &mystopwatch ); my long_computation( arguments ); uint32_t microseconds = pogobot_stopwatch_get_elapsed_microseconds( &mystopwatch ); printf( "Duration: %u microseconds", milliseconds );

Series of events, measuring duration of each, think "stopwatch lap".

time_reference_t mystopwatch; pogobot_stopwatch_reset( &mystopwatch ); while ( 1 ) { wait_for_some_external_event(); uint32_t microseconds = pogobot_stopwatch_lap( &mystopwatch ); printf( "Time since previous event: %u microseconds", milliseconds ); }

You want your code to periodically do something.

time_reference_t mytimer; uint32_t period_microseconds = 250000; pogobot_timer_init( &mytimer, period_microseconds ); while (1) { wait_for_some_external_event(); if (pogobot_timer_has_expired()) { pogobot_timer_offset_origin_microseconds( &mytimer, period_microseconds ); react_do_something(); } } (pli_timer_sleep_stopwatch_init) Initialise the timer structure (already made inside pogobot_init)

Parameters

  • none

Return

  • none

Time API

◆ pogobot_battery_voltage_read()

int16_t pogobot_battery_voltage_read ( void )

Battery API

(pogobot_battery_voltage_read) Recovers the value of the battery in mV

Parameters

  • none

Return

Returns a value in mV

Battery API

◆ pogobot_helper_getid()

uint16_t pogobot_helper_getid ( void )

Helper API

(pogobot_helper_getid) gives an unique identifier or an random number if no id is register inside the robot

Parameters

  • none

Return

Returns an unique id on 16bits

Helper API

◆ pogobot_helper_getRandSeed()

int16_t pogobot_helper_getRandSeed ( void )

(pogobot_helper_getRandSeed) gives an seed base on the ADC read of the battery

Parameters

  • none

Return

Returns an random id on 16bits

◆ pogobot_helper_print_version()

void pogobot_helper_print_version ( void )

(pogobot_helper_print_version) print the version inside the prompt It is also possible to use the define RELEASE_VERSION in release.h

Parameters

  • none

Return

  • none

◆ pogobot_imu_read()

void pogobot_imu_read ( float * acc,
float * gyro )

IMU API

(pogobot_imu_read) Read the accelaration on the IMU.
Returns in acc and gyro the IMU values.

usage :
float acc[3], gyro[3];

index :

  • 0 - X axis
  • 1 - Y axis
  • 2 - Z axis

Parameters

  • 'acc' - allocated float table (size 3)
  • 'gyro' - allocated float table (size 3)

Return

  • none

IMU API

◆ pogobot_imu_readTemp()

float pogobot_imu_readTemp ( void )

(pogobot_imu_readTemp) Read the temparature sensor on the IMU.

Parameters

  • none

Return

Returns the temperature in degres celsius

◆ pogobot_infrared_clear_message_queue()

void pogobot_infrared_clear_message_queue ( void )

(pogobot_infrared_clear_message_queue) Clears Infrared message queue

Parameters

  • none

Return

  • none

◆ pogobot_infrared_get_receiver_error_counter()

void pogobot_infrared_get_receiver_error_counter ( slip_error_counter_s * error_counter,
uint8_t ir_index )

(pogobot_infrared_get_receiver_error_counter) Get the receiver error counter value

Parameters

  • 'error_counter' - allocated structure 'slip_error_counter_s'
  • 'ir_index' - index of the ir receiver (0 to 3)

Return

  • none

◆ pogobot_infrared_ll_init()

void pogobot_infrared_ll_init ( void )

Infrared communication API Functions

(pogobot_infrared_ll_init) Initialise Infrared hardware and software struture (already made inside pogobot_init)

Parameters

  • none

Return

  • none

Infrared communication API Functions

◆ pogobot_infrared_message_available()

int pogobot_infrared_message_available ( void )

(pogobot_infrared_message_available) Infrared new message checks fonction

Parameters

  • none

Return

  • none

◆ pogobot_infrared_recover_next_message()

void pogobot_infrared_recover_next_message ( message_t * mes)

(pogobot_infrared_recover_next_message) Recover the next message inside the message queue

Parameters

  • 'mes' - Allocated structure of type 'message_t'

Return

  • none

◆ pogobot_infrared_reset_receiver_error_counter()

void pogobot_infrared_reset_receiver_error_counter ( void )

(pogobot_infrared_reset_receiver_error_counter) Reset all reveiver error counter

Parameters

  • none

Return

  • none

◆ pogobot_infrared_sendLongMessage_omniGen()

uint32_t pogobot_infrared_sendLongMessage_omniGen ( uint8_t * message,
uint16_t message_size )

(pogobot_infrared_sendLongMessage_omniGen) Send the same message in all direction at defined power Use pogobot_infrared_sendRawLongMessage Their no infrared sender ID

Parameters

  • 'message' - the current payload to send
  • 'message_size' - the size of the payload

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendLongMessage_omniSpe()

uint32_t pogobot_infrared_sendLongMessage_omniSpe ( uint8_t * message,
uint16_t message_size )

(pogobot_infrared_sendLongMessage_omniSpe) Send successively the same message with the origin infrared ID on each Infrared It is 4 times slower that without ID Use pogobot_infrared_sendRawLongMessage

Parameters

  • 'message' - the current payload to send
  • 'message_size' - the size of the payload

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendLongMessage_uniSpe()

uint32_t pogobot_infrared_sendLongMessage_uniSpe ( ir_direction dir,
uint8_t * message,
uint16_t message_size )

(pogobot_infrared_sendLongMessage_uniSpe) Send a message in only direction at defined power Use pogobot_infrared_sendRawLongMessage

Parameters

  • 'dir' - indicates the direction to send the message
  • 'message' - the current payload to send
  • 'message_size' - the size of the payload

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendRawLongMessage()

uint32_t pogobot_infrared_sendRawLongMessage ( message_t *const message)

(pogobot_infrared_sendRawLongMessage) Prepare and send one packet, with the specified emitters and powers, to the recipient, containing the specified message.

Parameters

  • 'message' - fully filled message_t variable

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendRawShortMessage()

uint32_t pogobot_infrared_sendRawShortMessage ( ir_direction dir,
short_message_t *const message )

(pogobot_infrared_sendRawShortMessage) Prepare and send one packet, with a short header containing the specified message.

Parameters

  • 'dir' - indicates the direction to send the message
  • 'message' - fully filled short_message_t variable

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendShortMessage_omni()

uint32_t pogobot_infrared_sendShortMessage_omni ( uint8_t * message,
uint16_t message_size )

(pogobot_infrared_sendShortMessage_omni) Send a short header message in all direction at defined power Use pogobot_infrared_sendRawShortMessage

Parameters

  • 'message' - the current payload to send
  • 'message_size' - the size of the payload

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_sendShortMessage_uni()

uint32_t pogobot_infrared_sendShortMessage_uni ( ir_direction dir,
uint8_t * message,
uint16_t message_size )

(pogobot_infrared_sendShortMessage_uni) Send a short header message in only direction at defined power Use pogobot_infrared_sendRawShortMessage

Parameters

  • 'dir' - indicates the direction to send the message
  • 'message' - the current payload to send
  • 'message_size' - the size of the payload

Return

  • '0' in case of success
  • '1' in case of payload too long

◆ pogobot_infrared_set_power()

void pogobot_infrared_set_power ( uint8_t power)

(pogobot_infrared_set_power) set the power level used to send all the next messages

Parameters

  • 'power' - use the pogobot_infrared_emitter_power_* or the values {0,1,2,3}

Return

  • none

◆ pogobot_infrared_update()

void pogobot_infrared_update ( void )

(pogobot_infrared_update) Infrared checks for received data and send to decode messages Decoded messages are placed in a Fifo

Parameters

  • none

Return

  • none

◆ pogobot_init()

void pogobot_init ( void )

Global API

(pogobot_init) Global API Initialisation This function is mandatory inside your program

Parameters

  • none

Return

  • none

◆ pogobot_led_setColor()

void pogobot_led_setColor ( const uint8_t r,
const uint8_t g,
const uint8_t b )

RGB LED API

(pogobot_led_setColor) Set the value of red, green and blue of the head led in static mode each value goes from 0 to 255 to determine the intensity.

Parameters

  • 'r' - value of the RED part
  • 'g' - value of the GREEN part
  • 'b' - value of the BLUE part

Return

  • none

RGB LED API

◆ pogobot_led_setColors()

void pogobot_led_setColors ( const uint8_t r,
const uint8_t g,
const uint8_t b,
uint8_t id )

(pogobot_led_setColors) Set the value of red, green and blue of the led with the number (ID) in static mode each value goes from 0 to 255 to determine the intensity. (only available with a belly with multiple LEDs)

Parameters

  • 'r' - value of the RED part
  • 'g' - value of the GREEN part
  • 'b' - value of the BLUE part
  • 'id' - Led ID (0 = head, 1 = belly front, 2 = belly right, 3 = belly back, 4 = belly left)

Return

  • none

◆ pogobot_motor_dir_current_status()

uint32_t pogobot_motor_dir_current_status ( void )

(pogobot_motor_dir_current_status) recover the value of the motor direction bit field.

Parameters

  • none

Return

  • bit field ( XXXX XMLR )

◆ pogobot_motor_dir_mem_get()

int8_t pogobot_motor_dir_mem_get ( uint8_t * p_directions)

(pogobot_motor_dir_mem_get) get the value of pwm that commands the motor.

Parameters

  • 'p_directions' - is an array of size 3 [R, L, B]. Each value is the chosen direction (0 or 1)

Return

  • the success or not of the read in memory (0: Ok, -1: NOk)

◆ pogobot_motor_dir_mem_set()

int8_t pogobot_motor_dir_mem_set ( uint8_t * p_directions)

(pogobot_motor_dir_mem_set) set the value of pwm that commands the motor (persistent).

Parameters

  • 'p_directions' - is an array of size 3 [R, L, B]. Each value is the chosen direction (0 or 1)

Return

  • the success or not of the read in memory (0: Ok, -1: NOk)

◆ pogobot_motor_dir_set()

void pogobot_motor_dir_set ( motor_id motor,
uint8_t value )

(pogobot_motor_dir_set) set the value of pwm that commands the motor (active).

Parameters

  • 'motor' - is the id of the motor you want to command (motorR, motorL, motorB)
  • 'value' - is the choosen direction (0 or 1)

Return

  • none

◆ pogobot_motor_power_mem_get()

uint8_t pogobot_motor_power_mem_get ( uint16_t * p_powers)

(pogobot_motor_power_mem_get) recover the value of the motor power memorized.

Parameters

  • 'p_powers' - is an array of size 3 [R, L, B]. Each value is the chosen power [0, 1023]

Return

  • the success or not of the read in memory (0: Ok, -1: NOK)

◆ pogobot_motor_power_mem_set()

uint8_t pogobot_motor_power_mem_set ( uint16_t * p_powers)

(pogobot_motor_power_mem_set) write the value of the motor power in memory (persistent).

Parameters

  • 'p_powers' - is an array of size 3 [R, L, B]. Each value is the chosen power [0, 1023]

Return

  • the success or not of the read in memory (0: Ok, -1: NOK)

◆ pogobot_motor_power_set()

void pogobot_motor_power_set ( motor_id motor,
uint16_t value )

Motors API Functions

(pogobot_motor_power_set) set the value of pwm that commands the motor (active)

Parameters

  • 'motor' - is the id of the motor you want to command
  • 'value' - is PWM ratio apply to the motor (between 0 and 1023)

Return

  • none

Motors API Values

◆ pogobot_motor_set()

void pogobot_motor_set ( motor_id motor,
uint16_t value )

◆ pogobot_photosensors_read()

int16_t pogobot_photosensors_read ( uint8_t sensor_number)

Photosensors API Functions

(pogobot_photosensors_read) Read one ambient light sensor. Sensor number must be between 0 and 2.

Parameters

  • 'sensor_number' - id of the sensor (Photosensor definition)

Return

Return a value proportional to the light

Photosensors API Values

◆ pogobot_stopwatch_get_elapsed_microseconds()

int32_t pogobot_stopwatch_get_elapsed_microseconds ( time_reference_t * stopwatch)

(pogobot_stopwatch_get_elapsed_microseconds) provides the current number of elapsed microseconds without otherwise interfering with the stopwatch state.

Parameters

Return

Returns the number of microseconds elapsed on 32 bits (which may be negative if you offset the origin to the future)

◆ pogobot_stopwatch_lap()

int32_t pogobot_stopwatch_lap ( time_reference_t * stopwatch)

(pogobot_stopwatch_lap) measures time elapsed from origin and offsets so that origin is zero at this point in time.

Parameters

Return

Returns the number of microseconds elapsed on 32 bits (which may be negative if you offset the origin to the future)

◆ pogobot_stopwatch_offset_origin_microseconds()

void pogobot_stopwatch_offset_origin_microseconds ( time_reference_t * stopwatch,
int32_t microseconds_offset )

(pogobot_stopwatch_offset_origin_microseconds) offsets the origin of the stopwatch by the specified number of microseconds.

Parameters

  • 'stopwatch' - pointer to a time_reference_t structure
  • 'microseconds_offset' - number of microsenconds to offset the origin

Return

  • none

◆ pogobot_stopwatch_reset()

void pogobot_stopwatch_reset ( time_reference_t * stopwatch)

(pogobot_stopwatch_reset) reset a time_reference structure. To use a time_reference_t as a stopwatch you must reset it using pogobot_stopwatch_reset()

Parameters

Return

  • none

◆ pogobot_timer_get_remaining_microseconds()

int32_t pogobot_timer_get_remaining_microseconds ( time_reference_t * timer)

(pogobot_timer_get_remaining_microseconds) provides the current of microseconds until the timer has expired, without otherwise interfering with the timer state.

Parameters

Return

Returns the number of microseconds elapsed on 32 bits. The result is a signed number, positive when the timer has not expired yet, negative when the timer has expired.

◆ pogobot_timer_has_expired()

bool pogobot_timer_has_expired ( time_reference_t * timer)

(pogobot_timer_has_expired) Returns true when the timer has expired, false when the timer has not expired yet.

Parameters

Return

Returns a bool depending on the status (True: if expired, False: if not expired)

◆ pogobot_timer_init()

void pogobot_timer_init ( time_reference_t * timer,
int32_t microseconds_to_go )

(pogobot_timer_init) set a timer that will expire in the defined number of microseconds in the future.

Parameters

  • 'timer' - pointer to a time_reference_t structure
  • 'microseconds_to_go' - number of microsenconds to go

Return

  • none

◆ pogobot_timer_offset_origin_microseconds()

void pogobot_timer_offset_origin_microseconds ( time_reference_t * timer,
int32_t microseconds_offset )

(pogobot_timer_offset_origin_microseconds) offsets the origin of the timer by the specified number of microseconds.

Parameters

  • 'timer' - pointer to a time_reference_t structure
  • 'microseconds_offset' - number of microsenconds to offset the origin

Return

  • none

◆ pogobot_timer_wait_for_expiry()

void pogobot_timer_wait_for_expiry ( time_reference_t * timer)

(pogobot_timer_wait_for_expiry) waits until the timer has expired.

Parameters

Return

  • none

◆ pogosim_printf()

void pogosim_printf ( const char * format,
... )

◆ pogosim_putchar()

int pogosim_putchar ( int ch)

◆ stop_simulation()

void stop_simulation ( void )

(stop_simulation) Stops the simulation

Variable Documentation

◆ my_mes_fifo

Messagefifo my_mes_fifo
extern

◆ my_mes_fifo_p

Messagefifo* my_mes_fifo_p
extern