示例#1
0
# Path follower using a simple bicycle model
# Multiple vehicles are used. The vehicles
# that aren't tracked are considered "opponents"
# Meant to demonstrate the WA Simulator API
# -----------------------------------------

# Import the simulator
import wa_simulator as wa

# Import the controller
from pid_controller import PIDController

# Command line arguments
parser = wa.WAArgumentParser(use_sim_defaults=True)
parser.add_argument(
    "-n",
    "--num_opponents",
    type=int,
    help=
    "Number of opponents to simulation. The more, the less efficient the simulation.",
    default=2)
args = parser.parse_args()


def main():
    # ---------------
    # Create a system
    # System's handle the simulation settings
    system = wa.WASystem(args=args)

    # ---------------------------
# Simple path demo
# Meant to demonstrate the WA Simulator API
# -----------------------------------------------------------------

# Import the simulator
import wa_simulator as wa
import matplotlib.pyplot as plt

# Command line arguments
parser = wa.WAArgumentParser(use_sim_defaults=False)
parser.add_argument("-p",
                    "--plot",
                    action="store_true",
                    help="Plot the paths",
                    default=False)
args = parser.parse_args()


def main():
    # Load data points from a csv file
    filename = wa.get_wa_data_file("paths/sample_medium_loop.csv")
    points = wa.load_waypoints_from_csv(filename, delimiter=",") * 2

    # Create the path
    path1 = wa.WASplinePath(points, num_points=1000)

    # Create another path
    points = [[9, 8, 0.5], [20, 5, 0.5], [25, 15, 0.5], [34, 24, 0.5],
              [35, 28, 0.5], [70, 18, 0.5], [130, 98, 0.5]]
    path2 = wa.WASplinePath(points, num_points=1000, is_closed=False)