summaryrefslogtreecommitdiff
path: root/n/asserv/src/asserv/models.host.c
blob: 062b88a729fe46eb5f4c52ac8bb9039f670ef3db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/* models.host.c */
/* asserv - Position & speed motor control on AVR. {{{
 *
 * Copyright (C) 2006 Nicolas Schodet
 *
 * Robot APB Team/Efrei 2006.
 *        Web: http://assos.efrei.fr/robot/
 *      Email: robot AT efrei DOT fr
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */
#include "motor_model.host.h"
#include "models.host.h"

#include <math.h>
#include <string.h>

/* Gloubi model. */
static const struct motor_t gloubi_model =
{
    /* Motor caracteristics. */
    407 * M_2_PI / 60,	/* Speed constant ((rad/s)/V). */
    23.4 / 1000,	/* Torque constant (N.m/A). */
    0,			/* Bearing friction (N.m/(rad/s)). */
    2.18,		/* Terminal resistance (Ohm). */
    0.24 / 1000,	/* Terminal inductance (H). */
    /* Gearbox caracteristics. */
    10,			/* Gearbox ratio. */
    0.75,		/* Gearbox efficiency. */
    /* Load caracteristics. */
    4 * 0.02 * 0.02,	/* Load (kg.m^2). */
    /* Simulation parameters. */
    4.444444 / 1000,	/* Simulation time step (s). */
    1000,		/* Simulation time step division. */
    /* Simulation current state. */
    0,			/* Current time (not realy used) (s). */
    0,			/* Current input voltage (V). */
    0,			/* Current current (A). */
    0,			/* Current angular speed (o for omega) (rad/s). */
    0			/* Current theta (th for theta) (rad). */
};

/* Taz model. */
static const struct motor_t taz_model =
{
    /* Motor caracteristics. */
    407 * M_2_PI / 60,	/* Speed constant ((rad/s)/V). */
    23.4 / 1000,	/* Torque constant (N.m/A). */
    0,			/* Bearing friction (N.m/(rad/s)). */
    2.18,		/* Terminal resistance (Ohm). */
    0.24 / 1000,	/* Terminal inductance (H). */
    /* Gearbox caracteristics. */
    10,			/* Gearbox ratio. */
    0.75,		/* Gearbox efficiency. */
    /* Load caracteristics. */
    10 * 0.04 * 0.04,	/* Load (kg.m^2). */
    /* Simulation parameters. */
    4.444444 / 1000,	/* Simulation time step (s). */
    1000,		/* Simulation time step division. */
    /* Simulation current state. */
    0,			/* Current time (not realy used) (s). */
    0,			/* Current input voltage (V). */
    0,			/* Current current (A). */
    0,			/* Current angular speed (o for omega) (rad/s). */
    0			/* Current theta (th for theta) (rad). */
};

/* Taz model, with a RE25G and a 1:20.25 ratio gearbox. */
static const struct motor_t tazg_model =
{
    /* Motor caracteristics. */
    407 * M_2_PI / 60,	/* Speed constant ((rad/s)/V). */
    40.2 / 1000,	/* Torque constant (N.m/A). */
    0,			/* Bearing friction (N.m/(rad/s)). */
    2.32,		/* Terminal resistance (Ohm). */
    0.24 / 1000,	/* Terminal inductance (H). */
    /* Gearbox caracteristics. */
    20.25,		/* Gearbox ratio. */
    0.75,		/* Gearbox efficiency. */
    /* Load caracteristics. */
    10 * 0.04 * 0.04,	/* Load (kg.m^2). */
    /* Simulation parameters. */
    4.444444 / 1000,	/* Simulation time step (s). */
    1000,		/* Simulation time step division. */
    /* Simulation current state. */
    0,			/* Current time (not realy used) (s). */
    0,			/* Current input voltage (V). */
    0,			/* Current current (A). */
    0,			/* Current angular speed (o for omega) (rad/s). */
    0			/* Current theta (th for theta) (rad). */
};

/* Table of models. */
static const struct
{
    const char *name;
    const struct motor_t *model;
} models[] = {
      { "gloubi", &gloubi_model },
      { "taz", &taz_model },
      { "tazg", &tazg_model },
      { 0, 0 }
};

/** Get a pointer to a model by name, or return 0. */
const struct motor_t *
models_get (const char *name)
{
    int i;
    for (i = 0; models[i].name; i++)
      {
	if (strcmp (models[i].name, name) == 0)
	    return models[i].model;
      }
    return 0;
}