SWARM-Bot Firmware  v1.0
Mobile robot OS - Embedded C/C++
__odometry__.h File Reference

Header file for odometry.c. More...

#include "__swarm_wold__.h"
Include dependency graph for __odometry__.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define __ENC_TICK_THETA_FOR_OMEGA   190399
 Threshold value for encoder ticks used to calculate angular velocity. More...
 
#define __ENC_TICK_THETA   0.1904
 Conversion factor from encoder ticks to radians. More...
 
#define __PM_lower_bound   200
 Lower bound for potentiometer readings. More...
 
#define __PM_upper_bound   800
 Upper bound for potentiometer readings. More...
 
#define __PM_SAMPLE_COUNT   5
 Number of samples taken for potentiometer readings. More...
 
#define __PM_SLOPE   1
 Slope for potentiometer readings, in radians per volt per overflow. More...
 
#define FORWARD   1
 Constant used to indicate forward motion. More...
 
#define BACKWARD   -1
 Constant used to indicate backward motion. More...
 

Functions

float _theta_A (void)
 Returns the absolute rotation angle of motor A. More...
 
float _theta_B (void)
 Returns the absolute rotation angle of motor B. More...
 
float _omega_from_enc_A (void)
 Returns the angular velocity of motor A based on encoder readings. More...
 
float _omega_from_enc_B (void)
 Returns the angular velocity of motor B based on encoder readings. More...
 
float _omega_from_PM_A (void)
 Returns the angular velocity of motor A based on potentiometer readings. More...
 
float _omega_from_PM_B (void)
 Returns the angular velocity of motor B based on potentiometer readings. More...
 
float _omega_comp_A (void)
 Returns the complementary filter for the angular velocity of motor A. More...
 
float omega_comp_B (void)
 Returns the complementary filter for the angular velocity of motor B. More...
 
int32_t _ticksA ()
 Returns the number of encoder ticks for motor A since boot. More...
 
int32_t _ticksB ()
 Returns the number of encoder ticks for motor A since boot. More...
 
void _insertion_sort (uint16_t arr[], int n)
 Indertio sort algorithm. Faster for small array sizes. More...
 

Detailed Description

Header file for odometry.c.

  • File: __odometry__h
  • Compiler: GCC-AVR
  • Supported devices: Tested on 328p
  • AppNote: Odometry calculations for the mobile robot
Author
Swarm robot graduation project workgroub
Mechatronics Program for the Distinguished
$Name$
Revision
1

$RCSfile$

Date
/19/2021 9:43:59 AM

Definition in file __odometry__.h.

Macro Definition Documentation

◆ __ENC_TICK_THETA

#define __ENC_TICK_THETA   0.1904

Conversion factor from encoder ticks to radians.

◆ __ENC_TICK_THETA_FOR_OMEGA

#define __ENC_TICK_THETA_FOR_OMEGA   190399

Threshold value for encoder ticks used to calculate angular velocity.

◆ __PM_lower_bound

#define __PM_lower_bound   200

Lower bound for potentiometer readings.

◆ __PM_SAMPLE_COUNT

#define __PM_SAMPLE_COUNT   5

Number of samples taken for potentiometer readings.

◆ __PM_SLOPE

#define __PM_SLOPE   1

Slope for potentiometer readings, in radians per volt per overflow.

◆ __PM_upper_bound

#define __PM_upper_bound   800

Upper bound for potentiometer readings.

◆ BACKWARD

#define BACKWARD   -1

Constant used to indicate backward motion.

◆ FORWARD

#define FORWARD   1

Constant used to indicate forward motion.

Function Documentation

◆ _insertion_sort()

void _insertion_sort ( uint16_t  arr[],
int  n 
)

Indertio sort algorithm. Faster for small array sizes.

Parameters
[in]arrpointer to start of sorting
[in]noffset from
arr[]
197 {
198  int i, key, j;
199  for (i = 1; i < n; i++) {
200  key = arr[i];
201  j = i - 1;
202 
203  /* Move elements of arr[0..i-1], that are
204  greater than key, to one position ahead
205  of their current position */
206  while (j >= 0 && arr[j] > key) {
207  arr[j + 1] = arr[j];
208  j = j - 1;
209  }
210  arr[j + 1] = key;
211  }
212 }

◆ _omega_comp_A()

float _omega_comp_A ( void  )

Returns the complementary filter for the angular velocity of motor A.

Returns
The complementary filter for the angular velocity of motor A in radians per second.

This function uses both encoder and potentiometer readings to calculate a more accurate estimate of the angular velocity of motor A.

124 {
125  return _omega_from_PMA() * 0.3f + _omega_from_encA() * 0.7f;
126 }

◆ _omega_from_enc_A()

float _omega_from_enc_A ( void  )

Returns the angular velocity of motor A based on encoder readings.

Returns
The angular velocity of motor A in radians per second.

This function measures the time between consecutive encoder ticks to determine the angular velocity of motor A.

◆ _omega_from_enc_B()

float _omega_from_enc_B ( void  )

Returns the angular velocity of motor B based on encoder readings.

Returns
The angular velocity of motor B in radians per second.

This function measures the time between consecutive encoder ticks to determine the angular velocity of motor B.

◆ _omega_from_PM_A()

float _omega_from_PM_A ( void  )

Returns the angular velocity of motor A based on potentiometer readings.

Returns
The angular velocity of motor A in radians per second.

This function uses the potentiometer readings of motor A to determine its angular velocity.

◆ _omega_from_PM_B()

float _omega_from_PM_B ( void  )

Returns the angular velocity of motor B based on potentiometer readings.

Returns
The angular velocity of motor B in radians per second.

This function uses the potentiometer readings of motor B to determine its angular velocity.

◆ _theta_A()

float _theta_A ( void  )

Returns the absolute rotation angle of motor A.

Returns
The absolute rotation angle of motor A in radians.

◆ _theta_B()

float _theta_B ( void  )

Returns the absolute rotation angle of motor B.

Returns
The absolute rotation angle of motor B in radians.

◆ _ticksA()

int32_t _ticksA ( )

Returns the number of encoder ticks for motor A since boot.

Returns
The number of encoder ticks for motor A since boot.
96 {
97  return _enca_count;
98 }

◆ _ticksB()

int32_t _ticksB ( )

Returns the number of encoder ticks for motor A since boot.

Returns
The number of encoder ticks for motor A since boot.
100 {
101  return _encb_count;
102 }

◆ omega_comp_B()

float omega_comp_B ( void  )

Returns the complementary filter for the angular velocity of motor B.

Returns
The complementary filter for the angular velocity of motor B in radians per second.

This function uses both encoder and potentiometer readings to calculate a more accurate estimate of the angular velocity of motor B.