summaryrefslogtreecommitdiff
path: root/n/asserv/utils
diff options
context:
space:
mode:
authorschodet2006-05-05 19:41:47 +0000
committerschodet2006-05-05 19:41:47 +0000
commit5a534ef4253328eec26acfabc8d8cbcb5641b67c (patch)
treebd30b38bd4c09c9f7d71c7068aad72ecd93ec53d /n/asserv/utils
parent4e5c530cd695b4c5807a16b017b3fa9ef1d61886 (diff)
Plus de trous, plus de stats et plus de coefs qui vont bien :)
Diffstat (limited to 'n/asserv/utils')
-rw-r--r--n/asserv/utils/graph/asserv_graph.cc57
-rw-r--r--n/asserv/utils/graph/plot/host.plot2
-rw-r--r--n/asserv/utils/graph/rc/config.avr14
-rw-r--r--n/asserv/utils/graph/rc/config.host6
4 files changed, 70 insertions, 9 deletions
diff --git a/n/asserv/utils/graph/asserv_graph.cc b/n/asserv/utils/graph/asserv_graph.cc
index 6de6c52..2453031 100644
--- a/n/asserv/utils/graph/asserv_graph.cc
+++ b/n/asserv/utils/graph/asserv_graph.cc
@@ -39,18 +39,26 @@ class AsservGraph : public Proto::Receiver
int akp, aki, akd;
int es, is;
int ta, aa;
+ int tspm, aspm;
int te, ti, ae, ai;
int tsc, asc;
int cl, cr;
+ int hx, hy, ha, dh;
+ int z0, z1, z2;
int pl, pr;
int n;
- int sP, sS, sC, sW;
+ int sP, sS, sC, sW, sY;
+ bool host;
+ double iu_mm;
+ int seq;
public:
AsservGraph (int argc, char **argv)
: proto_ (*this), argc_ (argc), argv_ (argv),
te (0), ti (0), ae (0), ai (0),
tsc (0), asc (0), cl (0), cr (0),
- n (0)
+ hx (0), hy (0), ha (0), dh (0),
+ z0 (0), z1 (0), z2 (0),
+ n (0), seq (1)
{
Config &config = Config::getInstance ();
tkp = config.get<int> ("asserv.tkp");
@@ -63,10 +71,18 @@ class AsservGraph : public Proto::Receiver
is = config.get<int> ("asserv.isat");
ta = config.get<int> ("asserv.ta");
aa = config.get<int> ("asserv.aa");
+ tspm = config.get<int> ("asserv.tspm");
+ aspm = config.get<int> ("asserv.aspm");
sP = config.get<int> ("asserv.stat_pos");
sS = config.get<int> ("asserv.stat_speed");
sC = config.get<int> ("asserv.stat_count");
sW = config.get<int> ("asserv.stat_pwm");
+ host = config.get<bool> ("host");
+ if (host)
+ {
+ sY = config.get<int> ("asserv.stat_simu");
+ iu_mm = config.get<double> ("iu_mm");
+ }
proto_.open (config.get<std::string> ("asserv.tty"));
init ();
}
@@ -83,10 +99,14 @@ class AsservGraph : public Proto::Receiver
proto_.send ('p', "bw", 'E', es);
proto_.send ('p', "bw", 'I', is);
proto_.send ('p', "bww", 'a', ta, aa);
+ proto_.send ('p', "bbb", 's', tspm, aspm);
proto_.send ('P', "b", sP);
proto_.send ('S', "b", sS);
proto_.send ('C', "b", sC);
proto_.send ('W', "b", sW);
+ if (host)
+ proto_.send ('Y', "b", sY);
+ ///proto_.send ('p', "bw", 'h', (int) ((110 - 0) * iu_mm));
}
void receive (char command, const Proto::Frame &frame)
{
@@ -101,15 +121,26 @@ class AsservGraph : public Proto::Receiver
case 'C':
proto_.decode (frame, "WW", cl, cr);
break;
+ case 'Y':
+ proto_.decode (frame, "WWWW", hx, hy, ha, dh);
+ break;
+ case 'Z':
+ proto_.decode (frame, "BBB", z0, z1, z2);
+ break;
case 'W':
if (proto_.decode (frame, "WW", pl, pr))
{
std::cout << te << ' ' << ti << ' ' << ae << ' ' << ai << ' '
<< pl << ' ' << pr << ' ' << tsc << ' ' << asc << ' '
- << cl << ' ' << cr << std::endl;
+ << hx << ' ' << hy << ' ' << ((double) ha / 1024) << ' '
+ << dh << ' '
+ << cl << ' ' << cr << ' '
+ << z0 << ' ' << z1 << ' ' << z2 << std::endl;
te = ti = ae = ai = 0;
tsc = asc = 0;
cl = cr = 0;
+ hx = hy = ha = dh = 0;
+ z0 = z1 = z2 = 0;
n++;
}
break;
@@ -124,8 +155,25 @@ class AsservGraph : public Proto::Receiver
" c teste le pas\n"
" s DUR teste la vitesse\n"
" p teste la position à vitesse controlée\n"
+ " h teste la detection de trous\n"
<< std::endl;
}
+ void find_holes (void)
+ {
+ if (host)
+ {
+ proto_.send ('y', "bwww", 'X', 1050 + 50, 400, (int) (M_PI_2 * 1024));
+ proto_.send ('h', "b", seq++);
+ for (n = 0; n < 1000;)
+ proto_.wait (-1);
+ }
+ else
+ {
+ proto_.send ('h', "b", seq++);
+ for (n = 0; n < 1000;)
+ proto_.wait (-1);
+ }
+ }
int main (void)
{
if (argc_ == 1)
@@ -168,6 +216,9 @@ class AsservGraph : public Proto::Receiver
for (n = 0; n < 500;)
proto_.wait (-1);
break;
+ case 'h':
+ find_holes ();
+ break;
default:
throw std::runtime_error ("bad command line");
break;
diff --git a/n/asserv/utils/graph/plot/host.plot b/n/asserv/utils/graph/plot/host.plot
index 222c009..d138757 100644
--- a/n/asserv/utils/graph/plot/host.plot
+++ b/n/asserv/utils/graph/plot/host.plot
@@ -1,3 +1,3 @@
set style data line
plot 'host' using 1 title "te", 'host' using 3 title "ti", 'host' using 3 title "ae", 'host' using 4 title "ai", 'host' using 5 title "pl", 'host' using 6 title "pr", 'host' using 7 title "tsc", 'host' using 8 title "asc"
-#, 'host' using 9 title "cl", 'host' using 10 title "cr"
+#, 'host' using 12 title "cl", 'host' using 13 title "cr"
diff --git a/n/asserv/utils/graph/rc/config.avr b/n/asserv/utils/graph/rc/config.avr
index dad73b8..0bf6222 100644
--- a/n/asserv/utils/graph/rc/config.avr
+++ b/n/asserv/utils/graph/rc/config.avr
@@ -1,20 +1,24 @@
asserv.tty = "/dev/ttyS0"
-asserv.tkp = 1024
-asserv.tki = 128
+asserv.tkp = 512
+asserv.tki = 64
asserv.tkd = 0
-asserv.akp = 512
-asserv.aki = 32
+asserv.akp = 2048
+asserv.aki = 128
asserv.akd = 0
asserv.esat = 1023
asserv.isat = 255
+asserv.tspm = 64
+asserv.aspm = 64
asserv.ta = 256
asserv.aa = 256
asserv.stat_pos = 1
asserv.stat_speed = 0
-asserv.stat_count = 1
+asserv.stat_count = 0
asserv.stat_pwm = 1
+
+host = false
diff --git a/n/asserv/utils/graph/rc/config.host b/n/asserv/utils/graph/rc/config.host
index 3bf18ed..5661d96 100644
--- a/n/asserv/utils/graph/rc/config.host
+++ b/n/asserv/utils/graph/rc/config.host
@@ -13,8 +13,14 @@ asserv.isat = 128
asserv.ta = 256
asserv.aa = 256
+asserv.tspm = 64
+asserv.aspm = 64
asserv.stat_pos = 1
asserv.stat_speed = 1
asserv.stat_count = 1
asserv.stat_pwm = 1
+asserv.stat_simu = 1
+
+host = true
+iu_mm = 75.78789091394133410940