Skip to content
Open
Show file tree
Hide file tree
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
Binary file added PathPlanning/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/maputils.cpython-310.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/rrt.cpython-310.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/rrt.cpython-39.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/rrt_star.cpython-310.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/rrtutils.cpython-310.pyc
Binary file not shown.
Binary file added PathPlanning/__pycache__/rrtutils.cpython-39.pyc
Binary file not shown.
Binary file not shown.
Binary file added Quadrotor/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added Quadrotor/__pycache__/params.cpython-310.pyc
Binary file not shown.
Binary file added Quadrotor/__pycache__/quadrotor.cpython-310.pyc
Binary file not shown.
Binary file added Quadrotor/__pycache__/quadsim.cpython-310.pyc
Binary file not shown.
Binary file added Quadrotor/__pycache__/quaternion.cpython-310.pyc
Binary file not shown.
Binary file added Quadrotor/__pycache__/utils.cpython-310.pyc
Binary file not shown.
Binary file added TrajGen/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added TrajGen/__pycache__/trajGen.cpython-310.pyc
Binary file not shown.
Binary file added TrajGen/__pycache__/trajutils.cpython-310.pyc
Binary file not shown.
Binary file added __pycache__/controller.cpython-310.pyc
Binary file not shown.
51 changes: 31 additions & 20 deletions runsim.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import numpy as np
import matplotlib
import platform
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as Axes3D

from PathPlanning import RRTStar, Map
from TrajGen import trajGenerator, Helix_waypoints, Circle_waypoints
from Quadrotor import QuadSim
import controller

np.random.seed(8)

# 3D boxes lx, ly, lz, hx, hy, hz
Expand All @@ -17,42 +20,50 @@
[70, 50, 0, 80, 80, 100]]

# limits on map dimensions
bounds = np.array([0,100])
bounds = np.array([0, 100])
# create map with obstacles
mapobs = Map(obstacles, bounds, dim = 3)
mapobs = Map(obstacles, bounds, dim=3)

#plan a path from start to goal
start = np.array([80,20,10])
goal = np.array([30,80,80])
# plan a path from start to goal
start = np.array([80, 20, 10])
goal = np.array([30, 80, 80])

rrt = RRTStar(start = start, goal = goal,
Map = mapobs, max_iter = 500,
goal_sample_rate = 0.1)
rrt = RRTStar(start=start, goal=goal,
Map=mapobs, max_iter=500,
goal_sample_rate=0.1)

waypoints, min_cost = rrt.plan()

# scale the waypoints to real dimensions
#waypoints = 0.02 * waypoints

# Generate trajectory through waypoints
#traj = trajGenerator(waypoints, max_vel=10, gamma=1e6)

#scale the waypoints to real dimensions
waypoints = 0.02*waypoints
# initialise simulation with given controller and trajectory
#Tmax = traj.TS[-1]
#des_state = traj.get_des_state
#sim = QuadSim(controller, des_state, Tmax)
waypoints = Helix_waypoints(5)

#Generate trajectory through waypoints
traj = trajGenerator(waypoints, max_vel = 10, gamma = 1e6)
traj = trajGenerator(waypoints,max_vel = 10,gamma = 1e6)

#initialise simulation with given controller and trajectory
Tmax = traj.TS[-1]
des_state = traj.get_des_state
sim = QuadSim(controller,des_state,Tmax)

#create a figure
# create a figure
fig = plt.figure()
ax = Axes3D.Axes3D(fig)
ax.set_xlim((0,2))
ax.set_ylim((0,2))
ax.set_zlim((0,2))
ax=fig.add_subplot(111,projection='3d')
#ax = Axes3D.Axes3D(fig)
ax.set_xlim((0, 2))
ax.set_ylim((0, 2))
ax.set_zlim((0, 2))

#plot the waypoints and obstacles
# plot the waypoints and obstacles
rrt.draw_path(ax, waypoints)
mapobs.plotobs(ax, scale = 0.02)
mapobs.plotobs(ax, scale=0.02)

#run simulation
# run simulation
sim.run(ax)
13 changes: 13 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

df_test=pd.DataFrame(data=np.random.normal(0,1,(20,3)),columns=['a','b','c'])
fig=plt.figure()
ax=fig.add_subplot(111,projection='3d')
ax.scatter=(df_test['a'],df_test['b'],df_test['c'])
ax.set_xlabel('a')
ax.set_ylabel('b')
ax.set_zlabel('c')
plt.show()