summaryrefslogtreecommitdiff
path: root/i/chuck
diff options
context:
space:
mode:
authordufourj2007-05-17 09:56:56 +0000
committerdufourj2007-05-17 09:56:56 +0000
commitf172d87ec5c9a94b33d00fa72541b85542228b68 (patch)
tree0ceeba01adb7482952d36e6753715f25734cb044 /i/chuck
parent3d44c4f67ac3ff3ff3cb2cd0f91e71f750110897 (diff)
* Es:
- add support for managing frontal sharp; - add function for upper class.
Diffstat (limited to 'i/chuck')
-rw-r--r--i/chuck/runtime/rc/config4
-rw-r--r--i/chuck/src/es/es.cc18
-rw-r--r--i/chuck/src/es/es.hh12
-rw-r--r--i/chuck/src/es/test_es.cc6
4 files changed, 40 insertions, 0 deletions
diff --git a/i/chuck/runtime/rc/config b/i/chuck/runtime/rc/config
index d7eb03f..e0ec1b6 100644
--- a/i/chuck/runtime/rc/config
+++ b/i/chuck/runtime/rc/config
@@ -62,6 +62,10 @@ es.threshold_front_sensors = 4
es.threshold_ball_sensors = 4
# Threshold of hole sensor
es.threshold_hole_sensors = 4
+# Threshold sharp
+es.threshold_sharp = 0x90
+# Frequency sharp update
+es.freq_sharp = 0x10
### Artificial Intelligency !
# Time of match in milliseconds !
diff --git a/i/chuck/src/es/es.cc b/i/chuck/src/es/es.cc
index 237b7db..e1ea228 100644
--- a/i/chuck/src/es/es.cc
+++ b/i/chuck/src/es/es.cc
@@ -70,6 +70,8 @@ Es::loadConfig (const Config & config)
lcdKeyStat_ = config.get<int> ("es.lcd_key_stat");
thresholdFrontSensors_ = config.get<int> ("es.threshold_front_sensors");
thresholdHoleSensors_ = config.get<int> ("es.threshold_hole_sensors");
+ thresholdSharp_ = config.get<int> ("es.threshold_sharp");
+ freqSharp_ = config.get<int> ("es.freq_sharp");
}
void
@@ -83,6 +85,9 @@ Es::reset (void)
setAckStat (ackFreq_);
setOthersStat (othersStat_);
lcdGetKey (lcdKeyStat_);
+ // XXX Hardcoded value !
+ setSharpThreshold (1, thresholdSharp_, thresholdSharp_);
+ launchSharpDetection ();
log_ ("Es", Log::debug) << "Reset Es done.";
}
@@ -191,6 +196,11 @@ void Es::receive(char command, const Proto::Frame & frame)
log_ ("Ack", Log::debug) << "ErrCode :" << errCode;
switch (errCode)
{
+ // XXX Yerka hardcoded
+ case 1:
+ log_ ("Ack", Log::debug) << "Ack sharp has seen something";
+ ackSharp_ = true;
+ break;
}
shutUp ();
}
@@ -273,3 +283,11 @@ Es::roulo_tombe(void)
proto_.send('m',"bb",0x00,0x7b);
}
+
+/// Restart the detection of something front
+void
+Es::launchSharpDetection (void)
+{
+ setSharpUpdate (2, freqSharp_);
+}
+
diff --git a/i/chuck/src/es/es.hh b/i/chuck/src/es/es.hh
index 7acde3e..94470eb 100644
--- a/i/chuck/src/es/es.hh
+++ b/i/chuck/src/es/es.hh
@@ -65,6 +65,12 @@ class Es : public Proto::Receiver
int thresholdFrontSensors_, thresholdBallSensors_, thresholdHoleSensors_;
/// Si la turbine avant est allumé
bool frontTurbineIsFull_;
+ /// Threshold for Sharp
+ int thresholdSharp_;
+ /// Frequency of sharp update_
+ int freqSharp_;
+ /// Do we have seen something
+ bool ackSharp_;
public:
/// Constructeur
@@ -121,6 +127,12 @@ class Es : public Proto::Receiver
void roulo_roule(int vit);
//le roulo tombe
void roulo_tombe(void);
+
+
+ /// Get sharp ack
+ bool getSharpAck (void) const { return ackSharp_; }
+ /// Restart the detection of something front
+ void launchSharpDetection (void);
private:
/// Update system for one sensor
void updateAnalysisSensor (int value, int index, int threshold);
diff --git a/i/chuck/src/es/test_es.cc b/i/chuck/src/es/test_es.cc
index b96baa5..c6cbfb1 100644
--- a/i/chuck/src/es/test_es.cc
+++ b/i/chuck/src/es/test_es.cc
@@ -83,6 +83,12 @@ class TestEs : public Tester
interpreter.add
("lcdKey", Interpreter::memFunc (es_, &Es::lcdGetKey),
"Set stat for key if pressed (freq)");
+ /* Function for relaunching sharp updater */
+ interpreter.add
+ ("launchSharpDetection",
+ Interpreter::memFunc (es_, &Es::launchSharpDetection),
+ "Launch the detection of object in front by using sharp");
+
interpreter.add ("ascenseur", Interpreter::memFunc(es_,
&Es::bouge_ascenceur),"Set sens , vitesse , tps\n" "sens : 0 UP 1 DOWN\n" "vit and tps : en hex");