sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions | Variables
robot_motor_control.c File Reference

Implementation of Robot Motor Control model. More...

#include <common/neuron-typedefs.h>
#include <common/in_spikes.h>
#include <data_specification.h>
#include <debug.h>
#include <simulation.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  motor_control_config_t
 The structure of our configuration region in SDRAM. More...
 
struct  robot_motor_control_provenance
 The provenance information written on application shutdown. More...
 

Macros

#define N_COUNTERS   6
 Number of counters. More...
 
#define NEURON_ID_MASK   0x7FF
 Mask for selecting the neuron ID from a spike. More...
 

Enumerations

enum  direction_t {
  MOTION_FORWARD = 0x01 , MOTION_BACK = 0x02 , MOTION_RIGHT = 0x03 , MOTION_LEFT = 0x04 ,
  MOTION_CLOCKWISE = 0x05 , MOTION_C_CLOCKWISE = 0x06
}
 The "directions" that the motors can move in. More...
 
enum  robot_motor_control_regions_e { SYSTEM_REGION , PARAMS_REGION , PROVENANCE_DATA_REGION }
 DSG regions in use. More...
 
enum  robot_motor_control_callback_priorities { MC = -1 , SDP = 0 , DMA = 1 , TIMER = 2 }
 values for the priority for each callback More...
 

Functions

static void send_to_motor (uint32_t direction, uint32_t the_speed)
 Send a SpiNNaker multicast-with-payload message to the motor hardware. More...
 
static void do_motion (direction_t direction_index, direction_t opposite_index, const char *direction, const char *opposite)
 Commands the robot's motors to start doing a motion. More...
 
static void do_update (direction_t direction_index, direction_t opposite_index, const char *direction, const char *opposite)
 Commands the robot's motors to continue a motion started by do_motion() More...
 
static void timer_callback (uint unused0, uint unused1)
 Regular 1ms callback. Takes spikes from circular buffer and converts to motor activity level. More...
 
static void read_parameters (motor_control_config_t *config_region)
 Reads the configuration. More...
 
static void incoming_spike_callback (uint key, uint payload)
 Add incoming spike message (in FIQ) to circular buffer. More...
 
static void incoming_spike_callback_payload (uint key, uint payload)
 Add incoming spike message (in FIQ) to circular buffer. More...
 
static void c_main_store_provenance_data (address_t provenance_region)
 Callback to store provenance data (format: neuron_provenance). More...
 
static bool initialize (uint32_t *timer_period)
 Read all application configuration. More...
 
void c_main (void)
 Entry point. More...
 

Variables

static uint32_t time
 The simulation time. More...
 
static int * counters
 Accumulators for each motor direction. More...
 
static int * last_speed
 The last speeds for each motor direction. More...
 
static uint32_t key
 The (base) key to use to send to the motor. More...
 
static int speed
 The standard motor speed, set by configuration. More...
 
static uint32_t sample_time
 Time interval between samples, in ticks. More...
 
static uint32_t update_time
 Time interval between updates, in ticks. More...
 
static uint32_t delay_time
 Inter-message delay time, in μs. More...
 
static int delta_threshold
 The size of change required to matter. More...
 
static bool continue_if_not_different
 Whether we should continue moving if there is no change. More...
 
static uint32_t simulation_ticks
 Current simulation stop/pause time. More...
 
static uint32_t infinite_run
 True if the simulation is running continuously. More...
 

Detailed Description

Implementation of Robot Motor Control model.

Definition in file robot_motor_control.c.


Data Structure Documentation

◆ motor_control_config_t

struct motor_control_config_t

The structure of our configuration region in SDRAM.

Definition at line 33 of file robot_motor_control.c.

Data Fields
uint32_t key The (base) key to use to send to the motor.
int speed The standard motor speed scaling factor.
uint32_t sample_time

Time interval between samples of the state of incoming messages, in ticks

uint32_t update_time Time interval between motor speed updates, in ticks.
uint32_t delay_time Outgoing inter-message delay time, in μs.
int delta_threshold The size of change required to matter.
uint32_t continue_if_not_different Whether we should continue moving if there is no change.

◆ robot_motor_control_provenance

struct robot_motor_control_provenance

The provenance information written on application shutdown.

Definition at line 52 of file robot_motor_control.c.

Data Fields
uint32_t n_input_buffer_overflows A count of the times that the synaptic input circular buffers overflowed.

Macro Definition Documentation

◆ N_COUNTERS

#define N_COUNTERS   6

Number of counters.

Definition at line 58 of file robot_motor_control.c.

◆ NEURON_ID_MASK

#define NEURON_ID_MASK   0x7FF

Mask for selecting the neuron ID from a spike.

Definition at line 71 of file robot_motor_control.c.

Enumeration Type Documentation

◆ direction_t

The "directions" that the motors can move in.

Enumerator
MOTION_FORWARD 

Forwards.

MOTION_BACK 

Backwards.

MOTION_RIGHT 

To the right.

MOTION_LEFT 

To the left.

MOTION_CLOCKWISE 

Rotate clockwise on the spot.

MOTION_C_CLOCKWISE 

Rotate counterclockwise on the spot.

Definition at line 61 of file robot_motor_control.c.

◆ robot_motor_control_regions_e

DSG regions in use.

Enumerator
SYSTEM_REGION 

General simulation API control area.

PARAMS_REGION 

Configuration region for this application.

PROVENANCE_DATA_REGION 

Provenance region for this application.

Definition at line 100 of file robot_motor_control.c.

◆ robot_motor_control_callback_priorities

values for the priority for each callback

Enumerator
MC 

Multicast message reception is FIQ.

SDP 

SDP handling is highest normal priority.

DMA 

DMA complete handling is medium priority.

TIMER 

Timer interrupt processing is lowest priority.

Definition at line 107 of file robot_motor_control.c.

Function Documentation

◆ send_to_motor()

static void send_to_motor ( uint32_t  direction,
uint32_t  the_speed 
)
inlinestatic

Send a SpiNNaker multicast-with-payload message to the motor hardware.

Parameters
[in]directionWhich direction to move in
[in]the_speedWhat speed to move at

Definition at line 119 of file robot_motor_control.c.

◆ do_motion()

static void do_motion ( direction_t  direction_index,
direction_t  opposite_index,
const char *  direction,
const char *  opposite 
)
inlinestatic

Commands the robot's motors to start doing a motion.

Parameters
[in]direction_indexThe "forward" sense of motion
[in]opposite_indexThe "reverse" sense of motion
[in]directionfor debugging
[in]oppositefor debugging

Definition at line 134 of file robot_motor_control.c.

◆ do_update()

static void do_update ( direction_t  direction_index,
direction_t  opposite_index,
const char *  direction,
const char *  opposite 
)
inlinestatic

Commands the robot's motors to continue a motion started by do_motion()

Parameters
[in]direction_indexThe "forward" sense of motion
[in]opposite_indexThe "reverse" sense of motion
[in]directionfor debugging
[in]oppositefor debugging

Definition at line 169 of file robot_motor_control.c.

◆ timer_callback()

static void timer_callback ( uint  unused0,
uint  unused1 
)
static

Regular 1ms callback. Takes spikes from circular buffer and converts to motor activity level.

Parameters
unused0unused
unused1unused

Definition at line 193 of file robot_motor_control.c.

◆ read_parameters()

static void read_parameters ( motor_control_config_t config_region)
static

Reads the configuration.

Parameters
[in]config_regionWhere to read the configuration from

Definition at line 240 of file robot_motor_control.c.

◆ incoming_spike_callback()

static void incoming_spike_callback ( uint  key,
uint  payload 
)
static

Add incoming spike message (in FIQ) to circular buffer.

Parameters
[in]keyThe received spike
payloadignored

Definition at line 268 of file robot_motor_control.c.

◆ incoming_spike_callback_payload()

static void incoming_spike_callback_payload ( uint  key,
uint  payload 
)
static

Add incoming spike message (in FIQ) to circular buffer.

Parameters
[in]keyThe received spike
payloadignored

Definition at line 278 of file robot_motor_control.c.

◆ c_main_store_provenance_data()

static void c_main_store_provenance_data ( address_t  provenance_region)
static

Callback to store provenance data (format: neuron_provenance).

Parameters
[out]provenance_regionWhere to write the provenance data

Definition at line 291 of file robot_motor_control.c.

◆ initialize()

static bool initialize ( uint32_t *  timer_period)
static

Read all application configuration.

Parameters
[out]timer_periodHow long to program ticks to be
Returns
True if initialisation succeeded

Definition at line 304 of file robot_motor_control.c.

◆ c_main()

void c_main ( void  )

Entry point.

Definition at line 337 of file robot_motor_control.c.

Variable Documentation

◆ time

uint32_t time
static

The simulation time.

Definition at line 75 of file robot_motor_control.c.

◆ counters

int* counters
static

Accumulators for each motor direction.

Definition at line 77 of file robot_motor_control.c.

◆ last_speed

int* last_speed
static

The last speeds for each motor direction.

Definition at line 79 of file robot_motor_control.c.

◆ key

uint32_t key
static

The (base) key to use to send to the motor.

Definition at line 81 of file robot_motor_control.c.

◆ speed

int speed
static

The standard motor speed, set by configuration.

Definition at line 83 of file robot_motor_control.c.

◆ sample_time

uint32_t sample_time
static

Time interval between samples, in ticks.

Definition at line 85 of file robot_motor_control.c.

◆ update_time

uint32_t update_time
static

Time interval between updates, in ticks.

Definition at line 87 of file robot_motor_control.c.

◆ delay_time

uint32_t delay_time
static

Inter-message delay time, in μs.

Definition at line 89 of file robot_motor_control.c.

◆ delta_threshold

int delta_threshold
static

The size of change required to matter.

Definition at line 91 of file robot_motor_control.c.

◆ continue_if_not_different

bool continue_if_not_different
static

Whether we should continue moving if there is no change.

Definition at line 93 of file robot_motor_control.c.

◆ simulation_ticks

uint32_t simulation_ticks
static

Current simulation stop/pause time.

Definition at line 95 of file robot_motor_control.c.

◆ infinite_run

uint32_t infinite_run
static

True if the simulation is running continuously.

Definition at line 97 of file robot_motor_control.c.