continuous-analytics-examples icon indicating copy to clipboard operation
continuous-analytics-examples copied to clipboard

sviluppare bene il caso dei bracci robotici

Open emanueledellavalle opened this issue 4 years ago • 0 comments

Caso

Suppose you want to monitor with a stream processing engine a group of robots used for picking and placing goods in an Industry 4.0 storehouse. Each robotic arm sends events reporting its status: ready to pick the good, good grasped, moving the good, placing the good, moving without any good. Several Force-Sensing Resistors measure the stress levels of the robotic arm. If the stress level is between 0 and 6, the robot is safely operating. If it is between 7 and 8, a controller should raise a warning. If it is above 9, a controller should stop the robot. In EPL propose:

  • E1 How to model the streaming data generated by the robotic arms
  • E2 A continuous query that emits the max stress for each arm.
  • E3 A continuous query that emits the average stress level between a pick and a place.
  • E4 A continuous query that returns the robotic arms that, in less than 10 second,
    • picked a good while safely operating,
    • moved it while the controller was raising a warning, and
    • placed it while safely operating again.
  • E5 A continuous query that monitors the results of the previous one and counts how many times each robotic arm is present in the stream over a tumbling window of 1 min.

E1

proposte

Valerio:

create schema Arm1 ( status string, stress_level int ); 
create schema Arm2 ( status string, stress_level int ); 
create schema Arm3 ( status string, stress_level int );

Pietro:

create schema RobotArm ( id int, status string, stess int ); 
create schema StressWarning ( armId int, ); 
create schema StopArmEvent( armId int );

Laura:

create schema RoboticSensorArm( roboticArmId string, status string, stressLevel int );

Andrea: un evento per ogni stato con un riferimento al braccio che lo ha creato mettendo lo stress_level solo negli stati in cui è utile

Ivan:

create schema RoboticArm(id int, status string); 
create schema ForceSensingResistors(idArm string, stressLvl int)

NOTA: ci sono due forze:

  • la realtà: se il mondo è fatto come l'ha modellato Ivan (il braccio non sa dei sensori e i sensori sanno solo di essere sul braccio) non possiamo che rappresentarlo in quel modo
  • l'uso che devo fare degli eventi: non voglio dover mettere insieme eventi durante le query se chi li emette può emetterne solo uno (vedi soluzione di Laura e Pietro)

per ragioni di efficienza anche il modeling di Valerio è appropriato perchè ha tenuto separati i bracci, mentre nelle altre soluzioni serve separarli usando l'ID

per le stesse ragioni la proposta di Andrea potrebbe essere molto buona se servisse fare analisi across braccio raggruppando per stato

direi di continuare usando:

create schema RoboticArm( id string, status string, stressLevel int );

I dati:

RoboticArm={id="1", status="ready", stressLevel=0} 
t=t.plus(1 seconds) 
RoboticArm={id="1", status="goodGrasped", stressLevel=1} 
t=t.plus(1 seconds) 
RoboticArm={id="1", status="movingGood", stressLevel=5} 
RoboticArm={id="2", status="ready", stressLevel=0} 
t=t.plus(1 seconds) 
RoboticArm={id="2", status="goodGrasped", stressLevel=5} 
t=t.plus(1 seconds) 
RoboticArm={id="2", status="movingGood", stressLevel=9} 
t=t.plus(5 seconds) 
RoboticArm={id="2", status="placingGood", stressLevel=3} 
RoboticArm={id="1", status="placingGood", stressLevel=3} 
t=t.plus(4 seconds) 
RoboticArm={id="1", status="moving", stressLevel=2} 
RoboticArm={id="2", status="moving", stressLevel=1} 
t=t.plus(3 seconds) 
RoboticArm={id="1", status="ready", stressLevel=0} 
RoboticArm={id="2", status="ready", stressLevel=0} 
t=t.plus(1 seconds)

le query E2, E3, E4, e E5

@Name("E2") 
SELECT id, max(stressLevel) 
FROM RoboticArm 
GROUP BY id
@Name("E3") 
SELECT a.id, (a.stressLevel + b.stressLevel + c.stressLevel) / 3
FROM pattern [ 
every a=RoboticArm(status="goodGrasped") -> 
b=RoboticArm(id = a.id, status="movingGood") -> c=RoboticArm(id = a.id, status="placingGood")  ];

@Name("E4") 
select a.id
from pattern [
(every (a=RoboticArm(status="goodGrasped")) -> 
every (b=RoboticArm(id=a.id, status="movingGood")) -> 
every (c=RoboticArm(id=a.id, status="placingGood"))) where timer:within(10 sec)
]
where  a.stressLevel <= 6 and  b.stressLevel > 6 and b.stressLevel <9 and c.stressLevel <= 6;

emanueledellavalle avatar Mar 05 '21 16:03 emanueledellavalle