-
Notifications
You must be signed in to change notification settings - Fork 0
Step by step Execution Guide with SLUGS and SLUGS Monitor
This example provides a standalone execution of SLUGS with a GUI for you to visualize the current inputs and outputs during execution.
- Go into the directory of the package slugs_ros:
~/LTL_stack/slugs_ros/src/slugs_ros
- Run the Executor with
python executor_standalone.py --ltl_filename ~/LTL_stack/controller_executor/examples/tutorial/tutorial.slugsin --option interactiveStrategy --wait_for_init_env 0
Replace the directory to the tutorial.slugsin with yours.
3. Open a new terminal and 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 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
- Open a new terminal and run
python output_listener_example.py
. We are now waiting for outputs from the executor here. - 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
MESSAGE1 = str({'person':0, 'sense_object':0}) # DICT MSG
MESSAGE2 = str({'person':0, 'sense_object':1}) # DICT MSG
print "message1:", MESSAGE1
print "message2:", MESSAGE2
count = 0
while count < 100:
count +=1
print count
sock.sendto(MESSAGE1, (UDP_IP, UDP_PORT))
sock.sendto(MESSAGE2, (UDP_IP, UDP_PORT))
-
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. -
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.