Exemplo n.º 1
0
    def _DistributedHouse__setupFloorMat(self):
        if self.floorMat:
            self.floorMat.removeNode()
            del self.floorMat
            self.floorMat = None

        mat = self.house.find('**/mat')
        mat.setColor(0.40000000000000002, 0.35699999999999998,
                     0.25900000000000001, 1.0)
        color = HouseGlobals.houseColors[self.housePosInd]
        matText = TextNode('matText')
        matText.setTextColor(color[0], color[1], color[2], 1)
        matText.setAlign(matText.ACenter)
        matText.setFont(ToontownGlobals.getSignFont())
        xScale = 1.0
        numLines = 0
        if self.name == '':
            houseName = ''
        else:
            (prettyName, numLines,
             xScale) = self._DistributedHouse__getPrettyName(9)
            houseName = Localizer.AvatarsHouse % Localizer.GetPossesive(
                prettyName)
        matText.setText(houseName)
        self.matText = matText
        mat_origin = self.house.find('**/mat_origin')
        pos = mat_origin.getPos()
        mat_origin.setPosHpr(pos[0] - 0.14999999999999999 * numLines, pos[1],
                             pos[2], 90, -90, 0)
        self.floorMat = mat_origin.attachNewNode(self.matText)
        self.floorMat.setPos(0, -0.025000000000000001, 0)
        self.floorMat.setScale(0.5 * xScale)
Exemplo n.º 2
0
    def _DistributedHouse__setupNamePlate(self):
        self.notify.debug('__setupNamePlate')
        if self.namePlate:
            self.namePlate.removeNode()
            del self.namePlate
            self.namePlate = None

        nameText = TextNode('nameText')
        r = self.randomGenerator.random()
        g = self.randomGenerator.random()
        b = self.randomGenerator.random()
        nameText.setTextColor(r, g, b, 1)
        nameText.setAlign(nameText.ACenter)
        nameText.setFont(ToontownGlobals.getSignFont())
        xScale = 1.0
        numLines = 0
        if self.name == '':
            houseName = ''
        else:
            (prettyName, numLines,
             xScale) = self._DistributedHouse__getPrettyName(16)
            houseName = Localizer.AvatarsHouse % Localizer.GetPossesive(
                prettyName)
        nameText.setText(houseName)
        self.nameText = nameText
        sign_origin = self.house.find('**/sign_origin')
        pos = sign_origin.getPos()
        sign_origin.setPosHpr(pos[0], pos[1],
                              pos[2] + 0.14999999999999999 * numLines, 90, 0,
                              0)
        self.namePlate = sign_origin.attachNewNode(self.nameText)
        self.namePlate.setPos(0, -0.050000000000000003, 0)
        self.namePlate.setScale(xScale)
def calc_truth_weights_terrain(map_file,
                               camera_path,
                               weights_file,
                               truth_file,
                               frames=10):
    '''
	Test observation and measurement model by calculating particle weights of ground truth
	observations.

	Args:
		map_file: path to file of the global map to use
		camera_path: path to camera images from the flight
		weights_file: file with weights for the learning model
		truth_file: file with ground truth trajectory
		frames: plot this many observations
	'''

    localizer = Localizer(map_file,
                          camera_path,
                          weights_file,
                          frames,
                          num_particles=1)
    processor = localizer.get_processor()
    truth = processor.read_truth(truth_file, all_dims=True)

    brief_weights = []
    for i in range(frames):
        x, y, z, angle = truth[i, 0], truth[i, 1], truth[i, 2], truth[i, 3]
        frame = processor.get_camera_image(i + 2)
        frame = processor.resize_to_scale(frame, z)
        frame_pred = processor.construct_prediction(frame)
        particle_pred = processor.get_particle_area(x,
                                                    y,
                                                    angle,
                                                    w=frame_pred.shape[1],
                                                    h=frame_pred.shape[0])
        brief_weight = calc_weight_brief(frame_pred, particle_pred)
        brief_weights.append(brief_weight)

    brief_weights = np.array(brief_weights)
    return brief_weights
Exemplo n.º 4
0
 def __setupNametag(self):
     if self.nametag:
         self.clearNametag()
     if self.name == '':
         houseName = ''
     else:
         houseName = Localizer.AvatarsHouse % Localizer.GetPossesive(
             self.name)
     self.nametag = NametagGroup()
     self.nametag.setFont(ToontownGlobals.getSignFont())
     self.nametag.setContents(Nametag.CName)
     self.nametag.setColorCode(NametagGroup.CCHouseBuilding)
     self.nametag.setActive(0)
     self.nametag.setAvatar(self.house)
     self.nametag.setObjectCode(self.doId)
     self.nametag.setName(houseName)
     self.nametag.manage(toonbase.marginManager)
Exemplo n.º 5
0
import Localizer

localizer = Localizer.Localizer()

quit = False
while quit == False:

    print("hello, it is the console")
    print("(1) Initilization")
    print("(2) Calibration")
    print("(3) Display data")
    print("(4) Get status")
    print("(5) Get position")
    print("(0) Quit")
    print("(10) Debug")
    input_key = input("please press one key \n")

    if input_key == "1":
        localizer.magneto.set_config()
    elif input_key == "2":
        localizer.magneto.calibration()
    elif input_key == "3":
        localizer.magneto.disp_data()
    elif input_key == "4":
        localizer.magneto.get_status()
    elif input_key == "5":
        localizer.get_distance()
    elif input_key == "10":
        localizer.get_debug()
    elif input_key == "0":
        quit = True
    def enter(self):
        ShtikerPage.ShtikerPage.enter(self)

        try:
            zone = toonbase.tcr.playGame.getPlace().getZoneId()
        except:
            zone = 0

        if zone and ZoneUtil.isPlayground(zone) or self.book.safeMode:
            self.safeZoneButton.hide()
        else:
            self.safeZoneButton.show()
        if toonbase.localToon.estate != None and toonbase.tcr.playGame.estateLoader.atMyEstate(
        ) or self.book.safeMode:
            self.goHomeButton.hide()
        elif toonbase.housingEnabled:
            self.goHomeButton.show()

        if toonbase.tcr.playGame.hood == None and toonbase.tcr.playGame.estateLoader != None:
            if toonbase.tcr.playGame.estateLoader.atMyEstate():
                self.hoodLabel['text'] = Localizer.MapPageYouAreAtHome
                self.hoodLabel.show()
            else:
                avatar = toonbase.tcr.identifyAvatar(
                    toonbase.tcr.playGame.estateLoader.estateOwnerId)
                if avatar:
                    avName = avatar.getName()
                    self.hoodLabel[
                        'text'] = Localizer.MapPageYouAreAtSomeonesHome % Localizer.GetPossesive(
                            avName)
                    self.hoodLabel.show()

        elif zone:
            hoodName = ToontownGlobals.hoodNameMap.get(
                ZoneUtil.getHoodId(zone), ('', ''))[1]
            streetName = ToontownGlobals.StreetNames.get(
                ZoneUtil.getBranchZone(zone), ('', ''))[1]
            if hoodName:
                self.hoodLabel['text'] = Localizer.MapPageYouAreHere % (
                    hoodName, streetName)
                self.hoodLabel.show()
            else:
                self.hoodLabel.hide()
        else:
            self.hoodLabel.hide()
        if toonbase.localToon.teleportCheat:
            safeZonesVisited = ToontownGlobals.Hoods
        else:
            safeZonesVisited = toonbase.localToon.safeZonesVisited
        hoodsAvailable = toonbase.tcr.hoodMgr.getAvailableZones()
        hoodVisibleList = PythonUtil.intersection(safeZonesVisited,
                                                  hoodsAvailable)
        if toonbase.localToon.teleportCheat:
            hoodTeleportList = hoodVisibleList
        else:
            hoodTeleportList = toonbase.localToon.getTeleportAccess()
        for hood in self.allZones:
            label = self.labels[self.allZones.index(hood)]
            clouds = self.clouds[self.allZones.index(hood)]
            if not (self.book.safeMode) and hood in hoodVisibleList:
                label.show()
                for cloud in clouds:
                    cloud.hide()

                fullname = toonbase.tcr.hoodMgr.getFullnameFromId(hood)
                if hood in hoodTeleportList:
                    text = Localizer.MapPageGoTo % fullname
                    label['text'] = ('', text, text)
                else:
                    label['text'] = ('', fullname, fullname)
            else:
                label.hide()
                for cloud in clouds:
                    cloud.show()

        return None
def Sense():
    cap = cv2.VideoCapture(-1)
    turn_offset = 1  #LaneDetection.detectLane(cap)
    in_intersection = Localizer.detect(cap)
    return turn_offset, in_intersection