Skip to content

Commit

Permalink
Merge pull request #40 from robocup-logistics/mgomaa/auto-confirm-del…
Browse files Browse the repository at this point in the history
…ivery

auto confirm delivery
  • Loading branch information
morxa authored Jul 10, 2019
2 parents 9134eac + c863b21 commit 77c65b6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
5 changes: 5 additions & 0 deletions cfg/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ llsfrb:
fail-safe: true
broadcast: false

#A requested delivery in the real world needs to be confirmed 'manually' by
# the referee before scoring. In simulation this might be tedious and
# unnecessary. 'Automatic' confirmation grants all delivery requests.
auto-confirm-delivery: true

simulation:
enable: false
# synchronize refbox time with the time of a simulation
Expand Down
31 changes: 23 additions & 8 deletions src/games/rcll/orders.clp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,22 @@
(retract ?pf)
)

(defrule order-delivery-confirmation-no-operation
(defrule order-referee-confirmation-automatic
"Automatically grant referee confirmation after DS idles,
if auto-confirm enabled"
(gamestate (phase PRODUCTION|POST_GAME))
(confval (path "/llsfrb/auto-confirm-delivery")
(type BOOL) (value true))
?rf <- (referee-confirmation (process-id ?p-id) (state REQUIRED))
(product-processed (id ?p-id) (at-machine ?mname) (mtype DS) (order ?o-id))
(machine (name ?mname) (state IDLE))
(order (id ?o-id) (active TRUE))
=>
(printout warn "Automatic confirmation of delivery" crlf)
(modify ?rf (state CONFIRMED))
)

(defrule order-delivery-confirmation-invalid-operation
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state ~REQUIRED))
(not (product-processed (id ?id)))
Expand All @@ -104,7 +119,7 @@
"no active order with ID " ?order crlf))))
)

(defrule order-delivery-confirmation-operation-denied
(defrule order-delivery-confirmation-referee-denied
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state DENIED))
?pf <- (product-processed (id ?id) (team ?team) (order ?order) (confirmed FALSE))
Expand All @@ -114,15 +129,15 @@
(printout t "Denied delivery for order " ?order " by team " ?team crlf)
)

(defrule order-delivery-confirmation-operation-confirmed-print
(defrule order-delivery-confirmation-referee-confirmed-print
?rf <- (referee-confirmation (process-id ?id) (state CONFIRMED))
?pf <- (product-processed (id ?id) (team ?team) (order ?order) (confirmed FALSE))
(order (id ?order))
=>
(printout t "Confirmed delivery for order " ?order " by team " ?team crlf)
)

(defrule order-delivery-confirmation-operation-confirmed-simulate-tracking
(defrule order-delivery-confirmation-referee-confirmed-simulate-tracking
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state CONFIRMED))
?pf <- (product-processed (id ?id) (team ?team) (order ?order) (confirmed FALSE)
Expand All @@ -136,7 +151,7 @@
(retract ?rf)
)

(defrule order-delivery-confirmation-operation-confirmed-DS-read-fail-recovery
(defrule order-delivery-confirmation-referee-confirmed-DS-read-fail-recovery
"Recover from reading failure at DS, iff there is a unique, fitting, caped unconfirmed, workpiece"
(declare (salience ?*PRIORITY_HIGH*))
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
Expand Down Expand Up @@ -166,7 +181,7 @@
(modify ?pf (workpiece ?wp-id))
)

(defrule order-delivery-confirmation-operation-confirmed-DS-read-fail-safe
(defrule order-delivery-confirmation-referee-confirmed-DS-read-fail-safe
"Disable tracking if fai-safe is on and couldn't recover"
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state CONFIRMED))
Expand All @@ -180,7 +195,7 @@
)


(defrule order-delivery-confirmation-operation-confirmed-workpiece-rectify
(defrule order-delivery-confirmation-referee-confirmed-workpiece-rectify
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state CONFIRMED))
?pf <- (product-processed (id ?id) (team ?team) (order ?order) (confirmed FALSE)
Expand Down Expand Up @@ -284,7 +299,7 @@
(modify ?wf (order ?order) (base-color ?order-base) (cap-color ?order-cap) (ring-colors ?order-rings))
)

(defrule order-delivery-confirmation-operation-confirmed-workpiece-verified
(defrule order-delivery-confirmation-referee-confirmed-workpiece-verified
?gf <- (gamestate (phase PRODUCTION|POST_GAME))
?rf <- (referee-confirmation (process-id ?id) (state CONFIRMED))
?pf <- (product-processed (id ?id) (team ?team) (order ?order) (confirmed FALSE)
Expand Down

0 comments on commit 77c65b6

Please sign in to comment.