コード例 #1
0
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
0
    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
0
ファイル: holonomic.py プロジェクト: meco-group/omg-tools
    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
0
ファイル: holonomic1d.py プロジェクト: meco-group/omg-tools
 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
0
ファイル: holonomic3d.py プロジェクト: meco-group/omg-tools
 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
0
ファイル: platform.py プロジェクト: jgillis/omg-tools
 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
0
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
0
ファイル: holonomic.py プロジェクト: jgillis/omg-tools
 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
0
 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.
コード例 #10
0
ファイル: trailer.py プロジェクト: meco-group/omg-tools
 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.
コード例 #11
0
ファイル: quadrotor.py プロジェクト: meco-group/omg-tools
 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
コード例 #12
0
ファイル: window.py プロジェクト: eduguerra/Zombie-Game
 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())
コード例 #13
0
ファイル: quadrotor.py プロジェクト: jgillis/omg-tools
 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')
コード例 #14
0
ファイル: bicycle.py プロジェクト: meco-group/omg-tools
 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
コード例 #15
0
ファイル: character.py プロジェクト: kengleason/PandaSteer
 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)
コード例 #16
0
ファイル: quadrotor.py プロジェクト: meco-group/omg-tools
 def set_parameters(self, current_time):
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['spl0'] = self.prediction['state'][:2]
     parameters[self]['dspl0'] = self.prediction['dspl']
     parameters[self]['ddspl0'] = self.prediction['ddspl']
     parameters[self]['poseT'] = self.poseT
     return parameters
コード例 #17
0
ファイル: holonomic.py プロジェクト: meco-group/omg-tools
 def set_parameters(self, current_time):
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['state0'] = self.prediction['state']
     parameters[self]['input0'] = self.prediction['input']
     # parameters[self]['dinput0'] = self.prediction['dinput']
     parameters[self]['poseT'] = self.poseT
     return parameters
コード例 #18
0
ファイル: quadrotor3d.py プロジェクト: meco-group/omg-tools
    def __init__(self, radius=0.2, options=None, bounds=None):
        bounds = bounds or {}
        Vehicle.__init__(
            self, n_spl=3, degree=2, shapes=Sphere(radius), options=options)

        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 -2.
        self.u2max = bounds['u2max'] if 'u2max' in bounds else 2.
        self.u3min = bounds['u3min'] if 'u3min' in bounds else -2.
        self.u3max = bounds['u3max'] if 'u3max' in bounds else 2.
        self.phimin = bounds['phimin'] if 'phimin' in bounds else -np.pi/6
        self.phimax = bounds['phimax'] if 'phimax' in bounds else np.pi/6
        self.thetamin = bounds['thetamin'] if 'thetamin' in bounds else -np.pi/6
        self.thetamax = bounds['thetamax'] if 'thetamax' in bounds else np.pi/6
        self.g = 9.81
        self.radius = radius
コード例 #19
0
 def set_parameters(self, current_time):
     # for the optimization problem
     # convert theta to tg_ha here
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['pos0'] = self.prediction['state'][:2]  # x, y
     parameters[self]['tg_ha0'] = np.tan(self.prediction['state'][2]/2)
     parameters[self]['vel0'] = self.prediction['input'][:2]  # dx, dy
     parameters[self]['dtg_ha0'] = 0.5*self.prediction['input'][2]*(1+parameters[self]['tg_ha0']**2)
     parameters[self]['posT'] = self.poseT[:2]  # x, y
     parameters[self]['tg_haT'] = np.tan(self.poseT[2]/2)
     return parameters
コード例 #20
0
ファイル: dennis.py プロジェクト: pwarren/AGDeviceControl
    def __init__(self, *args, **kwargs):

        Vehicle.__init__(self, *args, **kwargs)

        # quad servo controller
        if hasattr(self,'phid'):
            self.phid = int(self.phid)
        else:
            self.phid = 5927
        self.q = QuadServo( self.phid )

        # each servo has adjustable min, max positions (and final 10.6 "factor" - no idea what this does)
        self.q.setRange( PHIDGET_QUADSERVO_MOTOR0, 100, 3000 )
        self.q.setRange( PHIDGET_QUADSERVO_MOTOR1, 1000, 3000 )
        self.q.setRange( PHIDGET_QUADSERVO_MOTOR2, 1000, 3000 )

        # servo motor controller positions, the middle 0.5 is stopped
        self.rest = 0.5
        self.forward_start = 0.54
        self.spin_forward_start = 0.54
        self.motion_delta = 0.02
        self.turn_delta = 0.01
        self.spin_delta = 0.01
        self.reverse_start = 0.45
        self.spin_reverse_start = 0.46
        self.max = 0.70
        self.min = 0.30
        self.tilt_min = 0.25
        self.tilt_max = 0.85
        self.tilt_delta = 0.01

        self.left = self.rest
        self.right = self.rest
        self.tilt = 0.5

        self.left_previous = self.left
        self.right_previous = self.right
        self.tilt_previous = self.tilt

        self.state = 'STOPPED'
コード例 #21
0
ファイル: sim2.py プロジェクト: athityakumar/software
    def __init__(self):
        render.setAntialias(AntialiasAttrib.MAuto)

        # Enable physics - perhaps this should go someplace else, but it must
        # be done before the Vehicle is initialized.
        base.enableParticles()
        aei = AngularEulerIntegrator()
        base.physicsMgr.attachAngularIntegrator(aei)

        SelectionEngine.getDefault().enable()
        SelectionManager.getDefault().enable()
        
        # Make the environment and the vehicle model.
        makeEnvironment()
        self.vehicle = Vehicle(render)

        MissionElement.loadElementConfig('mission_elements.plist')

        #layoutName = AppPreferences.get('last_layout', 'defaultLayout.plist')
        if len(sys.argv) == 2:
            layoutName = sys.argv[1]
            print "Using command line argument %s for layout" %layoutName
        else:
            print "Using default layout file"
            print "Use ./sim2.py [layout file] to use a different layout"
            print "Or press Ctrl+O to open a new layout in the simulator"
            layoutName = 'defaultLayout.plist'

        self.layout = MissionLayout.loadLayout(layoutName)
        render.attachNewNode(self.layout)

        self.vehicle.setLayout(self.layout) #Link the layout 

        # Set up render buffer viewer, to aide debugging.
        self.accept("v", base.bufferViewer.toggleEnable)
        self.accept("V", base.bufferViewer.toggleEnable)
        base.bufferViewer.setPosition("llcorner")
        
        # Set up file saver
        self.accept('s', self._saveLayout)
        self.accept('o', self._openLayout)
        self.accept('f', self._setFreq)
        root = Tk()
        root.withdraw()
        self.modButtons = ModifierButtons()
        self.modButtons.addButton(KeyboardButton.control())
        self.accept('control', self.modButtons.buttonDown,
                [KeyboardButton.control()])
        self.accept('control-up', self.modButtons.buttonUp,
                [KeyboardButton.control()])
        # Add GUI Controls
        '''
コード例 #22
0
ファイル: quadrotor3d.py プロジェクト: meco-group/omg-tools
 def set_parameters(self, current_time):
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['q_phi0'] = np.tan(self.prediction['state'][6]/2.)
     parameters[self]['q_theta0'] = np.tan(self.prediction['state'][7]/2.)
     parameters[self]['f_til0'] = self.prediction['input'][0]/((1+parameters[self]['q_phi0']**2)*(1+parameters[self]['q_theta0']**2))
     parameters[self]['dq_phi0'] = 0.5*self.prediction['input'][1]*(1+parameters[self]['q_phi0']**2)
     parameters[self]['dq_theta0'] = 0.5*self.prediction['input'][2]*(1+parameters[self]['q_theta0']**2)
     parameters[self]['pos0'] = self.prediction['state'][:3]
     parameters[self]['dpos0'] = self.prediction['state'][3:6]
     parameters[self]['posT'] = self.poseT[:3]
     parameters[self]['q_phiT'] = np.tan(self.poseT[3]/2.)
     parameters[self]['q_thetaT'] = np.tan(self.poseT[4]/2.)
     return parameters
コード例 #23
0
ファイル: character.py プロジェクト: kengleason/PandaSteer
    def __init__(self,name='Ralph',model='models/ralph',run='models/ralph-run',
                 walk='models/ralph-walk',pos=None,avoidObstacles=True,
                 avoidVehicles=True,
                 hprs=(180,0,0,1,1,1), # Ralph's Y is backward
                 ):
        """Initialise the character.

        By default tries to load Panda3D's Ralph model: models/ralph,
        models/ralph-run and models/ralph-walk."""

        FSM.FSM.__init__(self,'Character')
        Vehicle.__init__(self,pos=pos,avoidObstacles=avoidObstacles,
                         avoidVehicles=avoidVehicles,radius=2.5)

        self.name = name
        self.lastPose = 0 # Used when transitioning between animations
        self.actor = Actor(model,{"run":run,"walk":walk})        
        self.actor.setHprScale(*hprs)
        self.actor.reparentTo(self.prime)

        # Add a task for this Character to the global task manager.
        self.characterStepTask=taskMgr.add(self.characterStep,"Character step task")
コード例 #24
0
 def set_parameters(self, current_time):
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['spl0'] = self.prediction['state'][:3]
     f0 = self.prediction['input'][0]
     phi0 = self.prediction['state'][6]
     theta0 = self.prediction['state'][7]
     ddx0 = f0*np.cos(phi0)*np.sin(theta0)
     ddy0 = -f0*np.sin(phi0)
     ddz0 = f0*np.cos(phi0)*np.cos(theta0)-self.g
     parameters[self]['ddspl0'] = [ddx0, ddy0, ddz0]
     parameters[self]['dspl0'] = self.prediction['state'][3:6]
     parameters[self]['positionT'] = self.positionT
     return parameters
コード例 #25
0
ファイル: trailer.py プロジェクト: meco-group/omg-tools
 def set_parameters(self, current_time):
     # pred of leading vehicle is not simulated separately
     pred_veh = {}
     pred_veh['input'] = self.prediction['input']
     pred_veh['state'] = self.prediction['state'][3:, ]
     self.lead_veh.update_prediction(pred_veh)
     parameters = Vehicle.set_parameters(self, current_time)
     parameters_tr = {}
     parameters_tr['tg_ha_tr0'] = np.tan(self.prediction['state'][2]/2.)
     parameters_tr['dtg_ha_tr0'] = 0.5*self.prediction['input'][0]/self.l_hitch*(np.sin(self.prediction['state'][5]-self.prediction['state'][2]))*(1+parameters_tr['tg_ha_tr0']**2)  # dtg_ha
     if hasattr(self, 'theta_trT'):
         parameters_tr['tg_ha_trT'] = np.tan(self.theta_trT/2.)
     parameters_veh = self.lead_veh.set_parameters(current_time)
     parameters[self].update(parameters_tr)
     parameters[self].update(parameters_veh[self.lead_veh])
     return parameters
コード例 #26
0
ファイル: bicycle.py プロジェクト: meco-group/omg-tools
 def set_parameters(self, current_time):
     # for the optimization problem
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['tg_ha0'] = np.tan(self.prediction['state'][2]/2)
     parameters[self]['v_til0'] = self.prediction['input'][0]/(1+parameters[self]['tg_ha0']**2)
     parameters[self]['pos0'] = self.prediction['state'][:2]
     parameters[self]['posT'] = self.poseT[:2]  # x, y
     parameters[self]['v_tilT'] = 0.
     parameters[self]['dv_tilT'] = 0.
     parameters[self]['tg_haT'] = np.tan(self.poseT[2]/2)
     parameters[self]['dtg_haT'] = 0.
     parameters[self]['ddtg_haT'] = 0.
     # parameters['tdeltaT'] = np.tan(self.poseT[3])
     if (parameters[self]['v_til0'] <= 1e-4):  # use l'Hopital's rule
         parameters[self]['hop0'] = 1.
         parameters[self]['v_til0'] = 0.  # put exactly = 0.
         parameters[self]['dtg_ha0'] = 0.  # otherwise you don't get 0./0.
         parameters[self]['tdelta0'] = np.tan(self.prediction['state'][3])
     else:  # no need for l'Hopital's rule
         parameters[self]['hop0'] = 0.
         parameters[self]['dtg_ha0'] = np.tan(self.prediction['state'][3])*parameters[self]['v_til0']* \
                                        (1+parameters[self]['tg_ha0']**2)**2/(2*self.length)
         # tdelta0 is only used when hop0 = 1, so no need to assign here
     return parameters
コード例 #27
0
ファイル: agv.py プロジェクト: zhengzh/omg-tools
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'plot_type': 'agv'})  # by default plot a bicycle-shape
コード例 #28
0
from vehicle import Vehicle

v = Vehicle('4-cyclider',
            ['front-driver', 'front-pasenger', 'rear-driver', 'rear-pasenger'])
#print(v.engine)
v.description()

#we can treat vehcile object as namespace and can add attributes at runtime

#adding attributes at runtime
v.serial_number = '1234'
print(f'Serial Number: {v.serial_number}')

#removing attirbute at runtime
del v.serial_number

#this will throw error because we have now delete the serial number attribute from Vechicl instance
print(f'Serial Number: {v.serial_number}')
コード例 #29
0
 def test_subsequent_years_tax_for_electric(self):
     vehicle = Vehicle(206, "ELECTRIC", self.FIRST_OF_APRIL_2017, 20000)
     self.assertEqual(0, self.tax_calculator.calculate_tax(vehicle))
コード例 #30
0
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'syslimit': 'norm_inf'})
コード例 #31
0
 def __init__(self):
     Vehicle.__init__(self, "Mustang", "Ford", 460, 4)
     GasPowered.__init__(self, 20)
コード例 #32
0
from vehicle import Vehicle
import time

vehicle = Vehicle()
#vehicle.set_motor(7.3)
time.sleep(3)
for i in xrange(730, 800, 1):
    pwm = i / 100.0
    print '{}'.format(pwm)
    vehicle.set_motor(pwm)
    time.sleep(0.1)
コード例 #33
0
 def __init__(self, brand, model, price, doors):
     Vehicle.__init__(self, brand, model, price)
     self.doors = doors
コード例 #34
0
from vehicle import Vehicle
import time

vehicle = Vehicle()
vehicle.set_motor(1)
vehicle.set_steering(5)
time.sleep(10)
コード例 #35
0
            "https://www.police.govt.nz/stolenwanted/vehicles/csv/download?tid=&all=true&gzip=false"
        )
        print("done.")
    except:
        print(
            "Failed to get the raw vehicle data. Has the URL changed, or is the website down?"
        )
        sys.exit(0)

    #process the csv.
    print("processing data and writing to MySQL...")
    vehicle_data_lines = raw_vehicle_data.text.split("\n")[0:-1]
    vehicles = []

    for line in vehicle_data_lines:
        this_vehicle = Vehicle(line)
        sql = "INSERT INTO `" + schema + "`.`vehicles`(`rego`,`colour`,`make`,`model`,`year`,`type`,`date`,`location`) VALUES (%s,%s,%s,%s,%s,%s,%s,%s)"
        vehicle_values = this_vehicle.get_sql_tuple()

        try:
            cursor.execute(sql, vehicle_values)
            db.commit()
            added_records_count += 1
        except:
            non_added_regos.append(this_vehicle.rego)

    print("done")
    print('Finished running grabber on {}. A total of {} records were added'.
          format(datetime.datetime.now(), str(added_records_count)),
          end='\n\n')
    print(
コード例 #36
0
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'stop_tol': 1.e-2})
     self.options.update({'substitution': False})
     self.options.update({'exact_substitution': False})
コード例 #37
0
 def __init__(self):
     Vehicle.__init__(self)
コード例 #38
0
def main_loop(race):
    current_distance = 0

    vehicle = Vehicle()
    line_tracker = LineTracker()
    velocity_pid = VelocityPID()
    steering_pid = SteeringPID()

    next_checkpoint = race.get_next_checkpoint(current_distance)
    while next_checkpoint:
        while current_distance < next_checkpoint.distance:
            # get distance & time
            current_distance = vehicle.get_distance()

            # get velocity
            vehicle.get_velocity()

            # get required velocity
            required_velocity = calc_required_velocity(next_checkpoint,
                                                       time_passed,
                                                       current_distance)

            # pass velocity and required velocity to velocity PID
            velocity_pid.update_velocity(current_velocity)
            velocity_pid.update_required_velocity(required_velocity)

            # get real world position relative to line
            try:
                offset = line_tracker.get_position()
            except LineTrackerException, e:
                print e.message()
                vehicle.halt()
                return

            # pass angle and offset to steering pid
            steering_pid.update_current_position(offset, angle)

            # request new pwm from velocity PID
            motor_pwm = velocity_pid.get_required_pwm()

            # request new pwm from steering PID
            steering_pwm = steering_pid.get_required_pwm()

            # set steering pwm
            vehicle.set_motor(motor_pwm)

            # set motor pwm
            vehicle.set_steering(steering_pwm)

        # update checkpoint
        next_checkpoint = race.get_next_checkpoint(current_distance)
コード例 #39
0
def init_new_vehicles(labels):
    # Iterate through labels in integrated heatmap
    for car_number in range(1, labels[1] + 1):
        # Find pixels with each car_number label value
        nonzero = (labels[0] == car_number).nonzero()
        # Identify x and y values of those pixels
        nonzeroy = np.array(nonzero[0])
        nonzerox = np.array(nonzero[1])
        # Define a bounding box based on min/max x and y
        xleft = np.min(nonzerox)
        ytop = np.min(nonzeroy)
        xright = np.max(nonzerox)
        ybot = np.max(nonzeroy)

        # Search over all vehicles for best overlap to associate
        max_iou = -1.0
        for v in vehicle_list:

            if v.age_predicted < max_age_predicted:
                centerx_v = v.fit_centroid_x
                xleft_v = np.int(centerx_v - 0.5 * v.fit_width)
                xright_v = np.int(centerx_v + 0.5 * v.fit_width)

                centery_v = v.fit_centroid_y
                ytop_v = np.int(centery_v - 0.5 * v.fit_height)
                ybot_v = np.int(centery_v + 0.5 * v.fit_height)

                # Calc intersection over union:
                area_det = (xright - xleft + 1) * (ybot - ytop + 1)
                area_v = (xright_v - xleft_v + 1) * (ybot_v - ytop_v + 1)
                intersection = max(
                    0,
                    min(xright, xright_v) - max(xleft, xleft_v)) * max(
                        0,
                        min(ybot, ybot_v) - max(ytop, ytop_v))
                union = area_det + area_v - intersection
                iou = intersection / union

                if iou > max_iou:
                    max_iou = iou

        # If overlap is small -> init new track
        if max_iou < min_iou:
            new_vehicle = Vehicle()
            new_vehicle.centroid_x = 0.5 * (xleft + xright)
            new_vehicle.centroid_y = 0.5 * (ytop + ybot)
            new_vehicle.width = xright - xleft
            new_vehicle.height = ybot - ytop
            new_vehicle.fit_centroid_x = new_vehicle.centroid_x
            new_vehicle.fit_centroid_y = new_vehicle.centroid_y
            new_vehicle.fit_width = new_vehicle.width
            new_vehicle.fit_height = new_vehicle.height
            new_vehicle.allx.extend(np.arange(xleft, xright + 1))
            new_vehicle.ally.extend(np.arange(ytop, ybot + 1))
            new_vehicle.detected = True
            new_vehicle.age_predicted = 0
            vehicle_list.append(new_vehicle)
コード例 #40
0
        v(800, 650),
        v(900, 650),
        v(1000, 650),
        v(1000, 600),
        v(1000, 500),
        v(1150, 500),
        v(1150, 600),
        v(1150, 750)
    ], 5)

    points4_reverse = list(reversed(path4.points))
    path4_reverse = Path(points4_reverse, 5)

    paths.append(path1)
    paths.append(path2)
    paths.append(path3)
    paths.append(path4)
    paths.append(path4_reverse)
    paths.append(path3_reverse)
    paths.append(path2_reverse)
    paths.append(path1_reverse)

    world = World(w, h, paths)

    for i in range(vehicleCount):
        world.addVehicle(
            Vehicle(paths[(i % len(paths))].start, vel, v0, 2, 25, 20,
                    paths[i % len(paths)]))

    ex = GUI(world)
    sys.exit(app.exec_())
コード例 #41
0
class Vehicle_movement_node:
    def __init__(self):
        SpeedControlMotor = Motor(8, 7, 1, 100)
        SteerControlMotor = Motor(9, 10, 11, 2)
        self.car = Vehicle(SpeedControlMotor, SteerControlMotor)
        self.car.start_engines()
        print "##ROS##\n. Starting movement_node. Subscribed to movement_command topic\n##ROS##"
        rospy.init_node(
            "Vehicle_movement_node"
        )  # removed ,anonymous=True to be able to kill it by name
        rospy.Subscriber("kotyamba/cmd_vel", TwistStamped,
                         self.on_twist_command)

        rospy.spin()

    def __del__(self):
        self.car.stop_()

    def on_twist_command(self, twist_stamped):
        '''  Up/Down Axis stick left twist.linear.x
            Left/Right Axis stick right twist.angular.z
        '''
        msg = "twist cmd: twist.linear.x: {}, twist.angular.z: {}".format(
            twist_stamped.twist.linear.x, twist_stamped.twist.angular.z)
        # print "twist {}".format(twist)
        # rospy.loginfo(twist)
        # print twist
        # if(twist.linear.x == 0 and twist.angular.z == 0):
        #     self.car.on_stop()
        if (twist_stamped.twist.linear.x >= 0):
            self.car.on_speed_change(twist_stamped.twist.linear.x * 100)
        elif (twist_stamped.twist.linear.x < 0):
            self.car.on_speed_change(twist_stamped.twist.linear.x * 100)
        if (twist_stamped.twist.angular.z < 0):
            self.car.on_steering_change(twist_stamped.twist.angular.z * 50)
        elif (twist_stamped.twist.angular.z >= 0):
            self.car.on_steering_change(twist_stamped.twist.angular.z * 50)
コード例 #42
0
ファイル: test_motor.py プロジェクト: abhispra/car
from values import Const
from pin_set import PinSet
from vehicle import Vehicle

Motor1A = 18
Motor1B = 16
Motor1E = 12
Motor2A = 15
Motor2B = 13
Motor2E = 11

GPIO.setmode(GPIO.BOARD)
rl_pin_set = PinSet(Motor1E, Motor1A, Motor1B)
rr_pin_set = PinSet(Motor2E, Motor2A, Motor2B)

vehicle = Vehicle(Const.TWO_WHEELED, rl_pin_set, rr_pin_set)

vehicle.forward()
sleep(2)
vehicle.turn_left()
sleep(0.75)
vehicle.forward()
sleep(2)
vehicle.turn_right()
sleep(0.75)
vehicle.forward()
sleep(1)
vehicle.reverse()
sleep(3)
vehicle.stop()
コード例 #43
0
 def __init__(self):
     Vehicle.__init__(self, "Leaf", "Nissan", 395, 4)
     ElectricPowered.__init__(self, 45)
コード例 #44
0
    def left():
        global turn, delta_turn
        turn -= delta_turn
        if turn < 0: turn = 0
    def right():
        global turn, delta_turn
        turn += delta_turn
        if turn > 500: turn = 500
    def stop():
        global speed
        speed = 250
    def reset():
        global speed, turn
        speed = turn = 250
    def finish():
        global keep_running
        keep_running = False

    keyboard.hook_key('up', up)
    keyboard.hook_key('down', down)
    keyboard.hook_key('left', left)
    keyboard.hook_key('right', right)
    keyboard.hook_key('space', stop)
    keyboard.hook_key('r', reset)
    keyboard.hook_key('q', finish)

    with Vehicle(port, baudrate) as car:
        while keep_running:
            time.sleep(0.5)
            car.move(speed, turn)
            print(f'Speed: {speed}, turn: {turn}')
コード例 #45
0
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options['stop_tol'] = 1.e-2
コード例 #46
0
    def testTickSimulation(self):
        while True:
            self.timer += 1
            inpt = self.input_to()
            self.updateCity()
            self.findRoadTrafficFlow(self.city.city_map, self.city.roads)
            # self.findJunctionTrafficFlow(self.city.city_map, self.city.junctions)

            if self.timer % 3 == 0:
                x = random.randint(0, 0)
                y = random.randint(self.city.junc_len - 2,
                                   self.city.junc_len - 2)
                x_pos = random.randint(x * 4 + 2, x * 4 + 3)
                y_pos = random.randint(y * 8 + 4, y * 8 + 5)
                if self.city.isAccomodate(x_pos, y_pos):
                    self.temp_vehicles.append(Vehicle(x_pos, y_pos, self.city))
                    self.temp_vehicles[
                        self.MAX_TEMP_VEHICLES].present_junction = (x, y)
                    self.temp_vehicles[
                        self.MAX_TEMP_VEHICLES].next_junction = (
                            self.city.junc_wid - 1, self.city.junc_len - 2)
                    self.city.city_map[x_pos][y_pos] = 'O'
                    self.MAX_TEMP_VEHICLES += 1

            if self.timer % 4 - 1 == 0:
                x = random.randint(self.city.junc_wid / 2,
                                   self.city.junc_wid / 2)
                y = random.randint(0, 0)
                x_pos = random.randint(x * 4 + 2, x * 4 + 3)
                y_pos = random.randint(y * 8 + 4, y * 8 + 5)
                if self.city.isAccomodate(x_pos, y_pos):
                    self.temp_vehicles.append(Vehicle(x_pos, y_pos, self.city))
                    self.temp_vehicles[
                        self.MAX_TEMP_VEHICLES].present_junction = (x, y)
                    self.temp_vehicles[
                        self.MAX_TEMP_VEHICLES].next_junction = (
                            self.city.junc_wid / 2, self.city.junc_len - 1)
                    self.city.city_map[x_pos][y_pos] = 'O'
                    self.MAX_TEMP_VEHICLES += 1

            for vhcl in range(self.MAX_VEHICLES):
                # self.vehicles_path[vhcl].append([self.vehicles[vhcl].x,self.vehicles[vhcl].y])
                if self.vehicles[vhcl].reached_junction:
                    self.vehicles[vhcl].value_iteration(
                        self.city.junc_wid, self.city.junc_len,
                        self.city.borders, self.traffic_flow,
                        self.city.TwoDJunctions, self.city.junction_roads)
                self.vehicles[vhcl].traverseToJunctionVI(
                    self.city.junctions, self.vehicles[vhcl].next_junction,
                    self.city.city_map)

            for vhcl in range(self.MAX_TEMP_VEHICLES):
                self.temp_vehicles[vhcl].traverseToJunctionVI(
                    self.city.junctions,
                    self.temp_vehicles[vhcl].next_junction, self.city.city_map)

            if (inpt == 'q' or inpt == 'Q'):
                exit()

            if (inpt == 'x'):
                self.vehicles[0].print_utilities(self.vehicles[0].utilities,
                                                 self.city.width / 4,
                                                 self.city.length / 8)
                time.sleep(3)
コード例 #47
0
#
# MicroPython for the IOT
# 
# Class Example: Using the generic Vehicle class
#
# Dr. Charles Bell
#
from vehicle import Vehicle

sedan = Vehicle(2, 4)
sedan.add_occupant()
sedan.add_occupant()
sedan.add_occupant()
print("The car has {0} occupants.".format(sedan.num_occupants()))
コード例 #48
0
 def set_parameters(self, current_time):
     parameters = Vehicle.set_parameters(self, current_time)
     parameters[self]['state0'] = self.prediction['state']
     parameters[self]['input0'] = self.prediction['input']
     parameters[self]['poseT'] = self.poseT
     return parameters
コード例 #49
0
ファイル: scan.py プロジェクト: imwasenabled/raspberryjammod
    minZ = min(z for (x, y, z) in vehicle.baseVehicle)
    maxX = max(x for (x, y, z) in vehicle.baseVehicle)
    maxY = max(y for (x, y, z) in vehicle.baseVehicle)
    maxZ = max(z for (x, y, z) in vehicle.baseVehicle)
    mc.postToChat('Erasing')
    mc.setBlocks(pos.x + minX, pos.y + minY, pos.z + minZ, pos.x + maxX,
                 pos.y + maxY, pos.z + maxZ, AIR)
    mc.postToChat('Drawing')
    vehicle.draw(pos.x, pos.y, pos.z, vehicle.baseAngle)
    mc.postToChat('Done')


mc = Minecraft()
basePos = mc.player.getTilePos()
rot = mc.player.getRotation()
vehicle = Vehicle(mc)
#restore(vehicle, "cottage", basePos)
#exit()

if len(sys.argv) == 8:
    corner1 = int(sys.argv[2]), int(sys.argv[3]), int(sys.argv[4])
    corner2 = int(sys.argv[5]), int(sys.argv[6]), int(sys.argv[7])
elif len(sys.argv) == 2:
    corner1, corner2 = getArea(basePos, 0)
elif len(sys.argv) == 3:
    if sys.argv[2].startswith('r'):
        restore(vehicle, sys.argv[1], basePos)
        exit()
    corner1, corner2 = getArea(basePos, int(sys.argv[2]))
else:
    mc.postToChat("scan vehiclename x1 y1 z1 x2 y2 z2")
コード例 #50
0
 def test_subsequent_years_tax_for(self):
     vehicle = Vehicle(206, "PETROL", self.FIRST_OF_APRIL_2017, 20000)
     self.assertEqual(140, self.tax_calculator.calculate_tax(vehicle))
コード例 #51
0
ファイル: bicycle.py プロジェクト: zhengzh/omg-tools
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'plot_type': 'bicycle'})  # by default plot a bicycle
     self.options.update({'substitution' : False})
     self.options.update({'exact_substitution' : False})
コード例 #52
0
 def test_subsequent_years_tax_for_alternative_fuel(self):
     vehicle = Vehicle(206, "ALTERNATIVE_FUEL", self.FIRST_OF_APRIL_2017,
                       20000)
     self.assertEqual(130, self.tax_calculator.calculate_tax(vehicle))
コード例 #53
0
ファイル: sim2.py プロジェクト: athityakumar/software
class World(DirectObject):
    instance = None

    def __init__(self):
        render.setAntialias(AntialiasAttrib.MAuto)

        # Enable physics - perhaps this should go someplace else, but it must
        # be done before the Vehicle is initialized.
        base.enableParticles()
        aei = AngularEulerIntegrator()
        base.physicsMgr.attachAngularIntegrator(aei)

        SelectionEngine.getDefault().enable()
        SelectionManager.getDefault().enable()
        
        # Make the environment and the vehicle model.
        makeEnvironment()
        self.vehicle = Vehicle(render)

        MissionElement.loadElementConfig('mission_elements.plist')

        #layoutName = AppPreferences.get('last_layout', 'defaultLayout.plist')
        if len(sys.argv) == 2:
            layoutName = sys.argv[1]
            print "Using command line argument %s for layout" %layoutName
        else:
            print "Using default layout file"
            print "Use ./sim2.py [layout file] to use a different layout"
            print "Or press Ctrl+O to open a new layout in the simulator"
            layoutName = 'defaultLayout.plist'

        self.layout = MissionLayout.loadLayout(layoutName)
        render.attachNewNode(self.layout)

        self.vehicle.setLayout(self.layout) #Link the layout 

        # Set up render buffer viewer, to aide debugging.
        self.accept("v", base.bufferViewer.toggleEnable)
        self.accept("V", base.bufferViewer.toggleEnable)
        base.bufferViewer.setPosition("llcorner")
        
        # Set up file saver
        self.accept('s', self._saveLayout)
        self.accept('o', self._openLayout)
        self.accept('f', self._setFreq)
        root = Tk()
        root.withdraw()
        self.modButtons = ModifierButtons()
        self.modButtons.addButton(KeyboardButton.control())
        self.accept('control', self.modButtons.buttonDown,
                [KeyboardButton.control()])
        self.accept('control-up', self.modButtons.buttonUp,
                [KeyboardButton.control()])
        # Add GUI Controls
        '''
        buttonReady = makeGeom('button_ready.png')
        b = DirectButton(geom = (buttonReady,
                                 makeGeom('button_click.png'),
                                 makeGeom('button_rollover.png'),
                                 buttonReady),
                          relief = None)
        b.reparentTo(pixel2d)
        b.hide()
        b.setPos(base.win.getXSize()/2, 0, -base.win.getYSize()/2)
        b.setScale(1, 1, 1)
        b.bind(DirectGuiGlobals.ACCEPT, eventHandler, ['accept'])
        b.bind(DirectGuiGlobals.ACCEPTFAILED, eventHandler, ['accept failed'])
        b.bind(DirectGuiGlobals.ADJUST, eventHandler, ['adjust'])
        b.bind(DirectGuiGlobals.B1CLICK, eventHandler, ['b1click'])
        b.bind(DirectGuiGlobals.B1PRESS, eventHandler, ['b1press'])
        b.bind(DirectGuiGlobals.B1RELEASE, eventHandler, ['b1release'])
        b.bind(DirectGuiGlobals.B2CLICK, eventHandler, ['b2click'])
        b.bind(DirectGuiGlobals.B2PRESS, eventHandler, ['b2press'])
        b.bind(DirectGuiGlobals.B2RELEASE, eventHandler, ['b2release'])
        b.bind(DirectGuiGlobals.B3CLICK, eventHandler, ['b3click'])
        b.bind(DirectGuiGlobals.B3PRESS, eventHandler, ['b3press'])
        b.bind(DirectGuiGlobals.B3RELEASE, eventHandler, ['b3release'])
        b.bind(DirectGuiGlobals.ENTER, eventHandler, ['enter'])
        b.bind(DirectGuiGlobals.EXIT, eventHandler, ['exit'])
        b.bind(DirectGuiGlobals.WITHIN, eventHandler, ['within'])
        b.bind(DirectGuiGlobals.WITHOUT, eventHandler, ['without'])
        b.bind(DirectGuiGlobals.CURSORMOVE, eventHandler, ['cursormove'])
        # b['frameSize'] = (3, 3, 3, 3)
        '''

    @classmethod
    def getInstance(cls):
        if cls.instance == None:
            cls.instance = World()
        return cls.instance

    def _saveLayout(self):
        if self.modButtons.isDown(KeyboardButton.control()):
            self.modButtons.buttonUp(KeyboardButton.control())
            self.modButtons.buttonUp(KeyboardButton.asciiKey('s'))
            filename = asksaveasfilename(filetypes=[('plist files', '*.plist')])
            if filename:
                self.layout.save(filename)
                AppPreferences.set('last_layout', filename)

    def _setFreq(self):
        #TODO: Check pinger selected

        pinger = None
        for element in self.layout.elements:
            if element.getTypeName() == "Pinger" and element.isSelected():
                pinger = element
                break

        if pinger is None:
            return

        newfreq = askinteger("Set Pinger Frequency", "Set this pinger to which frequency? (in Hz)", initialvalue=pinger.pinger_frequency, minvalue=10000, maxvalue=50000)
        if newfreq is None:
            print "No frequency specified, aborting"
            return

        pinger.pinger_frequency = newfreq
        print "Frequency of pinger set to %d Hz" % newfreq


    def _openLayout(self):
        if self.modButtons.isDown(KeyboardButton.control()):
            self.modButtons.buttonUp(KeyboardButton.control())
            self.modButtons.buttonUp(KeyboardButton.asciiKey('o'))
            filename = askopenfilename(filetypes=[('plist files', '*.plist')])
            if filename:
                if self.layout:
                    NodePath(self.layout).detachNode()
                self.layout = MissionLayout.loadLayout(filename)
                render.attachNewNode(self.layout)
                AppPreferences.set('last_layout', filename)
コード例 #54
0
ファイル: holonomicorient.py プロジェクト: zhengzh/omg-tools
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'syslimit': 'norm_inf'})
     self.options.update({'reg_type': None})  # no reg by default
コード例 #55
0
 def __init__(self, v_type, reg_number):
     self._vechile = Vehicle(v_type, reg_number)
コード例 #56
0
ファイル: trailer.py プロジェクト: meco-group/omg-tools
 def set_default_options(self):
     Vehicle.set_default_options(self)
コード例 #57
0
ファイル: frogger.py プロジェクト: danilopag/Frogger
        turtle.append(Turtle(arena, x, int((i * 40) + 100)))
        turtle.append(Turtle(arena, x + 30, int((i * 40) + 100)))
        turtle.append(Turtle(arena, x + 60, int((i * 40) + 100)))
        x = randint(350, 480)
        turtle.append(Turtle(arena, x, int((i * 40) + 100)))
        turtle.append(Turtle(arena, x + 30, int((i * 40) + 100)))
        turtle.append(Turtle(arena, x + 60, int((i * 40) + 100)))
    else:
        x = randint(100, 250)
        crocodile.append(Crocodile(arena, x, int((i * 40) + 100)))
        x = randint(350, 480)
        crocodile.append(Crocodile(arena, x, int((i * 40) + 100)))
for i in range(0, 5):
    if (i % 2 == 1):
        veicoli.append(
            Vehicle(arena, randint(100, 280), int((i * 30) + 280), 0, i)
        )  #paramentro x porto in un range da 150 a 480 (+ 20% del canvas) in modo da permettere alla rana di muoversi almeno nei primi momenti di gioco
        veicoli.append(
            Vehicle(arena, randint(350, 480), int((i * 30) + 280), 0, i))
        veicoli.append(
            Vehicle(arena, randint(530, 680), int((i * 30) + 280), 0, i))
    else:
        veicoli.append(
            Vehicle(arena, randint(100, 280), int((i * 30) + 280), 1, i))
        veicoli.append(
            Vehicle(arena, randint(350, 480), int((i * 30) + 280), 1, i))
        veicoli.append(
            Vehicle(arena, randint(530, 680), int((i * 30) + 280), 1, i))
frog.append(Frog(arena, 250, 440))
fiume = Fiume(arena, 0, 80)
land.append(Land(arena, 0, 0, 600, 44))
コード例 #58
0
ファイル: holonomic.py プロジェクト: jgillis/omg-tools
 def set_default_options(self):
     Vehicle.set_default_options(self)
     self.options.update({'syslimit': 'norm_inf'})
コード例 #59
0
ファイル: crosstrek.py プロジェクト: sambirky21/garys_garage
 def __init__(self):
     Vehicle.__init__(self, "Crosstrek", "Subaru", 60, 4)
     ElectricPowered.__init__(self, 40)
     GasPowered.__init__(self, 6)