summaryrefslogtreecommitdiff
path: root/n/asserv
diff options
context:
space:
mode:
Diffstat (limited to 'n/asserv')
-rw-r--r--n/asserv/src/asserv/main.c2
-rw-r--r--n/asserv/utils/graph/Makefile6
-rw-r--r--n/asserv/utils/graph/Makefile.defs4
-rw-r--r--n/asserv/utils/graph/asserv_graph.cc138
-rw-r--r--n/asserv/utils/graph/rc/config12
5 files changed, 162 insertions, 0 deletions
diff --git a/n/asserv/src/asserv/main.c b/n/asserv/src/asserv/main.c
index b32f2b1..866d784 100644
--- a/n/asserv/src/asserv/main.c
+++ b/n/asserv/src/asserv/main.c
@@ -180,7 +180,9 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args)
pos_reset ();
main_mode = 0;
pwm_left = v8_to_v16 (args[0], args[1]);
+ UTILS_BOUND (pwm_left, -PWM_MAX, PWM_MAX);
pwm_right = v8_to_v16 (args[2], args[3]);
+ UTILS_BOUND (pwm_right, -PWM_MAX, PWM_MAX);
break;
case c ('c', 4):
/* Add to position consign.
diff --git a/n/asserv/utils/graph/Makefile b/n/asserv/utils/graph/Makefile
new file mode 100644
index 0000000..b4feaed
--- /dev/null
+++ b/n/asserv/utils/graph/Makefile
@@ -0,0 +1,6 @@
+SRCDIR = ../../../../i/marvin/src
+EXTRA_SUBDIRS = .
+
+local-all: asserv_graph
+
+include $(SRCDIR)/Makefile.defs
diff --git a/n/asserv/utils/graph/Makefile.defs b/n/asserv/utils/graph/Makefile.defs
new file mode 100644
index 0000000..a159e7b
--- /dev/null
+++ b/n/asserv/utils/graph/Makefile.defs
@@ -0,0 +1,4 @@
+PROGRAMS += asserv_graph
+
+asserv_graph_OBJECTS = asserv_graph.o $(proto_OBJECTS) $(log_OBJECTS) \
+ $(serial_OBJECTS) $(utils_OBJECTS) $(timer_OBJECTS)
diff --git a/n/asserv/utils/graph/asserv_graph.cc b/n/asserv/utils/graph/asserv_graph.cc
new file mode 100644
index 0000000..a3760e6
--- /dev/null
+++ b/n/asserv/utils/graph/asserv_graph.cc
@@ -0,0 +1,138 @@
+// asserv_graph.cc
+// {{{
+//
+// 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 "proto/proto.hh"
+#include "timer/timer.hh"
+#include "config/config.hh"
+
+#include <iostream>
+#include <stdexcept>
+
+/// Classe de connexion à Proto.
+class AsservGraph : public Proto::Receiver
+{
+ Proto proto_;
+ int tkp, tki, tkd;
+ int akp, aki, akd;
+ int es, is;
+ int te, ti, ae, ai;
+ int pl, pr;
+ int n;
+ public:
+ AsservGraph (void)
+ : proto_ (*this),
+ te (0), ti (0), ae (0), ai (0),
+ n (0)
+ {
+ Config &config = Config::getInstance ();
+ tkp = config.get<int> ("asserv.tkp");
+ tki = config.get<int> ("asserv.tkd");
+ tkd = config.get<int> ("asserv.tki");
+ akp = config.get<int> ("asserv.akp");
+ aki = config.get<int> ("asserv.akd");
+ akd = config.get<int> ("asserv.aki");
+ es = config.get<int> ("asserv.esat");
+ is = config.get<int> ("asserv.isat");
+ proto_.open (config.get<std::string> ("asserv.tty"));
+ init ();
+ }
+ ~AsservGraph (void)
+ {
+ proto_.send ('z');
+ }
+ void init (void)
+ {
+ proto_.send ('z');
+ proto_.send ('p', "bww", 'p', tkp, akp);
+ proto_.send ('p', "bww", 'i', tki, aki);
+ proto_.send ('p', "bww", 'd', tkd, akd);
+ proto_.send ('p', "bw", 'E', es);
+ proto_.send ('p', "bw", 'I', is);
+ proto_.send ('P', "b", 1);
+ proto_.send ('W', "b", 1);
+ }
+ void receive (char command, const Proto::Frame &frame)
+ {
+ switch (command)
+ {
+ case 'P':
+ proto_.decode (frame, "WWWW", te, ti, ae, ai);
+ break;
+ case 'W':
+ if (proto_.decode (frame, "WW", pl, pr))
+ {
+ std::cout << te << ' ' << ti << ' ' << ae << ' ' << ai << ' '
+ << pl << ' ' << pr << std::endl;
+ te = ti = ae = ai = 0;
+ n++;
+ }
+ break;
+ }
+ }
+ void main (void)
+ {
+ proto_.send ('w', "ww", 0x3ff, 0x3ff);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ proto_.send ('w');
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ proto_.send ('c', "ww", 16, 0);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ proto_.send ('w');
+ }
+};
+
+/// Affiche un memo de syntaxe.
+void
+syntax (void)
+{
+ std::cout << "asserv_graph - graphe des variables de l'asservissement.\n"
+ "Syntaxe : asserv_graph\n"
+ " ? affiche cet écran d'aide\n"
+ << std::endl;
+}
+
+int
+main (int argc, char **argv)
+{
+ try
+ {
+ if (argc != 1)
+ {
+ syntax ();
+ return 1;
+ }
+ Config config (argc, argv);
+ AsservGraph asservGraph;
+ asservGraph.main ();
+ }
+ catch (const std::exception &e)
+ {
+ std::cerr << e.what () << std::endl;
+ return 1;
+ }
+ return 0;
+}
diff --git a/n/asserv/utils/graph/rc/config b/n/asserv/utils/graph/rc/config
new file mode 100644
index 0000000..e110c54
--- /dev/null
+++ b/n/asserv/utils/graph/rc/config
@@ -0,0 +1,12 @@
+asserv.tty = "../../src/asserv/uart0.pts"
+
+asserv.tkp = 700
+asserv.tki = 20
+asserv.tkd = 0
+
+asserv.akp = 0
+asserv.aki = 0
+asserv.akd = 0
+
+asserv.esat = 4095
+asserv.isat = 400