summaryrefslogtreecommitdiff
path: root/n/asserv/utils/graph/asserv_graph.cc
diff options
context:
space:
mode:
authorschodet2006-03-26 14:17:46 +0000
committerschodet2006-03-26 14:17:46 +0000
commita995bb9ff446a514ce99064ad9fc6c2f8c773eba (patch)
treee8344f6aa012c7e359b164173ab76ef62bfc98d0 /n/asserv/utils/graph/asserv_graph.cc
parent98f731d45cb51040bb6ee364920cb0de34939e0a (diff)
Ajout de la gestion en vitesse, d'une ligne de commande.
Correction d'inversion I et D.
Diffstat (limited to 'n/asserv/utils/graph/asserv_graph.cc')
-rw-r--r--n/asserv/utils/graph/asserv_graph.cc119
1 files changed, 84 insertions, 35 deletions
diff --git a/n/asserv/utils/graph/asserv_graph.cc b/n/asserv/utils/graph/asserv_graph.cc
index a3760e6..de7e337 100644
--- a/n/asserv/utils/graph/asserv_graph.cc
+++ b/n/asserv/utils/graph/asserv_graph.cc
@@ -33,27 +33,35 @@
class AsservGraph : public Proto::Receiver
{
Proto proto_;
+ int argc_;
+ char **argv_;
int tkp, tki, tkd;
int akp, aki, akd;
int es, is;
+ int ta, aa;
int te, ti, ae, ai;
+ int tsc, asc;
+ int cl, cr;
int pl, pr;
int n;
public:
- AsservGraph (void)
- : proto_ (*this),
+ 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)
{
Config &config = Config::getInstance ();
tkp = config.get<int> ("asserv.tkp");
- tki = config.get<int> ("asserv.tkd");
- tkd = config.get<int> ("asserv.tki");
+ tki = config.get<int> ("asserv.tki");
+ tkd = config.get<int> ("asserv.tkd");
akp = config.get<int> ("asserv.akp");
- aki = config.get<int> ("asserv.akd");
- akd = config.get<int> ("asserv.aki");
+ aki = config.get<int> ("asserv.aki");
+ akd = config.get<int> ("asserv.akd");
es = config.get<int> ("asserv.esat");
is = config.get<int> ("asserv.isat");
+ ta = config.get<int> ("asserv.ta");
+ aa = config.get<int> ("asserv.aa");
proto_.open (config.get<std::string> ("asserv.tty"));
init ();
}
@@ -69,7 +77,10 @@ class AsservGraph : public Proto::Receiver
proto_.send ('p', "bww", 'd', tkd, akd);
proto_.send ('p', "bw", 'E', es);
proto_.send ('p', "bw", 'I', is);
+ proto_.send ('p', "bww", 'a', ta, aa);
proto_.send ('P', "b", 1);
+ proto_.send ('S', "b", 1);
+ proto_.send ('C', "b", 1);
proto_.send ('W', "b", 1);
}
void receive (char command, const Proto::Frame &frame)
@@ -79,55 +90,93 @@ class AsservGraph : public Proto::Receiver
case 'P':
proto_.decode (frame, "WWWW", te, ti, ae, ai);
break;
+ case 'S':
+ proto_.decode (frame, "BB", tsc, asc);
+ break;
+ case 'C':
+ proto_.decode (frame, "WW", cl, cr);
+ break;
case 'W':
if (proto_.decode (frame, "WW", pl, pr))
{
std::cout << te << ' ' << ti << ' ' << ae << ' ' << ai << ' '
- << pl << ' ' << pr << std::endl;
+ << pl << ' ' << pr << ' ' << tsc << ' ' << asc << ' '
+ << cl << ' ' << cr << std::endl;
te = ti = ae = ai = 0;
+ tsc = asc = 0;
+ cl = cr = 0;
n++;
}
break;
}
}
- void main (void)
+ void syntax (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');
+ std::cout << "asserv_graph - graphe des variables de"
+ " l'asservissement.\n"
+ "Syntaxe : asserv_graph [commands]\n"
+ " w teste la pwm\n"
+ " c teste le pas\n"
+ " s teste la vitesse\n"
+ " p teste la position à vitesse controlée\n"
+ << std::endl;
+ }
+ int main (void)
+ {
+ if (argc_ == 1)
+ {
+ syntax ();
+ return 1;
+ }
+ for (int i = 1; i < argc_; ++i)
+ {
+ if (argv_[i][0] == '\0' || argv_[i][1] != '\0')
+ throw std::runtime_error ("bad command line");
+ switch (argv_[i][0])
+ {
+ case 'w':
+ proto_.send ('w', "ww", 0x3ff, 0x3ff);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ break;
+ case 'c':
+ proto_.send ('c', "ww", 64, 0);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ break;
+ case 's':
+ proto_.send ('s', "bb", 64, 0);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ proto_.send ('s');
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ break;
+ case 'p':
+ proto_.send ('s', "wwbb", 1024, 0, 64, 0);
+ for (n = 0; n < 100;)
+ proto_.wait (-1);
+ break;
+ default:
+ throw std::runtime_error ("bad command line");
+ break;
+ }
+ proto_.send ('w');
+ for (n = 0; n < 10;)
+ proto_.wait (-1);
+ }
+ return 0;
}
};
-/// 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 ();
+ AsservGraph asservGraph (argc, argv);
+ return asservGraph.main ();
}
catch (const std::exception &e)
{