Пример #1
0
    def getAisStr(self, mssi_, LatLon):
        # status
        # 0 - undarway
        # 1 - anchore
        # 2 - not under command
        # 3 - restricted movability
        # 4 - contrained
        # 5 - moored
        # 6 - aground
        # 7 - engaged in finish
        # 8 - under way sailing
        # 9 - high speed craft
        # 10 - wing in ground effect
        # 11 - power driven vessel towing
        # 12 - power driven vessel pushing
        # 13 - reserved 13
        # 15 - undefined

        a = aislib.AISPositionReportMessage(mmsi=mssi_,
                                            pa=1,
                                            lon=int((LatLon.lon) * 60 * 10000),
                                            lat=int((LatLon.lat) * 60 * 10000),
                                            status=15,
                                            ts=30,
                                            raim=0,
                                            comm_state=0)
        ais = aislib.AIS(a)
        #print("ais",ais)
        p = ais.build_payload(False)
        #print("payload",p)
        return p
 def aisCallback(self, data):
     rospy.loginfo(data)
     for ship in data.ships:
         aisreport = ais.AISPositionReportMessage(
             mmsi=ship.ID,
             lon=int(ship.lon * 600000),
             lat=int(ship.lat * 600000),
             heading=int(headingToBearingDegrees(ship.headingDegrees)) %
             360)
         aismsg = ais.AIS(aisreport)
         sock.sendto(aismsg.build_payload(), (UDP_IP, UDP_PORT))
Пример #3
0
def main():
    ship = 'knossos'
    if len(sys.argv) > 1: ship = sys.argv[1]
    try:
        print ships[ship][2]
    except:
        pass
    f = open(ships[ship][1])
    l = f.readline()
    for l in f:
        try:
            fields = l.split('\t')
            lat = float(fields[3])
            lon = float(fields[4])
            sog = float(fields[2])
            cog = float(fields[5])
        except ValueError:
            print >> sys.stderr, l,
            continue
        aismsg = aislib.AISPositionReportMessage(mmsi=ships[ship][0],
                                                 pa=1,
                                                 lon=int((lon) * 60 * 10000),
                                                 lat=int((lat) * 60 * 10000),
                                                 heading=int(cog),
                                                 sog=int(sog * 10),
                                                 cog=int(cog * 10),
                                                 status=0,
                                                 ts=60,
                                                 raim=1,
                                                 comm_state=82419)
        ais = aislib.AIS(aismsg)
        payload = ais.build_payload(False)
        print payload
        time.sleep(2)
        #   print "nav status: %d" % aismsg.get_attr("status")

        aismsg2 = ais.decode(payload)
        ais2 = aislib.AIS(aismsg2)
        payload2 = ais2.build_payload(False)


#   print payload2
#   print "nav status: %d" % aismsg2.get_attr("status")

#print aismsg.id
#print aismsg.repeat

#bitstr = aismsg.build_bitstream()
#print bitstr.bin
# #print bitstr.len
    f.close()
Пример #4
0
 def as_AIS_pos_report(self):
     # return an NMEA encoded position report
     
     aismsg = aislib.AISPositionReportMessage( \
         mmsi = self.vessel.mmsi, \
         status = 8, \
         sog = int(self.speed*10.0), \
         pa = 1, \
         lon = int(self.pos.x * 600000),
         lat = int(self.pos.y * 600000),
         # lon = (25*60+00)*10000,
         # lat = (35*60+30)*10000,
         cog = int(self.course * 10.0),
         ts = 40,
         raim = 1,
         comm_state = 82419
     )
     ais = aislib.AIS(aismsg)
     payload = ais.build_payload(False)
     return payload
Пример #5
0
from __future__ import print_function

import aislib

#
# Tests for Message Type 1
#

print('Tests for Message Type 1')

aismsg = aislib.AISPositionReportMessage(mmsi=237772000,
                                         status=8,
                                         sog=75,
                                         pa=1,
                                         lon=(25 * 60 + 00) * 10000,
                                         lat=(35 * 60 + 30) * 10000,
                                         cog=2800,
                                         ts=40,
                                         raim=1,
                                         comm_state=82419)
ais = aislib.AIS(aismsg)
payload = ais.build_payload(False)
print(payload)  # !AIVDM,1,1,,A,13RhLp801;QjL>0DD38:t?w@2D7k,0*3E
aismsg2 = ais.decode(payload)
ais2 = aislib.AIS(aismsg2)
payload2 = ais2.build_payload(False)
assert payload == payload2

#
# Tests for Message Type 2 (payload format as type 1)
#
Пример #6
0
    ship_name = "SEABOT"
    if (imei == 981770):
        ship_name += "1"
    elif (imei == 396100):
        ship_name += "2"
    elif (imei == 392110):
        ship_name += "3"

    # current_waypoint = data_yaml['current_waypoint']
    longitude, latitude = transform(inProj, outProj, east, north)
    # print(longitude, latitude)
    aismsg1 = aislib.AISPositionReportMessage(
        mmsi=imei,
        sog=min(int(round(data_yaml['gnss_speed'] * 19.4384)),
                1022),  # vitesse en dixieme de noeuds
        pa=1,
        lat=int(round(latitude * 60e4)),
        lon=int(round(longitude * 60e4)),
        cog=min(int(data_yaml['gnss_heading'] * 10.), 3599)  #, # max 3600
        # ts = msg_date.second
    )

    ais1 = aislib.AIS(aismsg1)
    payload1 = ais1.build_payload(False)
    ser.write(payload1 + '\n')

    aismsg2 = aislib.AISStaticAndVoyageReportMessage(shipname=ship_name,
                                                     mmsi=imei,
                                                     epfd=3,
                                                     month=msg_date.month,
                                                     day=msg_date.day,
                                                     hour=msg_date.hour,