Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions ros/src/fastpeople/launch/software_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Script to run all launch files and send takeoff command for software demo.

import subprocess
import signal
import sys
import time

# Process handles.
robot_launch = None
human_launch = None
takeoff = None

# Custom signal handler for clean shutdown.
def sigint_handler(sig, frame):
print "Cleaning up."

# Register global variables in this scope.
global robot_launch
global human_launch

# Send termination signals and wait for success.
if robot_launch is not None and robot_launch.poll() is None:
robot_launch.terminate()

if human_launch is not None and human_launch.poll() is None:
human_launch.terminate()

if takeoff is not None and takeoff.poll() is None:
takeoff.terminate()

if robot_launch is not None:
robot_launch.wait()

if human_launch is not None:
human_launch.wait()

if takeoff is not None:
takeoff.wait()

# Exit successfully.
sys.exit(0)


# Register custom signal handler on SIGINT.
signal.signal(signal.SIGINT, sigint_handler)

# Set up processes and let it go.
# (1) Launch the crazyflies.
robot_launch = subprocess.Popen(["roslaunch", "fastpeople", "software_demo.launch"])

# (2) Wait a fixed amount of time (s) before calling takeoff.
TIME_BEFORE_TAKEOFF = 3.0
time.sleep(TIME_BEFORE_TAKEOFF)

# (3) Send takeoff signal.
takeoff = subprocess.Popen(["rosservice", "call", "takeoffHY4"])

# (4) Wait a fixed amount of time for takeoff to initiate before starting
# human motion predictor.
TIME_BEFORE_HUMAN = 3.0
time.sleep(TIME_BEFORE_HUMAN)

# (5) Initiate human predictor.
human_launch = subprocess.Popen(["roslaunch", "crazyflie_human", "simulated_demo.launch"])

signal.pause()