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

Header file for kimenatics.c. More...

#include <__swarm_wold__.h>
Include dependency graph for __kinematics__.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  point
 
struct  pos
 
struct  pos_dot
 
struct  _i_pos
 
struct  mat2
 
struct  _omega
 
struct  _theta
 

Macros

#define L   0.06
 
#define r   0.02
 
#define R_over_L   0.333
 
#define R_over_2   0.01
 

Functions

struct _i_pos _omega_to_intertial (struct _omega *input)
 
struct pos_dot _inertial_to_pos_dot (struct _i_pos *inertial, struct pos *_pos)
 
uint16_t _dead_reckon (struct pos *_pos, struct pos_dot *_pos_dot)
 
struct pos _thetaLR_to_pos (struct _theta *th)
 
void _update_thetaLR (struct _theta *input)
 
void _update_omega (struct _omega *input)
 

Detailed Description

Header file for kimenatics.c.

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

$RCSfile$

Date
5/29/2021 8:04:54 PM

Definition in file __kinematics__.h.

Function Documentation

◆ _dead_reckon()

uint16_t _dead_reckon ( struct pos _pos,
struct pos_dot _pos_dot 
)

a dead-reckoner for spatial pos estimation, returns debug info

Parameters
[in]_pospos
[in]_pos_dotderivative of pos
36 {
37  static uint64_t t_prev = 0;
38  uint16_t dt = _micros0() - t_prev;
39  t_prev = _micros0();
40 
41  float vx = _pos_dot->x_dot;
42  float vy = _pos_dot->y_dot;
43  float w = _pos_dot->th_dot;
44 
45  struct pos out;
46  out.x += vx * dt;
47  out.y += vy * dt;
48  out.th += w * dt;
49 
50  return dt;
51 }
unsigned long _micros0(void)
Definition: __timer0__.c:54
float x_dot
Definition: __kinematics__.h:57
float y_dot
Definition: __kinematics__.h:58
float th_dot
Definition: __kinematics__.h:59
Definition: __kinematics__.h:45
float x
Definition: __kinematics__.h:46

References _micros0(), pos::th, pos_dot::th_dot, pos::x, pos_dot::x_dot, pos::y, and pos_dot::y_dot.

Here is the call graph for this function:

◆ _inertial_to_pos_dot()

struct pos_dot _inertial_to_pos_dot ( struct _i_pos inertial,
struct pos _pos 
)

A function to convert inertial velocities to pos_dot

Parameters
[in]inertialstruct of inertial pos
[in]_posstruct of current pos for \theta
22 {
23  float v = inertial->v;
24  float w = inertial->w;
25  float th = _pos->th;
26  struct pos_dot out;
27 
28  out.x_dot = v * cos(th);
29  out.y_dot = v * sin(th);
30  out.th_dot = w;
31 
32  return out;
33 }
float v
linear velocity V
Definition: __kinematics__.h:67
float w
rotational velocity W
Definition: __kinematics__.h:68
Definition: __kinematics__.h:56
float th
Definition: __kinematics__.h:48

References _i_pos::v.

◆ _omega_to_intertial()

struct _i_pos _omega_to_intertial ( struct _omega input)

A function to convert wheels rotation velocity to inertial velocities

Parameters
[in]inputstruct of wheels velocity
_omega
11 {
12  float wl = input->wl;
13  float wr = input->wr;
14 
15  struct _i_pos out;
16  out.v = (wl+wr)*R_over_2;
17  out.w = (wr-wl)*R_over_L;
18  return out;
19 }
Definition: __kinematics__.h:66
float wl
left motor
Definition: __kinematics__.h:89
float wr
right motor
Definition: __kinematics__.h:90

◆ _thetaLR_to_pos()

struct pos _thetaLR_to_pos ( struct _theta th)

A function to convert wheels' absolute rotation angles to pos (not proper)

Parameters
[in]thwheels' absolute rotation
54 {
55  struct pos out;
56 
57  out.th = (th->right - th->left)*R_over_L;
58  out.x = (th->right + th->left)*R_over_2*cos(out.th);
59  out.y = (th->right + th->left)*R_over_2*sin(out.th);
60 
61  return out;
62 }

◆ _update_omega()

void _update_omega ( struct _omega input)

A function to update the wheels' rotation velocity or each wheel from hardware modules

Parameters
[in]inputwheel's rotational velocity
71 {
72  input->wl = _omega_from_encA();
73  input->wr = -1.0 * _omega_from_encB();
74 }

References _omega::wl, and _omega::wr.

◆ _update_thetaLR()

void _update_thetaLR ( struct _theta input)

A function to update the absolute rotation angle of each wheel from hardware modules

Parameters
[in]inputwheels' absolute rotation
65 {
66  input->left = _thetaA();
67  input->right = -1.0 * _thetaB();
68 }
float right
right motor
Definition: __kinematics__.h:99
float left
left motor
Definition: __kinematics__.h:98

References _theta::left, and _theta::right.