def initialize(self, world):
     for i in range(-5, 6):
         world.addObstacle(
             Circle(r=15,
                    pos=[
                        world.width / 2 + i * world.width / 13,
                        0.36 * world.height
                    ]))
         world.addObstacle(
             Circle(r=15,
                    pos=[
                        world.width / 2 + i * world.width / 13,
                        0.2 * world.height
                    ]))
     for i in range(-5, 5):
         world.addObstacle(
             Circle(r=15,
                    pos=[
                        world.width / 2 + world.width / 39 +
                        i * world.width / 13, 0.28 * world.height
                    ]))
         world.addObstacle(
             Circle(r=15,
                    pos=[
                        world.width / 2 + world.width / 39 +
                        i * world.width / 13, 0.44 * world.height
                    ]))
     world.canon = Canon(r=75,
                         pos=[world.width / 2, world.height],
                         theta=-np.pi / 2)
     world.target = TargetArea(pos=(world.width / 2, world.height * 0.05),
                               width=world.width * 0.05,
                               height=world.height * 0.05)
 def initialize(self, world):
     world.addObstacle(
         Circle(world.height * 0.25,
                (world.width * 0.5, world.height * 0.5), 1.0))
     world.canon = Canon(r=75,
                         pos=[world.width / 2, world.height],
                         theta=-np.pi / 2)
     world.canon.shotQuantity = 6
     world.showTrajectories = True
示例#3
0
 def initialize(self, world):
     world.addObstacle(
         Circle(r=150, pos=[world.width / 2, world.height / 2]))
     world.addObstacle(
         Circle(r=world.height,
                pos=[-world.height * np.sqrt(3) / 2, world.height / 2]))
     world.addObstacle(
         Circle(r=world.height,
                pos=[
                    world.width + world.height * np.sqrt(3) / 2,
                    world.height / 2
                ]))
     world.canon = Canon(r=75,
                         pos=[world.width / 2, world.height],
                         theta=-np.pi / 2)
     world.target = TargetArea(pos=(world.width / 2, world.height * 0.21),
                               width=world.height * 0.04,
                               height=world.height * 0.04)
 def initialize(self, world):
     world.addObstacle(
         Line(world.width * 0.75, world.height / 2, world.width * 0.3,
              np.pi * 0.5))
     world.addObstacle(
         Line(world.width * 0.6, world.height / 4, world.width * 0.3, 0))
     world.addObstacle(
         Rectangle(world.width * 0.2, world.height * 0.42,
                   world.width * 0.45, 30, 0))
     world.addObstacle(
         Rectangle(world.width * 0.2, world.height * 0.58,
                   world.width * 0.5, 35, 0))
     world.addObstacle(
         Circle(r=20, pos=[world.width * 0.43, world.height * 0.42]))
     world.addObstacle(
         Circle(r=55, pos=[world.width * 0.46, world.height * 0.58]))
     world.canon = Canon(r=75,
                         pos=[world.width / 2, world.height],
                         theta=-np.pi / 2)
     world.target = TargetArea(pos=(world.width * 0.35, world.height * 0.5),
                               width=world.height * 0.1,
                               height=world.height * 0.1)
示例#5
0
import numpy as np
import matplotlib.pyplot as plt
from obstacles import Square, Circle
from robot import solve_coeffs, generate_path
from plot_utils import *

# Populate world with obstacles
A = Square(center=(-1.25, 0.625), length=0.4)
B = Circle(center=(-1.625, -0.3), radius=0.25)
C = Circle(center=(0.75, 0), radius=0.125)
D = Circle(center=(1.125, 0), radius=0.125)

# Define knot points
knots = [[30, 250], [50, 230], [90, 250], [235, 235], [180, 360]]

# Start and end times
ts = 0
tf = len(knots) - 1

# Generate paths between all knot points with a time interval of 1
path = []
for t in range(tf):
    # Calculate coefficients for 3rd order joint trajectories
    c1 = solve_coeffs(t, t + 1, knots[t][0], knots[t + 1][0])
    c2 = solve_coeffs(t, t + 1, knots[t][1], knots[t + 1][1])
    # Calculate 100 points along trajectory during time interval
    path += generate_path(t, t + 1, c1, c2)

# Plot everything in cartesian space
plt.figure(1)
plot_obstacles([A, B, C, D])