vulp  2.3.0
vulp.utils Namespace Reference

Utility functions. More...

Namespaces

 internal
 
 math
 Mathematical functions.
 
 serialize
 

Classes

class  SynchronousClock
 Synchronous (blocking) clock. More...
 

Functions

const bool & handle_interrupts ()
 Redirect interrupts to setting a global interrupt boolean. More...
 
double low_pass_filter (double prev_output, double cutoff_period, double new_input, double dt)
 Low-pass filter as an inline function. More...
 
std::string random_string (unsigned length=16)
 Generate a random string. More...
 
void configure_cpu (int cpu)
 Set the current thread to run on a given CPU core. More...
 
void configure_scheduler (int priority)
 Configure the scheduler policy to round-robin for this thread. More...
 
bool lock_memory ()
 Lock all memory to RAM so that the kernel doesn't page it to swap. More...
 

Detailed Description

Utility functions.

Function Documentation

◆ configure_cpu()

void vulp::utils::configure_cpu ( int  cpu)
inline

Set the current thread to run on a given CPU core.

Parameters
cpuCPU core for this thread (on the Pi, CPUID in {0, 1, 2, 3}).
Exceptions
std::runtime_errorIf the operation failed.

Definition at line 23 of file realtime.h.

◆ configure_scheduler()

void vulp::utils::configure_scheduler ( int  priority)
inline

Configure the scheduler policy to round-robin for this thread.

Parameters
priorityPriority of this thread for the scheduler, ranging from 1 (low) to 99 (high). See man sched. For agents, this priority should be lower than that of the spine.
Exceptions
std::runtime_errorIf the operation failed.

Definition at line 45 of file realtime.h.

◆ handle_interrupts()

const bool & vulp::utils::handle_interrupts ( )

Redirect interrupts to setting a global interrupt boolean.

Direct interrupts (e.g.

Returns
Reference to the interrupt boolean.

Ctrl-C) to a boolean flag.

Returns
Reference to a boolean flag, which is initially false and becomes true the first time an interruption is caught.

Definition at line 20 of file handle_interrupts.cpp.

◆ lock_memory()

bool vulp::utils::lock_memory ( )
inline

Lock all memory to RAM so that the kernel doesn't page it to swap.

The Linux man pages have a great NOTES section on this. Worth a read!

Definition at line 63 of file realtime.h.

◆ low_pass_filter()

double vulp::utils::low_pass_filter ( double  prev_output,
double  cutoff_period,
double  new_input,
double  dt 
)
inline

Low-pass filter as an inline function.

Parameters
prev_outputPrevious filter output, or initial value.
cutoff_periodCutoff period in [s].
new_inputNew filter input.
dtSampling period in [s].
Returns
New filter output.

Definition at line 24 of file low_pass_filter.h.

◆ random_string()

std::string vulp::utils::random_string ( unsigned  length = 16)
inline

Generate a random string.

Parameters
[in]lengthString length.
Returns
Random string.

The generated string contains only alphanumeric characters with no repetition.

Definition at line 21 of file random_string.h.