summaryrefslogtreecommitdiff
path: root/i/chuck/src
diff options
context:
space:
mode:
Diffstat (limited to 'i/chuck/src')
-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
3 files changed, 36 insertions, 0 deletions
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");