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
  1. Open a new terminal and run the Monitor with python proposition_monitor_standalone.py
  2. The Executor is now waiting for incoming inputs. Create and save the following script as output_listener_example.py
import socket

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

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

# retrieve msgs
while True:
    data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
    print "received message:", data
  1. Open a new terminal and run python output_listener_example.py. We are now waiting for outputs from the executor here.
  2. Create and save the following script as input_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

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
print "message:", MESSAGE

count = 0
while count < 100:
    count +=1
    print count
    sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))
  1. Now open another terminal run input_broadcaster_example.py with python input_broadcaster_example.py. We are sending input valuations to the Executor. You should see input and output valuations on the Monitor GUI, and output dictionaries from the terminal of input_broadcaster_example.py.

  2. With the current setup, the Executor expects inputs from port 5010 and broadcasts outputs to port 5005. You can add more connections by editing the executor_standalone.py file.