@@ -21,7 +21,7 @@ def __init__(self):
21
21
self .echo = True
22
22
self .verbose = True
23
23
24
- def return_config (self , return_value ):
24
+ def return_config (self , return_value ): # TODO: which functions return json()
25
25
"""Configure echo and verbosity of function returns."""
26
26
27
27
if self .echo is True and self .verbose is True :
@@ -369,6 +369,104 @@ def off(self, id):
369
369
self .control_peripheral (id , 0 )
370
370
# return ...
371
371
372
+ ## RESOURCES
373
+
374
+ # TODO: sort(points, method) --> API? --> order group of points according to chosen method
375
+
376
+ # def sort(tray, tray_cell):
377
+ # cell = tray_cell.upper()
378
+ # seeder_needle_offset = 17.5
379
+ # cell_spacing = 12.5
380
+
381
+ # cells = {
382
+ # "A1": {"label": "A1", "x": 0, "y": 0},
383
+ # "A2": {"label": "A2", "x": 0, "y": 1},
384
+ # "A3": {"label": "A3", "x": 0, "y": 2},
385
+ # "A4": {"label": "A4", "x": 0, "y": 3},
386
+ # "B1": {"label": "B1", "x": -1, "y": 0},
387
+ # "B2": {"label": "B2", "x": -1, "y": 1},
388
+ # "B3": {"label": "B3", "x": -1, "y": 2},
389
+ # "B4": {"label": "B4", "x": -1, "y": 3},
390
+ # "C1": {"label": "C1", "x": -2, "y": 0},
391
+ # "C2": {"label": "C2", "x": -2, "y": 1},
392
+ # "C3": {"label": "C3", "x": -2, "y": 2},
393
+ # "C4": {"label": "C4", "x": -2, "y": 3},
394
+ # "D1": {"label": "D1", "x": -3, "y": 0},
395
+ # "D2": {"label": "D2", "x": -3, "y": 1},
396
+ # "D3": {"label": "D3", "x": -3, "y": 2},
397
+ # "D4": {"label": "D4", "x": -3, "y": 3}
398
+ # }
399
+
400
+ # # Checks
401
+ # if tray["pointer_type"] != "ToolSlot":
402
+ # print("Error: Seed Tray variable must be a seed tray in a slot")
403
+ # return
404
+ # elif cell not in cells:
405
+ # print("Error: Seed Tray Cell must be one of **A1** through **D4**")
406
+ # return
407
+
408
+ # # Flip X offsets depending on pullout direction
409
+ # flip = 1
410
+ # if tray["pullout_direction"] == 1:
411
+ # flip = 1
412
+ # elif tray["pullout_direction"] == 2:
413
+ # flip = -1
414
+ # else:
415
+ # print("Error: Seed Tray **SLOT DIRECTION** must be `Positive X` or `Negative X`")
416
+ # return
417
+
418
+ # # A1 coordinates
419
+ # A1 = {
420
+ # "x": tray["x"] - seeder_needle_offset + (1.5 * cell_spacing * flip),
421
+ # "y": tray["y"] - (1.5 * cell_spacing * flip),
422
+ # "z": tray["z"]
423
+ # }
424
+
425
+ # # Cell offset from A1
426
+ # offset = {
427
+ # "x": cell_spacing * cells[cell]["x"] * flip,
428
+ # "y": cell_spacing * cells[cell]["y"] * flip
429
+ # }
430
+
431
+ # # Return cell coordinates
432
+ # return {
433
+ # "x": A1["x"] + offset["x"],
434
+ # "y": A1["y"] + offset["y"],
435
+ # "z": A1["z"]
436
+ # }
437
+
438
+ def soil_height (self ):
439
+ """Execute script to check soil height via message broker."""
440
+
441
+ soil_height_message = {
442
+ ** RPC_REQUEST ,
443
+ "body" : {
444
+ "kind" : "execute_script" ,
445
+ "args" : {
446
+ "label" : "Measure Soil Height"
447
+ }
448
+ }
449
+ }
450
+
451
+ self .broker_connect .publish (soil_height_message )
452
+ # return ...
453
+
454
+ def detect_weeds (self ):
455
+ """Execute script to detect weeds via message broker."""
456
+
457
+ detect_weeds_message = {
458
+ ** RPC_REQUEST ,
459
+ "body" : {
460
+ "kind" : "execute_script" ,
461
+ "args" : {
462
+ "label" : "plant-detection"
463
+ }
464
+ }
465
+ }
466
+
467
+ self .broker_connect .publish (detect_weeds_message )
468
+ # return ...
469
+
372
470
## OTHER FUNCTIONS
373
471
374
472
def calibrate_camera (self ): # TODO: fix "sequence_id"
@@ -438,38 +536,6 @@ def take_photo(self):
438
536
self .broker_connect .publish (take_photo_message )
439
537
# return ...
440
538
441
- def soil_height (self ):
442
- """Execute script to check soil height via message broker."""
443
-
444
- soil_height_message = {
445
- ** RPC_REQUEST ,
446
- "body" : {
447
- "kind" : "execute_script" ,
448
- "args" : {
449
- "label" : "Measure Soil Height"
450
- }
451
- }
452
- }
453
-
454
- self .broker_connect .publish (soil_height_message )
455
- # return ...
456
-
457
- def detect_weeds (self ):
458
- """Execute script to detect weeds via message broker."""
459
-
460
- detect_weeds_message = {
461
- ** RPC_REQUEST ,
462
- "body" : {
463
- "kind" : "execute_script" ,
464
- "args" : {
465
- "label" : "plant-detection"
466
- }
467
- }
468
- }
469
-
470
- self .broker_connect .publish (detect_weeds_message )
471
- # return ...
472
-
473
539
def mark_coord (self , x , y , z , property , mark_as ): # TODO: Fix "label"
474
540
mark_coord_message = {
475
541
** RPC_REQUEST ,
@@ -527,9 +593,8 @@ def mark_coord(self, x, y, z, property, mark_as): # TODO: Fix "label"
527
593
# TODO: water() --> all or single coords
528
594
# TODO: dispense() --> single coords?
529
595
530
- # TODO: sequence()
531
- # TODO: get_seed_tray_call(tray, cell)
532
- # TODO: sort(points, method) --> API?
596
+ # TODO: sequence() --> execute a sequence by ID
597
+ # TODO: get_seed_tray_call(tray, cell) --> get coordinates of cell in seed tray by passing tool object and cell id, eg B3
533
598
534
599
# TODO: get_job() --> access status tree --> fetch all or single by name
535
600
# TODO: set_job() --> access status tree --> inject(?) new or edit single by name
0 commit comments