summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2013-03-31 19:28:24 +0200
committerNicolas Schodet2013-03-31 19:28:24 +0200
commitb3392b2c9b5e808e868b092422d7b143a82c4628 (patch)
tree0586a54f57e5b392aae8839acf5e2e5e9698c207 /digital
parent3adb1db9e53ab8d33f25913376c8172d48253e34 (diff)
digital/io-hub/src/apbirthday: add radar system and obstacles handling
Diffstat (limited to 'digital')
-rw-r--r--digital/io-hub/src/apbirthday/Makefile3
-rw-r--r--digital/io-hub/src/apbirthday/hardware.hh6
-rw-r--r--digital/io-hub/src/apbirthday/hardware.host.cc3
-rw-r--r--digital/io-hub/src/apbirthday/radar_2013.cc50
-rw-r--r--digital/io-hub/src/apbirthday/radar_2013.hh40
-rw-r--r--digital/io-hub/src/apbirthday/robot.cc9
-rw-r--r--digital/io-hub/src/apbirthday/robot.hh6
-rw-r--r--digital/io-hub/src/common-cc/defs.hh1
-rw-r--r--digital/io-hub/src/common-cc/obstacles.cc105
-rw-r--r--digital/io-hub/src/common-cc/obstacles.hh68
-rw-r--r--digital/io-hub/src/common-cc/radar.cc101
-rw-r--r--digital/io-hub/src/common-cc/radar.hh74
-rw-r--r--digital/io-hub/src/common-cc/simu_report.host.cc42
-rw-r--r--digital/io-hub/src/common-cc/simu_report.host.hh42
14 files changed, 547 insertions, 3 deletions
diff --git a/digital/io-hub/src/apbirthday/Makefile b/digital/io-hub/src/apbirthday/Makefile
index 17254322..5611319d 100644
--- a/digital/io-hub/src/apbirthday/Makefile
+++ b/digital/io-hub/src/apbirthday/Makefile
@@ -3,9 +3,10 @@ BASE = ../../../ucoolib
TARGETS = host stm32f4
PROGS = apbirthday
apbirthday_SOURCES = main.cc robot.cc hardware.host.cc hardware.stm32.cc \
- zb_avrisp.stm32.cc \
+ simu_report.host.cc zb_avrisp.stm32.cc \
i2c_queue.cc asserv.cc mimot.cc \
pressure.cc chrono.host.cc chrono.stm32.cc \
+ radar.cc radar_2013.cc obstacles.cc \
outputs.cc \
top.cc init.cc move.cc candles.cc \
angfsm.host.c angfsm_gen_arm_AI.arm.c fsm_queue.cc \
diff --git a/digital/io-hub/src/apbirthday/hardware.hh b/digital/io-hub/src/apbirthday/hardware.hh
index 55caea40..63665222 100644
--- a/digital/io-hub/src/apbirthday/hardware.hh
+++ b/digital/io-hub/src/apbirthday/hardware.hh
@@ -33,6 +33,9 @@
#else
# include "ucoolib/arch/host/host_stream.hh"
#endif
+#ifdef TARGET_host
+# include "simu_report.host.hh"
+#endif
#ifdef TARGET_host
# include "ucoolib/arch/host/host.hh"
@@ -95,6 +98,9 @@ struct Hardware
ucoo::AdcHost adc_dist0, adc_dist1, adc_dist2, adc_dist3;
ucoo::AdcHost adc_pressure;
#endif
+#ifdef TARGET_host
+ SimuReport simu_report;
+#endif
Hardware ();
// Wait until next cycle.
void wait ();
diff --git a/digital/io-hub/src/apbirthday/hardware.host.cc b/digital/io-hub/src/apbirthday/hardware.host.cc
index a53962b7..39fe110b 100644
--- a/digital/io-hub/src/apbirthday/hardware.host.cc
+++ b/digital/io-hub/src/apbirthday/hardware.host.cc
@@ -66,7 +66,8 @@ Hardware::Hardware ()
adc_dist1 (host, "dist1", 1 << 12),
adc_dist2 (host, "dist2", 1 << 12),
adc_dist3 (host, "dist3", 1 << 12),
- adc_pressure (host, "pressure", 1 << 12)
+ adc_pressure (host, "pressure", 1 << 12),
+ simu_report (host)
{
dev_uart.block (false);
zb_uart.block (false);
diff --git a/digital/io-hub/src/apbirthday/radar_2013.cc b/digital/io-hub/src/apbirthday/radar_2013.cc
new file mode 100644
index 00000000..5cbbe0ca
--- /dev/null
+++ b/digital/io-hub/src/apbirthday/radar_2013.cc
@@ -0,0 +1,50 @@
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "radar_2013.hh"
+#include "playground.hh"
+
+RadarSensor sensors[] = {
+ { 0, { 102, 84 }, G_ANGLE_UF016_DEG (0), true },
+ { 0, { 102, -84 }, G_ANGLE_UF016_DEG (0), false },
+ { 0, { -78, 104 }, G_ANGLE_UF016_DEG (180), true },
+ { 0, { -83, -120 }, G_ANGLE_UF016_DEG (180), false },
+};
+
+Radar2013::Radar2013 (ucoo::UsDist &dist0, ucoo::UsDist &dist1,
+ ucoo::UsDist &dist2, ucoo::UsDist &dist3)
+ : Radar (150, sensors, lengthof (sensors))
+{
+ sensors[0].sensor = &dist0;
+ sensors[1].sensor = &dist1;
+ sensors[2].sensor = &dist2;
+ sensors[3].sensor = &dist3;
+}
+
+bool
+Radar2013::valid (int sensor_index, vect_t &p)
+{
+ return p.x >= margin_mm && p.x < pg_width - margin_mm
+ && p.y >= margin_mm && p.y < pg_length - margin_mm;
+}
+
diff --git a/digital/io-hub/src/apbirthday/radar_2013.hh b/digital/io-hub/src/apbirthday/radar_2013.hh
new file mode 100644
index 00000000..d865fbca
--- /dev/null
+++ b/digital/io-hub/src/apbirthday/radar_2013.hh
@@ -0,0 +1,40 @@
+#ifndef radar_2013_hh
+#define radar_2013_hh
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "radar.hh"
+
+/// APBirthday specific radar.
+class Radar2013 : public Radar
+{
+ public:
+ /// Constructor.
+ Radar2013 (ucoo::UsDist &dist0, ucoo::UsDist &dist1,
+ ucoo::UsDist &dist2, ucoo::UsDist &dist3);
+ protected:
+ /// See Radar::valid.
+ bool valid (int sensor_index, vect_t &p);
+};
+
+#endif // radar_2013_hh
diff --git a/digital/io-hub/src/apbirthday/robot.cc b/digital/io-hub/src/apbirthday/robot.cc
index 70b70e98..a40ca160 100644
--- a/digital/io-hub/src/apbirthday/robot.cc
+++ b/digital/io-hub/src/apbirthday/robot.cc
@@ -44,6 +44,7 @@ Robot::Robot ()
usdist1_ (usdist_control_, hardware.adc_dist1, hardware.dist1_sync, 100, 700, 650),
usdist2_ (usdist_control_, hardware.adc_dist2, hardware.dist2_sync, 100, 700, 650),
usdist3_ (usdist_control_, hardware.adc_dist3, hardware.dist3_sync, 100, 700, 650),
+ radar_ (usdist0_, usdist1_, usdist2_, usdist3_),
candles (1),
fsm_debug_state_ (FSM_DEBUG_RUN),
outputs_set_ (outputs_, lengthof (outputs_)),
@@ -108,7 +109,13 @@ Robot::main_loop ()
// Wait until next cycle.
hardware.wait ();
// Update IO modules.
- usdist_control_.update ();
+ if (usdist_control_.update ())
+ {
+ Position robot_pos;
+ asserv.get_position (robot_pos);
+ radar_.update (robot_pos, obstacles);
+ }
+ obstacles.update ();
pressure.update ();
outputs_set_.update ();
// Handle communications.
diff --git a/digital/io-hub/src/apbirthday/robot.hh b/digital/io-hub/src/apbirthday/robot.hh
index aaac185b..35b2266a 100644
--- a/digital/io-hub/src/apbirthday/robot.hh
+++ b/digital/io-hub/src/apbirthday/robot.hh
@@ -29,6 +29,8 @@
#include "chrono.hh"
#include "pressure.hh"
#include "outputs.hh"
+#include "radar_2013.hh"
+#include "obstacles.hh"
#include "candles.hh"
#include "ucoolib/base/proto/proto.hh"
@@ -74,7 +76,11 @@ class Robot : public ucoo::Proto::Handler
ucoo::UsDistControl usdist_control_;
/// US distance sensors.
ucoo::UsDist usdist0_, usdist1_, usdist2_, usdist3_;
+ /// Radar.
+ Radar2013 radar_;
public:
+ /// Obstacle database.
+ Obstacles obstacles;
/// Candles.
Candles candles;
private:
diff --git a/digital/io-hub/src/common-cc/defs.hh b/digital/io-hub/src/common-cc/defs.hh
index 4475b299..72053720 100644
--- a/digital/io-hub/src/common-cc/defs.hh
+++ b/digital/io-hub/src/common-cc/defs.hh
@@ -23,6 +23,7 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// }}}
+#include "ucoolib/common.hh"
/// General purpose definitions.
diff --git a/digital/io-hub/src/common-cc/obstacles.cc b/digital/io-hub/src/common-cc/obstacles.cc
new file mode 100644
index 00000000..d98a92ba
--- /dev/null
+++ b/digital/io-hub/src/common-cc/obstacles.cc
@@ -0,0 +1,105 @@
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "obstacles.hh"
+
+extern "C" {
+#include "modules/math/geometry/distance.h"
+}
+
+#ifdef TARGET_host
+# include "robot.hh"
+#endif
+
+Obstacles::Obstacles ()
+ : changed_ (false)
+{
+ for (int i = 0; i < obstacles_nb_; i++)
+ obstacles_[i].valid = 0;
+}
+
+void
+Obstacles::update ()
+{
+ for (int i = 0; i < obstacles_nb_; i++)
+ {
+ if (obstacles_[i].valid)
+ obstacles_[i].valid--;
+ }
+#ifdef TARGET_host
+ if (changed_)
+ {
+ SimuReport &r = robot->hardware.simu_report;
+ vect_t o[obstacles_nb_];
+ int o_nb = 0;
+ for (int i = 0; i < obstacles_nb_; i++)
+ {
+ if (obstacles_[i].valid)
+ o[o_nb++] = obstacles_[i].pos;
+ }
+ r.pos (o, o_nb, 0);
+ }
+#endif
+ changed_ = false;
+}
+
+void
+Obstacles::add (const vect_t &pos)
+{
+ // Try to merge, and find the oldest on the way.
+ int oldest_i = 0, oldest_i_valid = valid_new_;
+ for (int i = 0; i < obstacles_nb_; i++)
+ {
+ if (obstacles_[i].valid)
+ {
+ if (distance_point_point (&pos, &obstacles_[i].pos) < same_mm_)
+ {
+ // Replace if older.
+ if (obstacles_[i].valid < valid_new_)
+ {
+ obstacles_[i].pos = pos;
+ obstacles_[i].valid = valid_new_;
+ changed_ = true;
+ }
+ return;
+ }
+ }
+ if (obstacles_[i].valid < oldest_i_valid)
+ {
+ oldest_i = i;
+ oldest_i_valid = obstacles_[i].valid;
+ }
+ }
+ // If not found, replace the oldest.
+ obstacles_[oldest_i].pos = pos;
+ obstacles_[oldest_i].valid = valid_new_;
+ changed_ = true;
+}
+
+bool
+Obstacles::blocking (const vect_t &robot, const vect_t &dest) const
+{
+ // TODO
+ return false;
+}
+
diff --git a/digital/io-hub/src/common-cc/obstacles.hh b/digital/io-hub/src/common-cc/obstacles.hh
new file mode 100644
index 00000000..c3d2bc34
--- /dev/null
+++ b/digital/io-hub/src/common-cc/obstacles.hh
@@ -0,0 +1,68 @@
+#ifndef obstacles_hh
+#define obstacles_hh
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "defs.hh"
+
+/// Handle obstacles "database".
+///
+/// At each cycle, obstacle detections can come and go. This class will keep
+/// tracks of previously seen obstacles, and merge new detection events with
+/// past history.
+///
+/// This class also decide if an obstacle is in the robot way.
+class Obstacles
+{
+ public:
+ /// Constructor.
+ Obstacles ();
+ /// To be called at each cycle.
+ void update ();
+ /// Add an obstacle detection.
+ void add (const vect_t &pos);
+ /// Return true if there is an obstacle near the robot while going to a
+ /// destination point.
+ bool blocking (const vect_t &robot, const vect_t &dest) const;
+ private:
+ /// Validity period of a new obstacle.
+ static const int valid_new_ = 125;
+ /// Distance under which obstacles are considered the same.
+ static const int same_mm_ = 150;
+ /// Set when changed since last update.
+ bool changed_;
+ /// Single obstacle.
+ struct Obstacle
+ {
+ /// Position.
+ vect_t pos;
+ /// Validity period as a number of cycles, or 0 if unvalid.
+ int valid;
+ };
+ /// Number of obstacles.
+ static const int obstacles_nb_ = 4;
+ /// Obstacles array.
+ Obstacle obstacles_[obstacles_nb_];
+};
+
+#endif // obstacles_hh
diff --git a/digital/io-hub/src/common-cc/radar.cc b/digital/io-hub/src/common-cc/radar.cc
new file mode 100644
index 00000000..d7f2a96f
--- /dev/null
+++ b/digital/io-hub/src/common-cc/radar.cc
@@ -0,0 +1,101 @@
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "radar.hh"
+
+/// Maximum distance for a sensor reading to be ignored if another sensor is
+// nearer.
+static const int far_mm = 250;
+
+void
+Radar::update (const Position &robot_pos, Obstacles &obstacles)
+{
+ int i, j;
+ vect_t ray;
+ // Compute hit points for each sensor and eliminate invalid ones.
+ vect_t hit[sensors_nb_];
+ int dist_mm[sensors_nb_];
+ for (i = 0; i < sensors_nb_; i++)
+ {
+ dist_mm[i] = sensors_[i].sensor->get ();
+ if (dist_mm[i] != -1)
+ {
+ hit[i] = sensors_[i].pos;
+ vect_rotate_uf016 (&hit[i], robot_pos.a);
+ vect_translate (&hit[i], &robot_pos.v);
+ vect_from_polar_uf016 (&ray, dist_mm[i],
+ robot_pos.a + sensors_[i].a);
+ vect_translate (&hit[i], &ray);
+ if (valid (i, hit[i]))
+ {
+ vect_from_polar_uf016 (&ray, obstacle_edge_radius_mm_,
+ robot_pos.a + sensors_[i].a);
+ vect_translate (&hit[i], &ray);
+ }
+ else
+ dist_mm[i] = -1;
+ }
+ }
+ // Ignore sensor results too far from other sensors of the same group.
+ for (i = 0; i < sensors_nb_ - 1; i++)
+ {
+ if (dist_mm[i] != -1)
+ {
+ for (j = i + 1; j < sensors_nb_ && !sensors_[j].new_group; j++)
+ {
+ if (dist_mm[j] != -1)
+ {
+ if (dist_mm[i] + far_mm < dist_mm[j])
+ dist_mm[j] = -1;
+ else if (dist_mm[j] + far_mm < dist_mm[i])
+ dist_mm[i] = -1;
+ }
+ }
+ }
+ }
+ // Compute hit point from all sensors in the same group.
+ vect_t hit_center = { 0, 0 };
+ int hit_nb = 0;
+ for (i = 0; i < sensors_nb_; i++)
+ {
+ if (dist_mm[i] != -1)
+ {
+ vect_add (&hit_center, &hit[i]);
+ hit_nb++;
+ }
+ // If last of group or last sensor, may add obstacle.
+ if ((i == sensors_nb_ - 1 || sensors_[i + 1].new_group) && hit_nb)
+ {
+ if (hit_nb > 1)
+ {
+ hit_center.x /= hit_nb;
+ hit_center.y /= hit_nb;
+ }
+ obstacles.add (hit_center);
+ hit_center.x = 0;
+ hit_center.y = 0;
+ hit_nb = 0;
+ }
+ }
+}
+
diff --git a/digital/io-hub/src/common-cc/radar.hh b/digital/io-hub/src/common-cc/radar.hh
new file mode 100644
index 00000000..d2cb2d83
--- /dev/null
+++ b/digital/io-hub/src/common-cc/radar.hh
@@ -0,0 +1,74 @@
+#ifndef radar_hh
+#define radar_hh
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "defs.hh"
+#include "ucoolib/dev/usdist/usdist.hh"
+#include "obstacles.hh"
+
+/// Describe a radar sensor.
+struct RadarSensor
+{
+ /// US distance sensor.
+ ucoo::UsDist *sensor;
+ /// Position relative to the robot center.
+ vect_t pos;
+ /// Angle relative to the robot X axis.
+ uint16_t a;
+ /// Part of an new sensor group?
+ bool new_group;
+};
+
+/// Handle any distance sensors information to extract useful data. This
+/// includes:
+/// - combining several sensors information for a more precise obstacle
+/// position,
+/// - ignoring obstacles not in the playground.
+class Radar
+{
+ public:
+ /// Margin to be considered inside the playground. An obstacle can not be
+ /// exactly at the playground edge.
+ static const int margin_mm = 150;
+ protected:
+ /// Constructor.
+ Radar (int obstacle_edge_radius_mm, RadarSensor *sensors, int sensors_nb)
+ : obstacle_edge_radius_mm_ (obstacle_edge_radius_mm),
+ sensors_ (sensors), sensors_nb_ (sensors_nb) { }
+ /// Define exclusion area, return true if point is valid.
+ virtual bool valid (int sensor_index, vect_t &p) = 0;
+ public:
+ /// Update radar view. Record found obstacles.
+ void update (const Position &robot_pos, Obstacles &obstacles);
+ private:
+ /// Estimated obstacle edge radius. As the sensors detect obstacle edge,
+ /// this is added to position obstacle center.
+ const int obstacle_edge_radius_mm_;
+ /// Sensors description.
+ RadarSensor *sensors_;
+ /// Number of sensors.
+ int sensors_nb_;
+};
+
+#endif // radar_hh
diff --git a/digital/io-hub/src/common-cc/simu_report.host.cc b/digital/io-hub/src/common-cc/simu_report.host.cc
new file mode 100644
index 00000000..2a3f98fd
--- /dev/null
+++ b/digital/io-hub/src/common-cc/simu_report.host.cc
@@ -0,0 +1,42 @@
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "simu_report.host.hh"
+
+SimuReport::SimuReport (ucoo::Host &host)
+ : node_ (host.get_node ())
+{
+ std::string instance (host.get_instance ());
+ pos_mtype_ = node_.reserve (instance + ":pos-report");
+}
+
+void
+SimuReport::pos (vect_t *pos, int pos_nb, uint8_t id)
+{
+ ucoo::mex::Msg msg (pos_mtype_);
+ msg.push ("B") << id;
+ for (; pos_nb; pos++, pos_nb--)
+ msg.push ("hh") << pos->x << pos->y;
+ node_.send (msg);
+}
+
diff --git a/digital/io-hub/src/common-cc/simu_report.host.hh b/digital/io-hub/src/common-cc/simu_report.host.hh
new file mode 100644
index 00000000..8e8929ad
--- /dev/null
+++ b/digital/io-hub/src/common-cc/simu_report.host.hh
@@ -0,0 +1,42 @@
+#ifndef simu_report_host_hh
+#define simu_report_host_hh
+// io-hub - Modular Input/Output. {{{
+//
+// Copyright (C) 2013 Nicolas Schodet
+//
+// APBTeam:
+// Web: http://apbteam.org/
+// Email: team AT apbteam DOT org
+//
+// 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 "ucoolib/arch/host/host.hh"
+#include "defs.hh"
+
+/// Report internal information to be displayed by simulator interface.
+class SimuReport
+{
+ public:
+ /// Constructor.
+ SimuReport (ucoo::Host &host);
+ /// Report positions.
+ void pos (vect_t *pos, int pos_nb, uint8_t id);
+ private:
+ ucoo::mex::Node &node_;
+ ucoo::mex::mtype_t pos_mtype_;
+};
+
+#endif // simu_report_host_hh