Skip to content

Step by step Execution Guide with SLUGS and SLUGS Monitor

Kai Weng (Catherine) Wong edited this page Apr 4, 2018 · 5 revisions

This example provides a standalone execution of SLUGS with a GUI for you to visualize the current inputs and outputs during execution.

  1. Go into the directory of the package slugs_ros: ~/LTL_stack/slugs_ros/src/slugs_ros
  2. Run the Executor with `python executor_standalone.py --ltl_filename ~/LTL_stack/controller_executor/examples/firefighting/firefighting.slugsin --option interactiveStrategy --wait_for_init_env 0'
  3. Run the Monitor with python proposition_monitor_standalone.py
  4. The executor is now waiting for incoming inputs. Create and save the following script as input_listener_example.py
import socket

# socket to communicate with executor
UDP_IP = "127.0.0.1"
UDP_PORT = 5005```python
import socket

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
ssock.bind((UDP_IP, UDP_PORT))

# retrieve msgs
while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    print "received message:", data
  1. Create and save the following script as output_broadcaster_example.py
import socket

# socket setup to communicate with executor standalone
UDP_IP = "127.0.0.1"
UDP_PORT = 5010
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE

sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP

# test broadbast with firefighting example
#MESSAGE = "'00'" # STR MSG
MESSAGE = str({'person':0, 'hazardous_item':0}) # DICT MSG

count = 0
while count < 100:
    count +=1
    print count
    sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
  1. The Executor expects inputs from port 5005 and broadcasts outputs to port 5010. Now run output_broadcaster_example.py with python output_broadcaster_example.py