summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/asserv/test_asserv.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/asserv/test_asserv.cc')
-rw-r--r--2005/i/robert/src/asserv/test_asserv.cc80
1 files changed, 54 insertions, 26 deletions
diff --git a/2005/i/robert/src/asserv/test_asserv.cc b/2005/i/robert/src/asserv/test_asserv.cc
index 54e5716..302be6a 100644
--- a/2005/i/robert/src/asserv/test_asserv.cc
+++ b/2005/i/robert/src/asserv/test_asserv.cc
@@ -39,47 +39,60 @@ class TestAsserv : public Asserv::Receiver
{
std::cout << "C:" << "lMotor:" << lMotor << " rMotor:" << rMotor << std::endl;
}
+
void receivePosX (double xPos)
{
std::cout << "X:" << "XPos:" << xPos << std::endl;
}
+
void receivePosY (double yPos)
{
std::cout << "Y:" << "yPos:" << yPos << std::endl;
}
+
void receivePosA (double aPos)
{
std::cout << "A:" << "aPos:" << aPos << std::endl;
}
- void receiveMotor (int oldLSpeed_e, int LSpeed_int, int oldRSpeed_e, int RSpeed_int)
+
+ void receiveSpeedStat (int leftError, int leftInt, int rightError, int rightInt)
{
- std::cout << "S:" << "oldLSpeed_e:" << oldLSpeed_e << "LSpeed_int:" <<
- LSpeed_int << "oldRSpeed_e:" << oldRSpeed_e <<
- "RSpeed_int:" << RSpeed_int << std::endl;
+ std::cout << "S:" << "leftError:" << leftError << "leftInt:" <<
+ leftInt << "rightError:" << rightError <<
+ "rightInt:" << rightInt << std::endl;
}
+
void receivePwm (double leftPwm, double rightPwm)
{
std::cout << "W:" << "leftPwm" << leftPwm << " rightPwm:" << rightPwm << std::endl;
}
- void receiveTiming (double motorTimer5, double motorTimer4,
- double motorTimer3, double motorTimer2,
- double motorTimer1,
- double motorTimer0 )
+
+ void receiveTiming (int motorTimer4, int motorTimer3,
+ int motorTimer2, int motorTimer1,
+ int motorTimer0 )
{
- std::cout << "T:" << "motorTimer5:" << motorTimer5 <<
- " motorTimer4:" << motorTimer4 << "motorTimer3:" <<
- motorTimer3 << "motorTimer2:" << motorTimer2 <<
- "motorTimer1:" << motorTimer1 << "motorTimer0:" <<
- motorTimer0 << std::endl;
+ std::cout << "T:" << " motorTimer4:" << motorTimer4 << "motorTimer3:"
+ << motorTimer3 << "motorTimer2:" << motorTimer2
+ << "motorTimer1:" << motorTimer1 << "motorTimer0:"
+ << motorTimer0 << std::endl;
}
- void receiveInPort (double state)
+
+ void receiveInPort (int port)
{
- std::cout << "P:" << "state:" << state << std::endl;
+ std::cout << "P:" << "state:" << port << std::endl;
}
- void jaifini (void)
+
+ void receiveSharp (int sharp0, int sharp1, int sharp2)
+ {
+ std::cout << "t:" << "sharp0:" << sharp0 << " sharp1:" << sharp1
+ << " sharp2:" << sharp2 << std::endl;
+ }
+
+ void done (void)
{
std::cout << "F:" << "J'ai fini!!" << std::endl;
}
+
};
/// Affiche un memo de suntaxe.
@@ -133,12 +146,14 @@ main (int argc, char **argv)
case 'g':
if(++i + 1 > argc)
throw std::runtime_error("syntax error");
- asserv.goToPosition(strtod(argv[i], 0), strtod(argv[++i], 0));
+ asserv.goToPosition(strtod(argv[i], 0),
+ strtod(argv[i + 1], 0));
+ i++;
break;
case 'f':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.fuckTheWall(strtod(argv[i], 0));
+ asserv.fuckTheWall(atoi(argv[i]));
break;
case 's':
if(++i + 1 > argc)
@@ -156,33 +171,40 @@ main (int argc, char **argv)
case 'C':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.statCounter(strtod(argv[i], 0));
+ asserv.statCounter(strtol(argv[i], 0, 10));
break;
case 'X':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.statPosition(strtod(argv[i], 0));
+ asserv.statPosition(strtol(argv[i], 0, 10));
break;
case 'S':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.statMotor(strtod(argv[i], 0));
+ asserv.statMotor(strtol(argv[i], 0, 10));
break;
case 'W':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.statPwm(strtod(argv[i], 0));
+ asserv.statPwm(strtol(argv[i], 0, 10));
break;
case 'T':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.statTiming(strtod(argv[i], 0));
+ asserv.statTiming(strtol(argv[i], 0, 10));
break;
case 'P':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.fuckTheWall(strtod(argv[i], 0));
+ asserv.fuckTheWall(atoi(argv[i]));
break;
+
+ case 'H':
+ if(++i > argc)
+ throw std::runtime_error("syntax error");
+ asserv.statSharp(atoi(argv[i]));
+ break;
+
case 'p':
if(++i > argc)
throw std::runtime_error("syntax error");
@@ -236,12 +258,18 @@ main (int argc, char **argv)
case 'A':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setAccel(strtod(argv[i], 0));
+ asserv.setAccel(strtol(argv[i], 0, 10));
break;
case 'm':
if(++i > argc)
throw std::runtime_error("syntax error");
- asserv.setMaxSpeed(strtod(argv[i], 0));
+ asserv.setMaxSpeed(strtol(argv[i], 0, 10));
+ break;
+ case 'W':
+ if (++i + 1 > argc)
+ throw std::runtime_error("syntax error");
+ asserv.setInvPwm(atoi(argv[i]), atoi(argv[i + 1]));
+ i++;
break;
}
}