Ejemplo n.º 1
0
 def __init__(self, mpstate):
     super(GPSInputModule, self).__init__(mpstate, "GPSInput", "GPS_INPUT message support")
     self.add_command('GPSInput.port', self.cmd_port, 'Port selection', ['<25100>'])
     self.data = {
         'time_usec' : 0,                        # (uint64_t) Timestamp (micros since boot or Unix epoch)
         'gps_id' : 0,                           # (uint8_t) ID of the GPS for multiple GPS inputs
         'ignore_flags' : self.IGNORE_FLAG_ALL,  # (uint16_t) Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum). All other fields must be provided.
         'time_week_ms' : 0,                     # (uint32_t) GPS time (milliseconds from start of GPS week)
         'time_week' : 0,                        # (uint16_t) GPS week number
         'fix_type' : 0,                         # (uint8_t) 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK
         'lat' : 0,                              # (int32_t) Latitude (WGS84), in degrees * 1E7
         'lon' : 0,                              # (int32_t) Longitude (WGS84), in degrees * 1E7
         'alt' : 0,                              # (float) Altitude (AMSL, not WGS84), in m (positive for up)
         'hdop' : 0,                             # (float) GPS HDOP horizontal dilution of position in m
         'vdop' : 0,                             # (float) GPS VDOP vertical dilution of position in m
         'vn' : 0,                               # (float) GPS velocity in m/s in NORTH direction in earth-fixed NED frame
         've' : 0,                               # (float) GPS velocity in m/s in EAST direction in earth-fixed NED frame
         'vd' : 0,                               # (float) GPS velocity in m/s in DOWN direction in earth-fixed NED frame
         'speed_accuracy' : 0,                   # (float) GPS speed accuracy in m/s
         'horiz_accuracy' : 0,                   # (float) GPS horizontal accuracy in m
         'vert_accuracy' : 0,                    # (float) GPS vertical accuracy in m
         'satellites_visible' : 0                # (uint8_t) Number of satellites visible.
     }
     
     self.BUFFER_SIZE = 4096
     self.ip="127.0.0.1"
     self.portnum = 25100
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind((self.ip, self.portnum))
     self.port.setblocking(0)
     mavutil.set_close_on_exec(self.port.fileno())
     print("Listening for GPS Input packets on UDP://%s:%s" % (self.ip, self.portnum))
Ejemplo n.º 2
0
 def __init__(self,
              device,
              baud=None,
              input=True,
              broadcast=False,
              source_system=255,
              use_native=mavutil.default_native):
     a = device.split(':')
     if len(a) != 2:
         print("UDP ports must be specified as host:port")
         sys.exit(1)
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.udp_server = input
     self.broadcast = False
     self.addresses = set()
     if input:
         self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         self.port.bind((a[0], int(a[1])))
     else:
         self.destination_addr = (a[0], int(a[1]))
         if broadcast:
             self.port.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
             self.broadcast = True
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     mavutil.mavfile.__init__(self,
                              self.port.fileno(),
                              device,
                              source_system=source_system,
                              input=input,
                              use_native=use_native)
Ejemplo n.º 3
0
 def __init__(self, mpstate):
     super(GPSInputModule, self).__init__(mpstate, "GPSInput", "GPS_INPUT message support")
     self.add_command('GPSInput.port', self.cmd_port, 'Port selection', ['<25100>'])
     self.data = {
         'time_usec' : 0,                        # (uint64_t) Timestamp (micros since boot or Unix epoch)
         'gps_id' : 0,                           # (uint8_t) ID of the GPS for multiple GPS inputs
         'ignore_flags' : self.IGNORE_FLAG_ALL,  # (uint16_t) Flags indicating which fields to ignore (see GPS_INPUT_IGNORE_FLAGS enum). All other fields must be provided.
         'time_week_ms' : 0,                     # (uint32_t) GPS time (milliseconds from start of GPS week)
         'time_week' : 0,                        # (uint16_t) GPS week number
         'fix_type' : 0,                         # (uint8_t) 0-1: no fix, 2: 2D fix, 3: 3D fix. 4: 3D with DGPS. 5: 3D with RTK
         'lat' : 0,                              # (int32_t) Latitude (WGS84), in degrees * 1E7
         'lon' : 0,                              # (int32_t) Longitude (WGS84), in degrees * 1E7
         'alt' : 0,                              # (float) Altitude (AMSL, not WGS84), in m (positive for up)
         'hdop' : 0,                             # (float) GPS HDOP horizontal dilution of position in m
         'vdop' : 0,                             # (float) GPS VDOP vertical dilution of position in m
         'vn' : 0,                               # (float) GPS velocity in m/s in NORTH direction in earth-fixed NED frame
         've' : 0,                               # (float) GPS velocity in m/s in EAST direction in earth-fixed NED frame
         'vd' : 0,                               # (float) GPS velocity in m/s in DOWN direction in earth-fixed NED frame
         'speed_accuracy' : 0,                   # (float) GPS speed accuracy in m/s
         'horiz_accuracy' : 0,                   # (float) GPS horizontal accuracy in m
         'vert_accuracy' : 0,                    # (float) GPS vertical accuracy in m
         'satellites_visible' : 0                # (uint8_t) Number of satellites visible.
     }
     
     self.BUFFER_SIZE = 4096
     self.ip="127.0.0.1"
     self.portnum = 25100
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind((self.ip, self.portnum))
     self.port.setblocking(0)
     mavutil.set_close_on_exec(self.port.fileno())
     print "Listening for GPS Input packets on UDP://%s:%s" % (self.ip, self.portnum)
    def __init__(self, mpstate):
        super(DepthOutputModule, self).__init__(mpstate, "DepthOutput",
                                                "Depth output support")
        self.add_command('DepthOutput.port', self.cmd_port, 'Port selection',
                         ['<25102>'])
        self.add_command('DepthOutput.depthSource', self.cmd_depth_source,
                         'Depth source selection', ['<bar30|filtered>'])
        self.add_command('DepthOutput.tempSource', self.cmd_temp_source,
                         'Temperature source selection', ['<sp2|sp3>'])

        self.last_update = 0
        self.depth_source = 'bar30'
        self.temp_source = 'sp2'

        self.data = {
            'depth': 0,  # Depth in meters
            'temp': 0  # Water temperature in degrees Celsius
        }

        self.ip = "0.0.0.0"
        self.portnum = 25102
        self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        mavutil.set_close_on_exec(self.port.fileno())
        print "Outputting depth on UDP://%s:%s" % (self.ip, self.portnum)
Ejemplo n.º 5
0
 def __init__(self, mpstate):
     super(DGPSModule, self).__init__(mpstate, "DGPS", "DGPS injection support")
     self.portnum = 13320
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind(("127.0.0.1", self.portnum))
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
 def __init__(self, mpstate):
     super(DGPSModule, self).__init__(mpstate, "DGPS", "DGPS injection support")
     self.portnum = 13320
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind(("127.0.0.1", self.portnum))
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     print ("Listening for DGPS packets on UDP://%s:%s" % ("127.0.0.1", self.portnum))
Ejemplo n.º 7
0
 def __init__(self, mpstate):
     super(DGPSModule, self).__init__(mpstate, "DGPS", "DGPS injection support for SBP/RTCP/UBC")
     self.portnum = 13320
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind(("127.0.0.1", self.portnum))
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     self.inject_seq_nr = 0
     print "DGPS: Listening for RTCM packets on UDP://%s:%s" % ("127.0.0.1", self.portnum)
Ejemplo n.º 8
0
def init(_mpstate):
    '''initialise module'''
    global mpstate
    mpstate = _mpstate
    state = dgps_state()
    mpstate.dgps_state = state

    state.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    state.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    state.port.bind(("127.0.0.1", state.portnum))
    mavutil.set_close_on_exec(state.port.fileno())
    state.port.setblocking(0)
Ejemplo n.º 9
0
def init(_mpstate):
    '''initialise module'''
    global mpstate
    mpstate = _mpstate
    state = dgps_state()
    mpstate.dgps_state = state

    state.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    state.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    state.port.bind(("127.0.0.1", state.portnum))
    mavutil.set_close_on_exec(state.port.fileno())
    state.port.setblocking(0)
    def cmd_port(self, args):
        'handle port selection'
        if len(args) != 1:
            print("Usage: port <number>")
            return

        self.port.close()
        self.portnum = int(args[0])
        self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        mavutil.set_close_on_exec(self.port.fileno())
        print "Outputting depth on UDP://%s:%s" % (self.ip, self.portnum)
Ejemplo n.º 11
0
 def cmd_port(self, args):
     """Handle port selection."""
     if len(args) != 1:
         print("Usage: port <number>")
         return
     self.port.close()  # close current port
     self.portnum = int(args[0])
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind((self.ip, self.portnum))  # bind new port
     self.port.setblocking(0)
     mavutil.set_close_on_exec(self.port.fileno())
     print("Listening for INPUT packets on UDP://%s:%s" %
           (self.ip, self.portnum))
Ejemplo n.º 12
0
 def cmd_port(self, args):
     'handle port selection'
     if len(args) != 1:
         print("Usage: port <number>")
         return
     
     self.port.close()
     self.portnum = int(args[0])
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind((self.ip, self.portnum))
     self.port.setblocking(0)
     mavutil.set_close_on_exec(self.port.fileno())
     print "Listening for GPS INPUT packets on UDP://%s:%s" % (self.ip, self.portnum)
Ejemplo n.º 13
0
 def __init__(self, mpstate):
     super(DGPSModule,
           self).__init__(mpstate, "DGPS",
                          "DGPS injection support for SBP/RTCP/UBC")
     #self.ipaddress = 192.168.42.1
     #self.ipaddress = 127.0.0.1
     self.portnum = 9000
     #self.portnum = 13320
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind(("0.0.0.0", self.portnum))
     #self.port.bind((self.ipaddress, self.portnum))
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     self.inject_seq_nr = 0
     print("DGPS_dove: Listening for RTCM packets on ://%s:%s" %
           ("127.0.0.1", self.portnum))
Ejemplo n.º 14
0
 def __init__(self, mpstate):
     super(position_ft_sensor_module, self).__init__(
         mpstate, "position_ft_sensor", "position ft sensor support"
     )  # the callable module name is defined in the second init arg
     self.add_command("port", self.cmd_port, "port selection",
                      ["<5006>"])  # UDP port selection
     self.last_time = time.clock()
     # UDP setup
     self.ip = "127.0.0.1"  # localhost
     self.portnum = 5010  # default UDP port
     self.buffer_size = 1024
     self.port = socket.socket(
         socket.AF_INET,  # internet
         socket.SOCK_DGRAM)  # UDP
     self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     self.port.bind((self.ip, self.portnum))  # bind port
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     print("Listening for input packets on UDP://%s:%s" %
           (self.ip, self.portnum))
Ejemplo n.º 15
0
 def __init__(self, device, baud=None, input=True, broadcast=False, source_system=255, use_native=mavutil.default_native):
     a = device.split(':')
     if len(a) != 2:
         print("UDP ports must be specified as host:port")
         sys.exit(1)
     self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     self.udp_server = input
     self.broadcast = False
     self.addresses = set()
     if input:
         self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
         self.port.bind((a[0], int(a[1])))
     else:
         self.destination_addr = (a[0], int(a[1]))
         if broadcast:
             self.port.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
             self.broadcast = True
     mavutil.set_close_on_exec(self.port.fileno())
     self.port.setblocking(0)
     mavutil.mavfile.__init__(self, self.port.fileno(), device, source_system=source_system, input=input, use_native=use_native)
Ejemplo n.º 16
0
    def connect_dgps(self):
        if self.port is not None:
            self.port.close()
            print("Restarting DGPS")
        self.port = None

        try:
            address = (self.dgps_settings.host, self.dgps_settings.port)
            if self.dgps_settings.type == 'tcp_client':
                self.port = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                self.port.connect(address)
                print("DGPS: Connecting for RTCM packets to TCP://%s:%s" %
                      address)
            elif self.dgps_settings.type == 'udp_client':
                self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                self.port.connect(address)
                print("DGPS: Connecting for RTCM packets to UDP://%s:%s" %
                      address)
            elif self.dgps_settings.type == 'udp_host':
                self.port = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
                self.port.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                self.port.bind(address)
                print("DGPS: Listening for RTCM packets on UDP://%s:%s" %
                      address)
            else:
                print("DGPS: Unknown connection type: %s" %
                      self.dgps_settings.type)
                return False

            mavutil.set_close_on_exec(self.port.fileno())
            self.port.setblocking(0)
        except Exception as e:
            print("DGPS: Error starting DGPS: %s" % str(e))
            self.port = None
            return False

        self.inject_seq_nr = 0
        self.reset_stats()
        return True