def _set_eye_xy_front_pos(self, x, y):
        # Units for X and Y real are "height of the eye" = 1. Scaling out so
        # that we can tweak it more here than in touch and can define a reasonable
        # addressable area
        xr = config.get("xy_scale")["x"] * x
        yr = config.get("xy_scale")["y"] * (y + 0.5)

        # y gets weird because +y is down
        yr = 1.0 - yr

        xyz_pos = [xr, 10.0, yr]

        print "in=(%f,%f) xyz = %s" % (x,y, str(xyz_pos))

        self.p_eye_pos = eyes.xyz_to_pnt(xyz_pos, True)
        self._notify_eye_changed(True)

        self.b_eye_pos = eyes.xyz_to_pnt(xyz_pos, False)
        self._notify_eye_changed(False)
Exemple #2
0
    def store_position(self):
        data = cherrypy.request.json

        x = data.get("x_pos")
        y = data.get("y_pos")
        z = data.get("z_pos")

        is_xyz = data.get("pos_is_xyz") or False

        which = data.get("position")
        eye_positions = config.get("eye_positions")

        if is_xyz:
            xyz_pos = [x, y, z]
            pnt_p = eyes.xyz_to_pnt(xyz_pos, True)
            pnt_b = eyes.xyz_to_pnt(xyz_pos, False)
        else:
            pnt_p = [x, y]
            pnt_b = [x, y]

        if which == "disco":
            # Don't need to look at left / right. Disco is only left
            p = eye_positions["disco"]
            p[0] = pnt_p

        elif which == "headlights":
            p = eye_positions["headlights"]
            p[0] = pnt_p
            p[1] = pnt_b

        try:
            config.save()
        except Exception:
            return {"ok": False, "msg": "Couldn't save the positon"}

        return {"ok": True}
Exemple #3
0
    def store_position(self):
        data = cherrypy.request.json

        x = data.get("x_pos")
        y = data.get("y_pos")
        z = data.get("z_pos")

        is_xyz = data.get("pos_is_xyz") or False

        which = data.get("position")
        eye_positions = config.get("eye_positions")

        if is_xyz:
            xyz_pos = [x,y,z]
            pnt_p = eyes.xyz_to_pnt(xyz_pos, True)
            pnt_b = eyes.xyz_to_pnt(xyz_pos, False)
        else:
            pnt_p = [x,y]
            pnt_b = [x,y]

        if which == "disco":
            # Don't need to look at left / right. Disco is only left
            p = eye_positions["disco"]
            p[0] =pnt_p

        elif which == "headlights":
            p = eye_positions["headlights"]
            p[0] = pnt_p
            p[1] = pnt_b

        try:
            config.save()
        except Exception:
            return {"ok": False, "msg": "Couldn't save the positon"}

        return {"ok": True}