Skip to content

Commit c12515c

Browse files
authored
Merge pull request #41 from robocup-logistics/thofmann/simple-storage-station
Implement a simple storage station that dispenses a single C0
2 parents 42e2e5a + 8a71056 commit c12515c

File tree

10 files changed

+59
-64
lines changed

10 files changed

+59
-64
lines changed

cfg/config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ llsfrb:
5757
port: !tcp-port 4840
5858
type: DS
5959
connection: mockup
60+
C-SS:
61+
active: true
62+
host: !ipv4 192.168.2.22
63+
port: !tcp-port 4840
64+
type: SS
65+
connection: mockup
6066
M-BS:
6167
active: true
6268
host: !ipv4 192.168.2.33
@@ -93,6 +99,12 @@ llsfrb:
9399
port: !tcp-port 4840
94100
type: DS
95101
connection: mockup
102+
M-SS:
103+
active: true
104+
host: !ipv4 192.168.2.35
105+
port: !tcp-port 4840
106+
type: SS
107+
connection: mockup
96108

97109
clips:
98110
# Timer interval, in milliseconds

src/games/rcll/facts.clp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
(slot ds-order (type INTEGER))
7777

7878
(slot ss-operation (type SYMBOL) (allowed-values STORE RETRIEVE))
79-
(multislot ss-slot (type INTEGER) (cardinality 3 3)) ; meaning defined in llsf_msgs.SSSlot
79+
;(multislot ss-slot (type INTEGER) (cardinality 3 3)) ; meaning defined in llsf_msgs.SSSlot
80+
(slot ss-holding (type SYMBOL) (allowed-values TRUE FALSE) (default TRUE))
8081

8182
(slot rs-ring-color (type SYMBOL)
8283
(allowed-values RING_BLUE RING_GREEN RING_ORANGE RING_YELLOW))

src/games/rcll/globals.clp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
; How long to wait before resetting a machine that is processing
5454
?*PROCESSING-WAIT-TILL-RESET* = 90
5555
?*PREPARE-WAIT-TILL-PROCESSING* = 5
56+
?*PROCESS-TIME-SS* = 5
5657

5758
; number of points for specific actions
5859
?*EXPLORATION-CORRECT-REPORT-ROTATION-POINTS* = 1
@@ -76,6 +77,7 @@
7677
?*PRODUCTION-DELIVER-MAX-LATENESS-TIME* = 10
7778
?*PRODUCTION-POINTS-COMPETITIVE-FIRST-BONUS* = 10
7879
?*PRODUCTION-POINTS-COMPETITIVE-SECOND-DEDUCTION* = 10
80+
?*PRODUCTION-POINTS-SS-RETRIEVAL* = -10
7981
; Workpiece ranges
8082
?*WORKPIECE-RANGE-RED* = (create$ 1001 1999)
8183
?*WORKPIECE-RANGE-BLACK* = (create$ 2001 2999)

src/games/rcll/net.clp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -523,17 +523,8 @@
523523
(pb-set-field ?m "instruction_ds" ?pm)
524524
)
525525
(case SS then
526-
(bind ?pssm (pb-create "llsf_msgs.SSSlot"))
527-
(pb-set-field ?pssm "x" (nth$ 1 (fact-slot-value ?mf ss-slot)))
528-
(pb-set-field ?pssm "y" (nth$ 2 (fact-slot-value ?mf ss-slot)))
529-
(pb-set-field ?pssm "z" (nth$ 3 (fact-slot-value ?mf ss-slot)))
530-
531-
(bind ?psm (pb-create "llsf_msgs.SSTask"))
532-
(pb-set-field ?psm "operation" (fact-slot-value ?mf ss-operation))
533-
(pb-set-field ?psm "shelf" ?pssm)
534-
535526
(bind ?pm (pb-create "llsf_msgs.PrepareInstructionSS"))
536-
(pb-set-field ?pm "task" ?psm)
527+
(pb-set-field ?pm "operation" (fact-slot-value ?mf ss-operation))
537528
(pb-set-field ?m "instruction_ss" ?pm)
538529
)
539530
(case RS then

src/games/rcll/production.clp

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -109,36 +109,24 @@
109109
(if (pb-has-field ?p "instruction_ss")
110110
then
111111
(bind ?prepmsg (pb-field-value ?p "instruction_ss"))
112-
(bind ?task (pb-field-value ?prepmsg "task"))
113-
(bind ?operation (sym-cat (pb-field-value ?task "operation")))
114-
(bind ?slot (pb-field-value ?task "shelf"))
115-
(bind ?slot-x (pb-field-value ?slot "x"))
116-
(bind ?slot-y (pb-field-value ?slot "y"))
117-
(bind ?slot-z (pb-field-value ?slot "z"))
118-
112+
(bind ?operation (sym-cat (pb-field-value ?prepmsg "operation")))
119113
(if (eq ?operation RETRIEVE)
120114
then
121-
; check if slot is filled
122-
(if (any-factp ((?ss-slot machine-ss-filled)) (and (eq ?ss-slot:name ?mname)
123-
(and (eq (nth$ 1 ?ss-slot:slot) ?slot-x)
124-
(and (eq (nth$ 2 ?ss-slot:slot) ?slot-y)
125-
(eq (nth$ 3 ?ss-slot:slot) ?slot-z)
126-
)
127-
)
128-
)
129-
)
115+
(if ?m:ss-holding
130116
then
131-
(printout t "Prepared " ?mname " (RETRIVE: (" ?slot-x ", " ?slot-y ", " ?slot-z ") )" crlf)
132-
(modify ?m (state PREPARED) (ss-operation ?operation) (ss-slot ?slot-x ?slot-y ?slot-z) (wait-for-product-since ?gt))
117+
(printout t "Prepared " ?mname crlf)
118+
(modify ?m (state PREPARED) (ss-operation ?operation) (wait-for-product-since ?gt))
133119
else
134-
(modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with RETRIVE (" ?slot-x ", " ?slot-y ", " ?slot-z ") but this is empty")))
120+
(modify ?m (state BROKEN)
121+
(broken-reason
122+
(str-cat "Prepare received for " ?mname ", but station is empty")))
135123
)
136124
else
137125
(if (eq ?operation STORE)
138126
then
139-
(modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with STORE-operation")))
127+
(modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with STORE operation")))
140128
else
141-
(modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with unknown operation")))
129+
(modify ?m (state BROKEN) (broken-reason (str-cat "Prepare received for " ?mname " with unknown operation " ?operation)))
142130
)
143131
)
144132
else
@@ -450,10 +438,10 @@
450438
(mps-move-conveyor (str-cat ?n) "OUTPUT" "FORWARD")
451439
)
452440

453-
(defrule production-bs-cs-rs-ready-at-output
441+
(defrule production-bs-cs-rs-ss-ready-at-output
454442
"Workpiece is in output, switch to READY-AT-OUTPUT"
455443
(gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt))
456-
?m <- (machine (name ?n) (mtype BS|CS|RS) (state PROCESSED) (task MOVE-OUT)
444+
?m <- (machine (name ?n) (mtype BS|CS|RS|SS) (state PROCESSED) (task MOVE-OUT)
457445
(mps-busy FALSE) (mps-ready TRUE))
458446
=>
459447
(modify ?m (state READY-AT-OUTPUT) (task nil))
@@ -504,6 +492,28 @@
504492
(modify ?m (state WAIT-IDLE) (idle-since ?gt))
505493
)
506494

495+
(defrule production-ss-start-retrieval
496+
"SS is prepared, move the workpiece to the output."
497+
(gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt))
498+
?m <- (machine (name ?n) (mtype SS) (state PREPARED)
499+
(ss-operation RETRIEVE) (task nil))
500+
=>
501+
(modify ?m (state PROCESSING) (proc-start ?gt))
502+
)
503+
504+
(defrule production-ss-processed-retrieval
505+
"The conveyor started moving, go to processed."
506+
(gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt))
507+
?m <- (machine (name ?n) (mtype SS) (team ?team) (state PROCESSING) (ss-operation RETRIEVE)
508+
(proc-start ?t&:(timeout-sec ?gt ?t ?*PROCESS-TIME-SS*)))
509+
=>
510+
(assert (points (game-time ?gt) (team ?team) (phase PRODUCTION)
511+
(points ?*PRODUCTION-POINTS-SS-RETRIEVAL*)
512+
(reason (str-cat "Retrieved product from " ?n))))
513+
(mps-move-conveyor (str-cat ?n) "OUTPUT" "FORWARD")
514+
(modify ?m (state PROCESSED) (task MOVE-OUT) (mps-busy WAIT) (ss-holding FALSE))
515+
)
516+
507517
(defrule production-mps-idle
508518
"The machine has been in WAIT-IDLE for the specified time, switch to IDLE."
509519
(gamestate (state RUNNING) (phase PRODUCTION) (game-time ?gt))

src/libs/mps_comm/storage_station.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ StorageStation::StorageStation(std::string name,
2121

2222
StorageStation::~StorageStation() {}
2323

24-
void StorageStation::get_product(int slot) {
25-
//lock_guard<mutex> g(lock_);
26-
send_command(machine_type_ + Operation::OPERATION_GET_F_PRODUCT, slot);
27-
}
28-
2924
void StorageStation::identify() {
3025
send_command(Command::COMMAND_SET_TYPE, StationType::STATION_TYPE_SS);
3126
}

src/libs/mps_comm/storage_station.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ class StorageStation: public Machine {
1919
StorageStation(std::string name, std::string ip, unsigned short port, ConnectionMode mode);
2020
virtual ~StorageStation();
2121

22-
// Send command to deliver a product
23-
// slot is between 1 and 3
24-
// deprecated
25-
void get_product(int slot);
26-
2722
// identify: tell the PLC, which machine it is controlling
2823
virtual void identify();
2924
};

src/msgs/MachineInstructions.proto

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ enum MachineSide {
5050
OUTPUT = 2;
5151
}
5252

53-
message SSTask {
54-
required SSOp operation = 2;
55-
required SSSlot shelf = 3;
56-
}
57-
5853
message PrepareInstructionBS {
5954
required MachineSide side = 1;
6055
required BaseColor color = 2;
@@ -67,7 +62,7 @@ message PrepareInstructionDS {
6762
}
6863

6964
message PrepareInstructionSS {
70-
required SSTask task = 1;
65+
required SSOp operation = 1;
7166
}
7267

7368
message PrepareInstructionRS {

src/refbox/refbox.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ LLSFRefBox::LLSFRefBox(int argc, char **argv)
234234
logger_->log_info("RefBox", "Adding DS %s:%u", mpsip.c_str(), port);
235235
mps = new DeliveryStation(cfg_name, mpsip, port, connection_mode);
236236
}
237+
else if (mpstype == "SS") {
238+
logger_->log_info("RefBox", "Adding SS %s:%u", mpsip.c_str(), port);
239+
mps = new StorageStation(cfg_name, mpsip, port, connection_mode);
240+
}
237241
else {
238242
throw fawkes::Exception("this type wont match");
239243
}

src/tools/rcll-prepare-machine.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,7 @@ handle_message(boost::asio::ip::udp::endpoint &sender,
173173
prep_ds->set_order_id(ds_order_id_);
174174
} else if (machine_type_ == "SS") {
175175
llsf_msgs::PrepareInstructionSS *prep_ss = prep.mutable_instruction_ss();
176-
177-
llsf_msgs::SSTask *ss_task = prep_ss->mutable_task();
178-
ss_task->set_operation( ss_op_ );
179-
180-
llsf_msgs::SSSlot *ss_slot = ss_task->mutable_shelf();
181-
ss_slot->set_x(ss_slot_x_);
182-
ss_slot->set_y(ss_slot_y_);
183-
ss_slot->set_z(ss_slot_z_);
176+
prep_ss->set_operation(ss_op_);
184177
} else if (machine_type_ == "RS") {
185178
llsf_msgs::PrepareInstructionRS *prep_rs = prep.mutable_instruction_rs();
186179
prep_rs->set_ring_color(rs_ring_color_);
@@ -201,7 +194,7 @@ usage(const char *progname)
201194
"instructions are specific for the machine type:\n"
202195
"BS: (INPUT|OUTPUT) (BASE_RED|BASE_BLACK|BASE_SILVER)\n"
203196
"DS: <order_id>\n"
204-
"SS: (RETRIEVE|STORE) <slot-x> <slot-y> <slot-z>\n"
197+
"SS: (RETRIEVE|STORE)\n"
205198
"RS: (RING_BLUE|RING_GREEN|RING_ORANGE|RING_YELLOW)\n"
206199
"CS: (RETRIEVE_CAP|MOUNT_CAP)\n",
207200
progname);
@@ -242,17 +235,14 @@ main(int argc, char **argv)
242235
}
243236
ds_order_id_ = argp.parse_item_int(2);
244237
} else if (machine_type_ == "SS") {
245-
if (argp.num_items() < 6) {
246-
printf("SS machine requires operation and x, y, z arguments %zu\n", argp.num_items());
238+
if (argp.num_items() != 3) {
239+
printf("Wrong number of arguments. Expected 3, got %zu\n", argp.num_items());
247240
usage(argv[0]);
248241
exit(-1);
249242
}
250243
if (! llsf_msgs::SSOp_Parse(argp.items()[2], &ss_op_)) {
251244
printf("Invalid operation\n"); exit(-2);
252245
}
253-
ss_slot_x_ = argp.parse_item_int(3);
254-
ss_slot_y_ = argp.parse_item_int(4);
255-
ss_slot_z_ = argp.parse_item_int(5);
256246
} else if (machine_type_ == "RS") {
257247
if (! llsf_msgs::RingColor_Parse(argp.items()[2], &rs_ring_color_)) {
258248
printf("Invalid ring color\n"); exit(-2);

0 commit comments

Comments
 (0)