Esempio n. 1
0
    def execute(self, context):
        global pd

        for obj in context.selected_objects:
            for action_index, action in enumerate(pc.TempPathContainer()):
                if obj.name_full == action._arrow:
                    # Inserta una nueva action en medio de la pose seleccionada y la anterior
                    p0 = action.p0
                    p1 = action.p1
                    xm, ym = (p1.x + p0.x)/2. , (p1.y + p0.y)/2.
                    med_pose = path.Pose(xm, ym, p0.z, p0.alpha, p0.beta, p0.gamma)

                    # Crea un nuevo action desde la pose añadida hasta la pose seleccionada
                    next_action = path.Action(med_pose, p1)
                    next_action.draw_annotation(context)

                    # Se traslada la action seleccionada al punto intermedio
                    # La pose de este action será el nuevo punto intermedio
                    action.move(med_pose)
                    action.del_annotation()

                    pc.TempPathContainer().insert(action_index + 1, next_action)

                    # Cambia pathdrawer
                    pd.current_action = action
                    pd.next_action = next_action

                    cl.CursorListener.set_pose(action.p1)
                    cl.CursorListener.select_cursor()
                    context.scene.isModifying = True

                    return {'FINISHED'}
        return {'FINISHED'}
Esempio n. 2
0
def parse_data(json_poses):
    try:
        poses = []
        for p in json_poses['poses']:
            poses.append(
                path.Pose(p['x'], p['y'], p['z'], p['rx'], p['ry'], p['rz']))
    except Exception as e:
        return None
    return poses
Esempio n. 3
0
 def unpack(list_packet):
     """
     Apply a deserialization method to unpack
     """
     assert len(list_packet) == 5, "Error: No valid trace packet"
     assert int(
         list_packet[1]) == 3, "Error: byte_packet is not a ack packet"
     pose = path.Pose(float(list_packet[2]), float(list_packet[3]), 0, 0, 0,
                      float(list_packet[4]))
     return datapacket.TracePacket(int(list_packet[0]), pose)
Esempio n. 4
0
    def unpack(list_packet):
        """
        Apply a deserialization method to unpack
        """
        assert len(list_packet) == 5, "Error: No valid trace packet"
        assert list_packet[1] == 3, "Error: list_packet is not a trace packet"

        from math import radians
        pose = path.Pose(list_packet[2], list_packet[3], 0.0, 0.0, 0.0,
                         radians(list_packet[4]))
        return datapacket.TracePacket(list_packet[0], pose)
Esempio n. 5
0
 def unpack(list_packet):
     """
     Apply a deserialization method to unpack
     """
     assert len(
         list_packet
     ) == 5, "Error: No valid reached pose packet " + "len= " + str(
         len(list_packet))
     assert list_packet[
         1] == 11, "Error: list_packet is not a reached pose packet"
     x = list_packet[2]
     y = list_packet[3]
     tetha = list_packet[4]
     from math import radians
     pose = path.Pose(x, y, 0, 0, 0, radians(tetha))
     return datapacket.ReachedPosePacket(list_packet[0], pose)
Esempio n. 6
0
 def unpack(list_packet):
     assert len(
         list_packet) == 9, "Error: no valid AddUltrasoundBeaconPacket"
     assert list_packet[
         1] == 15, "Error: packet is not an AddUltrasoundBeaconPacket"
     pid = list_packet[0]
     ptype = list_packet[1]
     beacon_id = list_packet[2]
     x = list_packet[3]
     y = list_packet[4]
     z = list_packet[5]
     a = list_packet[6]
     b = list_packet[7]
     g = list_packet[8]
     pose_beacon = path.Pose(x, y, z, a, b, g)
     return datapacket.AddUltrasoundBeaconPacket(pid, beacon_id,
                                                 pose_beacon)