本文整理匯總了Python中vehicle.Vehicle類的典型用法代碼示例。如果您正苦於以下問題:Python Vehicle類的具體用法?Python Vehicle怎麽用?Python Vehicle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Vehicle類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: read_vehicles
def read_vehicles(database, query_no):
"""
read vehicle data
"""
conn = sqlite3.connect(database)
cursor = conn.cursor()
# database should have index on Sim
if query_no == "all":
cursor.execute("SELECT DISTINCT id FROM vehicles")
all_ids = cursor.fetchall()
else:
all_ids = [(no, ) for no in query_no]
vehicles = Vehicles()
for ID in all_ids:
# Order by Id?
cursor.execute("""SELECT gpstime, latitude, longitude
FROM vehicles
WHERE id = ? ORDER BY gpstime ASC""", ID)
results = cursor.fetchall()
vehicle = Vehicle(results, ID[0])
vehicle = vehicle.denoise()
vehicles.add(vehicle)
cursor.close()
conn.close()
return vehicles
示例2: __init__
def __init__(self, pmcombo, battery, pmaterial, cmaterial, geometry=None, feasible=True, score=0, pareto=False):
"""
The input "feasible" will be true by default. If the quad is found to be infeasible the value will be changed
to a tuple. The first entry will be a string explaining the first reason why the alternative was rejected
(but not necessarily the only reason it would have been rejected). The second entry is the % (e.g., 0.15) off
the vehicle spec was from the requirement.
"""
# Call vehicle constructor to initialize performance parameters
Vehicle.__init__(self)
if geometry is None:
geometry = [0] * 4
self.hub_size, self.hub_separation, self.hub_grid, self.arm_len = geometry
self.pmcombo = pmcombo
self.prop = self.pmcombo.prop
self.motor = self.pmcombo.motor
self.battery = battery
self.pmaterial = pmaterial
self.cmaterial = cmaterial
self.feasible = feasible
self.score = score
self.pareto = pareto
self.name = "(%s, %s)" % (self.pmcombo.name, self.battery.name)
示例3: __init__
def __init__(self, shapes=Circle(0.1), options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=2, degree=3, shapes=shapes, options=options)
if ((not 'syslimit' in self.options) or # default choose norm_inf
(self.options['syslimit'] is 'norm_inf')):
# user specified separate velocities for x and y
self.vxmin = bounds['vxmin'] if 'vxmin' in bounds else -0.5
self.vymin = bounds['vymin'] if 'vymin' in bounds else -0.5
self.vxmax = bounds['vxmax'] if 'vxmax' in bounds else 0.5
self.vymax = bounds['vymax'] if 'vymax' in bounds else 0.5
self.axmin = bounds['axmin'] if 'axmin' in bounds else -1.
self.aymin = bounds['aymin'] if 'aymin' in bounds else -1.
self.axmax = bounds['axmax'] if 'axmax' in bounds else 1.
self.aymax = bounds['aymax'] if 'aymax' in bounds else 1.
# user specified a single velocity for x and y
if 'vmin' in bounds:
self.vxmin = self.vymin = bounds['vmin']
if 'vmax' in bounds:
self.vxmax = self.vymax = bounds['vmax']
if 'amin' in bounds:
self.axmin = self.aymin = bounds['amin']
if 'amax' in bounds:
self.axmax = self.aymax = bounds['amax']
elif self.options['syslimit'] is 'norm_2':
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.5
self.amax = bounds['amax'] if 'amax' in bounds else 1.
示例4: __init__
def __init__(self, width=0.7, height=0.1, options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(self, n_spl=1, degree=3, shapes=Rectangle(width, height), options=options)
self.vmin = bounds['vmin'] if 'vmin' in bounds else -0.5
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.5
self.amin = bounds['amin'] if 'amin' in bounds else -1.
self.amax = bounds['amax'] if 'amax' in bounds else 1.
示例5: __init__
def __init__(self, shapes, options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=3, degree=3, shapes=shapes, options=options)
self.vmin = bounds['vmin'] if 'vmin' in bounds else -0.5
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.5
self.amin = bounds['amin'] if 'amin' in bounds else -1.
self.amax = bounds['amax'] if 'amax' in bounds else 1.
示例6: __init__
def __init__(self, width=0.7, height=0.1, options={}, bounds={}):
Vehicle.__init__(self, n_spl=1, degree=3, shapes=Rectangle(width, height), options=options)
self.vmin = bounds['vmin'] if 'vmin' in bounds else -0.8
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.8
self.amin = bounds['amin'] if 'amin' in bounds else -2.
self.amax = bounds['amax'] if 'amax' in bounds else 2.
# time horizon
self.T = self.define_symbol('T')
示例7: process_pipeline
def process_pipeline(frame, verbose=False):
detected_vehicles = []
img_blend_out = frame.copy()
# return bounding boxes detected by SSD
ssd_bboxes = process_frame_bgr_with_SSD(frame, ssd_model, bbox_helper, allow_classes=[7], min_confidence=0.3)
for row in ssd_bboxes:
label, confidence, x_min, y_min, x_max, y_max = row
x_min = int(round(x_min * frame.shape[1]))
y_min = int(round(y_min * frame.shape[0]))
x_max = int(round(x_max * frame.shape[1]))
y_max = int(round(y_max * frame.shape[0]))
proposed_vehicle = Vehicle(x_min, y_min, x_max, y_max)
if not detected_vehicles:
detected_vehicles.append(proposed_vehicle)
else:
for i, vehicle in enumerate(detected_vehicles):
if vehicle.contains(*proposed_vehicle.center):
pass # go on, bigger bbox already detected in that position
elif proposed_vehicle.contains(*vehicle.center):
detected_vehicles[i] = proposed_vehicle # keep the bigger window
else:
detected_vehicles.append(proposed_vehicle)
# draw bounding boxes of detected vehicles on frame
for vehicle in detected_vehicles:
vehicle.draw(img_blend_out, color=(0, 255, 255), thickness=2)
h, w = frame.shape[:2]
off_x, off_y = 30, 30
thumb_h, thumb_w = (96, 128)
# add a semi-transparent rectangle to highlight thumbnails on the left
mask = cv2.rectangle(frame.copy(), (0, 0), (w, 2 * off_y + thumb_h), (0, 0, 0), thickness=cv2.FILLED)
img_blend_out = cv2.addWeighted(src1=mask, alpha=0.3, src2=img_blend_out, beta=0.8, gamma=0)
# create list of thumbnails s.t. this can be later sorted for drawing
vehicle_thumbs = []
for i, vehicle in enumerate(detected_vehicles):
x_min, y_min, x_max, y_max = vehicle.coords
vehicle_thumbs.append(frame[y_min:y_max, x_min:x_max, :])
# draw detected car thumbnails on the top of the frame
for i, thumbnail in enumerate(sorted(vehicle_thumbs, key=lambda x: np.mean(x), reverse=True)):
vehicle_thumb = cv2.resize(thumbnail, dsize=(thumb_w, thumb_h))
start_x = 300 + (i+1) * off_x + i * thumb_w
img_blend_out[off_y:off_y + thumb_h, start_x:start_x + thumb_w, :] = vehicle_thumb
# write the counter of cars detected
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img_blend_out, 'Vehicles in sight: {:02d}'.format(len(detected_vehicles)),
(20, off_y + thumb_h // 2), font, 0.8, (255, 255, 255), 2, cv2.LINE_AA)
return img_blend_out
示例8: __init__
def __init__(self, shapes=Circle(0.1), options={}, bounds={}):
Vehicle.__init__(
self, n_spl=2, degree=3, shapes=shapes, options=options)
self.vmin = bounds['vmin'] if 'vmin' in bounds else -0.5
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.5
self.amin = bounds['amin'] if 'amin' in bounds else -1.
self.amax = bounds['amax'] if 'amax' in bounds else 1.
# time horizon
self.T = self.define_symbol('T')
示例9: __init__
def __init__(self, radius=0.2, options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=2, degree=4, shapes=Circle(radius), options=options)
self.radius = radius
self.u1min = bounds['u1min'] if 'u1min' in bounds else 2.
self.u1max = bounds['u1max'] if 'u1max' in bounds else 15.
self.u2min = bounds['u2min'] if 'u2min' in bounds else -8.
self.u2max = bounds['u2max'] if 'u2max' in bounds else 8.
self.g = 9.81
示例10: keyPressEvent
def keyPressEvent(self, QKeyEvent):
if QKeyEvent.key() == QtCore.Qt.Key_Z:
vehicle = Vehicle(parent=self, x=100, y=600)
vehicle.summon()
elif QKeyEvent.key() == QtCore.Qt.Key_Space:
self.message.set_text("Paused")
self.message.show()
self.pause()
else:
self.shooter.move(QKeyEvent.key())
示例11: __init__
def __init__(self, lead_veh=None, shapes=Circle(0.2), l_hitch=0.2, options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=1 + lead_veh.n_spl, degree=3, shapes=shapes, options=options)
# n_spl contains all splines of lead_veh and trailer
# being: tg_ha_trailer, v_til_veh, tg_ha_veh
self.lead_veh = Dubins(Circle(0.2)) if (lead_veh is None) else lead_veh # vehicle which pulls the trailer
self.l_hitch = l_hitch # distance between rear axle of trailer and connection point on the car
self.tmax = bounds['tmax'] if 'tmax' in bounds else np.pi/4. # limit angle between trailer and vehicle
self.tmin = bounds['tmin'] if 'tmin' in bounds else -np.pi/4.
示例12: __init__
def __init__(self, shapes=Rectangle(width=0.2, height=0.4), options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=3, degree=3, shapes=shapes, options=options)
self.vmin = bounds['vmin'] if 'vmin' in bounds else -0.5
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.5
self.amin = bounds['amin'] if 'amin' in bounds else -1.
self.amax = bounds['amax'] if 'amax' in bounds else 1.
self.wmin = bounds['wmin'] if 'wmin' in bounds else -np.pi/6. # in rad/s
self.wmax = bounds['wmax'] if 'wmax' in bounds else np.pi/6.
示例13: __init__
def __init__(self, length=0.4, options=None, bounds=None):
bounds = bounds or {}
Vehicle.__init__(
self, n_spl=2, degree=2, shapes=Circle(length/2.), options=options)
self.vmax = bounds['vmax'] if 'vmax' in bounds else 0.8
self.amax = bounds['amax'] if 'amax' in bounds else 1.
self.dmin = bounds['dmin'] if 'dmin' in bounds else -np.pi/6. # steering angle [rad]
self.dmax = bounds['dmax'] if 'dmax' in bounds else np.pi/6.
self.ddmin = bounds['ddmin'] if 'ddmin' in bounds else -np.pi/4. # dsteering angle [rad/s]
self.ddmax = bounds['ddmax'] if 'ddmax' in bounds else np.pi/4.
self.length = length
示例14: __init__
def __init__(self, radius=0.2, options={}, bounds={}):
Vehicle.__init__(
self, n_spl=2, degree=4, shapes=Circle(radius), options=options)
self.radius = radius
self.u1min = bounds['u1min'] if 'u1min' in bounds else 1.
self.u1max = bounds['u1max'] if 'u1max' in bounds else 15.
self.u2min = bounds['u2min'] if 'u2min' in bounds else -8.
self.u2max = bounds['u2max'] if 'u2max' in bounds else 8.
self.g = 9.81
# time horizon
self.T = self.define_symbol('T')
示例15: destroy
def destroy(self):
"""Prepare this Character to be garbage-collected by Python:
Remove all of the Character's nodes from the scene graph, remove its
CollisionSolids from the global CollisionTraverser, clear its
CollisionHandler, remove tasks, destroy Actor.
After executing this method, any remaining references to the Character
object can be destroyed by the user module, and the Character will be
garbage-collected by Python.
"""
taskMgr.remove(self.characterStepTask)
self.cleanup()
self.actor.delete()
Vehicle.destroy(self)