2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Revision : $Id: main.c,v 1.1.2.3 2007-12-31 16:25:01 zer0 Exp $
26 #include <aversive/pgmspace.h>
27 #include <aversive/error.h>
28 #include <aversive/wait.h>
30 #include <scheduler.h>
32 #include <control_system_manager.h>
33 #include <position_manager.h>
34 #include <trajectory_manager.h>
38 /* XXX it is 90 don't forget it :) */
41 /* decrease track to decrease angle */
42 #define MOT_TRACK_CM 23.906
43 #define EXT_TRACK_CM 8.995 // 8.5
44 #define VIRTUAL_TRACK_CM MOT_TRACK_CM
46 #define DIST_IMP_CM 6160.0
48 #define LEFT_ENCODER_MOT ((void *)0)
49 #define RIGHT_ENCODER_MOT ((void *)1)
50 #define LEFT_ENCODER_EXT ((void *)2)
51 #define RIGHT_ENCODER_EXT ((void *)3)
54 #define LEFT_PWM ((void *)PWM3C)
55 #define RIGHT_PWM ((void *)PWM1A)
56 #define ROLL_PWM ((void *)PWM2)
58 #define DO_CS 1 /* control system */
59 #define DO_RS 2 /* robot system (angle/distance) */
60 #define DO_POS 4 /* process position */
61 #define DO_BD 8 /* process blocking detection */
62 #define DO_TIMER 16 /* check time and stop after 90 secs */
65 #define E_USER_NOTHING 193
67 #define BALL_IS_READY 1
68 #define BALL_IS_WHITE 2
69 #define BALL_COUNT (4+8)
70 #define BALL_SUCKED 16
73 #define BALL_COUNT_BIT 2
75 #define BALL_LAYDOWN 1
80 #define BALL_LAYDOWN_FORCE 6
81 #define BALL_EJECT_FORCE 7
86 struct robot_system rs;
87 struct robot_position pos;
90 struct quadramp_filter qr_a;
93 struct quadramp_filter qr_d;
95 struct trajectory traj;
98 /* WARNING : this test is only a compilation test */
99 /* it does not check that the module is working */
104 rs_set_ratio(&robot.rs, MOT_TRACK_CM / EXT_TRACK_CM);
105 rs_set_flags(&robot.rs, 0); /* rs use mot */
107 /* POSITION MANAGER */
108 position_init(&robot.pos);
109 position_set_physical_params(&robot.pos, VIRTUAL_TRACK_CM, DIST_IMP_CM);
110 position_set_related_robot_system(&robot.pos, &robot.rs);
111 position_use_ext(&robot.pos);
114 quadramp_init(&robot.qr_d);
115 quadramp_set_1st_order_vars(&robot.qr_d, 1000, 1000); /* set speed */
116 quadramp_set_2nd_order_vars(&robot.qr_d, 10, 10); /* set accel */
118 cs_init(&robot.cs_d);
119 cs_set_consign_filter(&robot.cs_d, quadramp_do_filter, &robot.qr_d);
120 cs_set_consign(&robot.cs_d, 0);
123 quadramp_init(&robot.qr_a);
124 quadramp_set_1st_order_vars(&robot.qr_a, 500, 500); /* set speed */
125 quadramp_set_2nd_order_vars(&robot.qr_a, 5, 5); /* set accel */
127 cs_init(&robot.cs_a);
128 cs_set_consign_filter(&robot.cs_a, quadramp_do_filter, &robot.qr_a);
129 cs_set_consign(&robot.cs_a, 0);
131 /* TRAJECTORY MANAGER */
132 trajectory_init(&robot.traj);
133 trajectory_set_cs(&robot.traj, &robot.cs_d, &robot.cs_a);
134 trajectory_set_robot_params(&robot.traj, &robot.rs, &robot.pos);
135 trajectory_set_windows(&robot.traj, 12.0, 15.0, 50.0);
139 scheduler_interrupt();