From 4e7a9fa756eb4093812074125a17e6825b2744c6 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 23 Mar 2013 08:12:35 +0100 Subject: digital/asserv, digital/mimot/asserv: add apbirthday parameters --- digital/ai/tools/apbirthday.py | 5 ++- digital/asserv/tools/asserv/init.py | 1 + digital/mimot/src/asserv/models.host.c | 62 ++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/digital/ai/tools/apbirthday.py b/digital/ai/tools/apbirthday.py index 13f06959..1dad3f0f 100644 --- a/digital/ai/tools/apbirthday.py +++ b/digital/ai/tools/apbirthday.py @@ -33,15 +33,14 @@ class Robot: def prog (cmd): cmd = [ s.format (instance = instance) for s in cmd ] subprocess.Popen (cmd) - # TODO: use apbirthday model for asserv. asserv_cmd = ('../../mimot/src/asserv/asserv.host', - '-i{instance}:asserv0', '-m9', 'guybrush') + '-i{instance}:asserv0', '-m9', 'apbirthday') io_hub_cmd = ('../../io-hub/src/apbirthday/apbirthday.host', '-i{instance}:io0') beacon_stub_cmd = ('../../beacon/src/stub/simu_stub.host', '-i{instance}:beacon0') self.asserv = proto (asserv.Proto, asserv_cmd, - asserv.init.host['guybrush']) + asserv.init.host['apbirthday']) self.io = proto (io_hub.ProtoGuybrush, io_hub_cmd, io_hub.init.host['apbirthday']) self.beacon_stub = prog (beacon_stub_cmd) diff --git a/digital/asserv/tools/asserv/init.py b/digital/asserv/tools/asserv/init.py index d28c1b32..495ebd82 100644 --- a/digital/asserv/tools/asserv/init.py +++ b/digital/asserv/tools/asserv/init.py @@ -36,6 +36,7 @@ host = { 'marcel': host_marcel, 'robospierre': host_robospierre, 'guybrush': host_guybrush, + 'apbirthday': host_guybrush, } target_marcel = dict ( scale = 0.0415178942124, footing = 0xcef, diff --git a/digital/mimot/src/asserv/models.host.c b/digital/mimot/src/asserv/models.host.c index ab55c341..e568ba1f 100644 --- a/digital/mimot/src/asserv/models.host.c +++ b/digital/mimot/src/asserv/models.host.c @@ -44,6 +44,9 @@ static int simu_table_test_guybrush (double p_x, double p_y); +static int +simu_table_test_apbirthday (double p_x, double p_y); + /* Guybrush, APBTeam 2012. */ static const struct robot_t guybrush_robot = { @@ -81,6 +84,43 @@ static const struct robot_t guybrush_robot = NULL, }; +/* APBirthday, APBTeam 2013. TODO: update base dimensions. */ +static const struct robot_t apbirthday_robot = +{ + /* Main motors. */ + &motor_model_def_faulhaber_2657_x9_7, + /* Motors voltage (V). */ + 24.0, + /* Number of steps on the main motors encoders. */ + 2500, + /* Wheel radius (m). */ + 0.065 / 2, + /* Distance between the wheels (m). */ + 0.16, + /* Weight of the robot (kg). */ + 10.0, + /* Distance of the gravity center from the center of motors axis (m). */ + 0.0, + /* Whether the encoder is mounted on the main motor (false) or not (true). */ + 1, + /** Encoder wheel radius (m). */ + 0.063 / 2, + /** Distance between the encoders wheels (m). */ + 0.28, + /** No auxiliary motors. */ + { }, { }, { }, + /** Sensor update function. */ + NULL, + /** Table test function, return false if given robot point is not in + * table. */ + simu_table_test_apbirthday, + /** Robot corners, from front left, then clockwise. */ + { { 102, 140 }, { 102, -140 }, { -108, -140 }, { -108, 70 }, + { -58, 140 } }, + /** Initialisation function. */ + NULL, +}; + /* Table of models. */ static const struct { @@ -88,6 +128,7 @@ static const struct const struct robot_t *robot; } models[] = { { "guybrush", &guybrush_robot }, + { "apbirthday", &apbirthday_robot }, { 0, 0 } }; @@ -165,3 +206,24 @@ simu_table_test_guybrush (double p_x, double p_y) return 1; } +/* Table test for APBirthday. */ +int +simu_table_test_apbirthday (double p_x, double p_y) +{ + static const double table_width = 3000.0, table_height = 2000.0; + double x, y; + simu_compute_absolute_position (p_x, p_y, &x, &y); + if (x < 0 || y < 0 || x >= table_width || y >= table_height) + return 0; + /* Sideboards. */ + if ((x < 400 || x >= table_width - 400) + && (y < 100 || y >= table_height - 100)) + return 0; + /* Cake. */ + double cake_dx = table_width / 2 - x; + double cake_dy = table_height - y; + if (cake_dx * cake_dx + cake_dy * cake_dy < 500 * 500) + return 0; + return 1; +} + -- cgit v1.2.3