WebbotLib Reference
The following functions are always available
From clock.h
- clockGetus - Get the current time in µS.
- clockHasElapsed - Test if a given duration has elapsed.
- clockHasElapsedGetOverflow - Similar to 'clockHasElapsed' but returns the number of µS left to go if the duration has not elapsed, or the number of µS we have exceeded the duration if is has elapsed.
- clockWaitms - Pause for the given number of milliseconds.
- clockWaitus - Pause for the given number of microseconds.
From core.h
- interpolate - This will interpolate a value from one range of values into its equivalent in another range of signed numbers by using the following parameters:-
- interpolateU - This will interpolate a value from one range of values into its equivalent in another range of unsigned numbers by using the following parameters:-
- interpolatef - This will interpolate a floating point value from one range of values into its equivalent in another range of signed numbers by using the following parameters:-
- isqrt - Performs a fast square root function on a whole number - returning the nearest whole number answer and without requiring the floating point library.
- delay_cycles - Pause for the given number of clock cycles.
- delay_ms - Pause for the given number of ms.
- delay_us - Pause for the given number of µs.
- MS_TO_CYCLES - Convert milliseconds into a number of cycles.
- US_TO_CYCLES - Convert microseconds into a number of cycles.
- PRINTF - Output a formatted string to any Stream.
- memoryDump - Dumps an area of memory in tabular format showing both hexadecimal and ASCII values.
From libdefs.h
- CRITICAL_SECTION - Bracket a section of code that shoud not be interrupted.
- CRITICAL_SECTION_START - Deprecated - use CRITICAL_SECTION instead
- CRITICAL_SECTION_END - Deprecated - use CRITICAL_SECTION instead
- READMEMBYTE - This macro will read a byte either from ROM or from RAM given the following parameters:-
- MIN - This macro takes two numbers as its arguments and will return the smallest one ie the one closest to negative infinity.
- MAX - This macro takes two numbers as its arguments and will return the largest one ie the one closest to positive infinity.
- ABS - This macro takes one number as its arguments and will return the absolute value. ie if the number starts with a '-' then it will change it to a '+'.
- CLAMP - A macro to clamp a value to be within a given range.
- get_uint16 - Returns a 16 bit integer from a buffer.
- get_int16 - Returns a 16 bit signed integer from a buffer.
- get_uint32 - Returns a 32 bit integer from a buffer.
- set_uint16 - Stores a 16 bit integer into a buffer.
- set_uint32 - Stores a 32 bit integer into a buffer.
From rprintf.h
- rprintfInit - Tells rprintf where to send its output to.
- OUTPUT - Brackets a piece of code whose rprintf output should be sent to a specific place.
- hexchar - Convert binary to hexadecimal digit.
- rprintfChar - Output a single character.
- rprintfCharN - Print a character a given number of times.
- rprintfStr - Print a string that is stored in RAM.
- rprintfStrLen - Print a section of string that is stored in RAM.
- rprintfProgStr - Output a constant string stored in program memory.
- rprintfProgStrM - Output a fixed string from program memory.
- rprintfCRLF - Move the output to a new line.
- rprintfu04 - Output the low 4 bits of 'data' as one hexadecimal character
- rprintfu08 - Output the parameter as two hexadecimal characters.
- rprintfu16 - Output the parameter as 4 hexadecimal digits.
- rprintfu32 - Outputput the parameter as an 8 digit hexadecimal number.
- rprintfNum - Allows you to print a number in any base using different padding characters.
- rprintfFloat - Prints a floating point number.
- rprintf - Output a formatted string to the output.
- rprintfMemoryDump - Dumps an area of memory in tabular format showing both hexadecimal and ASCII values.
The following .H files need to be manually added to your program if needed
Directory
- Gait
- Adds support for using gaits in both design mode and free running mode.
- Maths
- The Maths folder contains various helper routines for more complex mathematical processing such as Vectors and Matrices.
File
- buffer.h
- Defines a 'first in first out circular' buffer which can be written to and read from by different tasks.
- <avr/eeprom.h>
- Most AVR micro controllers contain some 'on-chip' EEPROM. This is memory that remembers its content even after the power is switched off.
- errors.h
- "All programs run properly and never come across an unexpected situation" - said the inexperienced programmer!
- pid.h
- Implements a PID (Proportional, Integral, Derivative) control loop.
- pinChange.h
- Allow callback routines to be attached to IOPins that are called when the pin changes.
- scheduler.h
- Provides a scheduler mechanism whereby code can be queued up to be called at a later date. NB the scheduler timer cannot be used to time/measure fast events of less than 1ms ie certainly not to send pulses to a servo or for PWM to motors. However it is fine for less demanding applications - such as regular sampling in a Kalman filter.
- timer.h
- Provides low level help with timers and compare channels.