mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-03 04:03:59 -04:00
SITL: add SIM_AIS
This commit is contained in:
parent
60db4c1a62
commit
ce7a93ab6c
75
libraries/SITL/SIM_AIS.cpp
Normal file
75
libraries/SITL/SIM_AIS.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
Dump logged AIS data to the serial port
|
||||
./Tools/autotest/sim_vehicle.py -v Rover -A --uartF=sim:AIS --custom-location 51.58689798356386,-3.9044570193067965,0,0
|
||||
|
||||
param set SERIAL5_PROTOCOL 40
|
||||
param set AIS_TYPE 1
|
||||
*/
|
||||
|
||||
#include "SIM_AIS.h"
|
||||
#include <SITL/SITL.h>
|
||||
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
using namespace SITL;
|
||||
|
||||
|
||||
AIS::AIS() : SerialDevice::SerialDevice()
|
||||
{
|
||||
char* file_path;
|
||||
IGNORE_RETURN(asprintf(&file_path, SKETCHBOOK "/libraries/SITL/SIM_AIS_data.txt"));
|
||||
|
||||
file = fopen(file_path,"r");
|
||||
|
||||
if (file == nullptr) {
|
||||
AP_HAL::panic("AIS could not open data file");
|
||||
}
|
||||
|
||||
// seek past the header line
|
||||
char line[100];
|
||||
IGNORE_RETURN(fgets(line, sizeof(line), file));
|
||||
}
|
||||
|
||||
void AIS::update()
|
||||
{
|
||||
if (file == nullptr) {
|
||||
AP_HAL::panic("AIS lost data file");
|
||||
}
|
||||
|
||||
// just send a line of data at 1Hz:
|
||||
const uint32_t now = AP_HAL::millis();
|
||||
if (now - last_sent_ms < 1000) {
|
||||
return;
|
||||
}
|
||||
last_sent_ms = now;
|
||||
|
||||
char line[100];
|
||||
|
||||
if (!fgets(line, sizeof(line), file)) {
|
||||
// got to the end of the file, circle back
|
||||
fseek(file,0,SEEK_SET);
|
||||
if (!fgets(line, sizeof(line), file)) {
|
||||
AP_HAL::panic("AIS lost data file");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//hal.console->printf("%s",line);
|
||||
write_to_autopilot(line, strlen(line));
|
||||
|
||||
}
|
44
libraries/SITL/SIM_AIS.h
Normal file
44
libraries/SITL/SIM_AIS.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*
|
||||
Dump logged AIS data to the serial port
|
||||
./Tools/autotest/sim_vehicle.py -v Rover --no-mavproxy -A --uartF=sim:AIS --custom-location 51.58689798356386,-3.9044570193067965,0,0
|
||||
|
||||
param set SERIAL5_PROTOCOL 40
|
||||
param set AIS_TYPE 1
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SIM_SerialDevice.h"
|
||||
#include <SITL/SITL.h>
|
||||
|
||||
namespace SITL {
|
||||
|
||||
class AIS : public SerialDevice {
|
||||
public:
|
||||
|
||||
AIS();
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
FILE* file;
|
||||
|
||||
uint32_t last_sent_ms;
|
||||
|
||||
};
|
||||
|
||||
}
|
154
libraries/SITL/SIM_AIS_data.txt
Normal file
154
libraries/SITL/SIM_AIS_data.txt
Normal file
@ -0,0 +1,154 @@
|
||||
AIS AIVDM data stream captured from a real receiver
|
||||
!AIVDM,1,1,,B,403Ot`QuvFEfMo@7<0K?fL7028AU,0*60
|
||||
!AIVDM,2,1,4,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0F
|
||||
!AIVDM,2,2,4,B,0016=H=4;v?Te;1hTmh@000000000000000,2*68
|
||||
!AIVDM,2,1,5,B,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*32
|
||||
!AIVDM,2,2,5,B,2216:08666?S0=ihTmhH888888888888880,2*58
|
||||
!AIVDM,2,1,6,B,5815;hT2AUU=KMMSR20q??N2v1<E9@4v2222,0*10
|
||||
!AIVDM,2,2,6,B,221JLP0:P4hd0N43lU850C0Sm8888888880,2*2C
|
||||
!AIVDM,1,1,,A,3815;hUw00wfUdHMPfQ4s8WT0D`r,0*00
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c@MR@=0lBb80000,0*7F
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T0l`CBP000,0*4B
|
||||
!AIVDM,2,1,7,B,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*66
|
||||
!AIVDM,2,2,7,B,00169H=666?i0<ihTmh@000000000000000,2*17
|
||||
!AIVDM,1,1,,A,33M@D8UP00Of5B8MRBJ6A?vT2DTb,0*09
|
||||
!AIVDM,2,1,8,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*03
|
||||
!AIVDM,2,2,8,B,0016=H=4;v?Te;1hTmh@000000000000000,2*64
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c@MR@=Dw2b:0000,0*62
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5B`MR?>hUOwF0DfJ,0*5E
|
||||
!AIVDM,2,1,9,A,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*6B
|
||||
!AIVDM,2,2,9,A,00169H=666?i0<ihTmh@000000000000000,2*1A
|
||||
!AIVDM,1,1,,A,33m:7K5000Of4M>MR=S`gWlB0000,0*69
|
||||
!AIVDM,2,1,0,B,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*01
|
||||
!AIVDM,2,2,0,B,0016:0:2<69T0?TmhCTi@@0000000000000,2*65
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5BrMR?>PUOwF0Dm:,0*0C
|
||||
!AIVDM,1,1,,B,33m:7K5000Of4N2MR=WpgWlB0000,0*71
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T0g`CBP000,0*40
|
||||
!AIVDM,2,1,1,B,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*60
|
||||
!AIVDM,2,2,1,B,00169H=666?i0<ihTmh@000000000000000,2*11
|
||||
!AIVDM,1,1,,B,3815;hU0h1wfUdHMPfQ6B`WT0Dir,0*7F
|
||||
!AIVDM,1,1,,A,33bU7n5000Of2hDMRB@:CTs00000,0*09
|
||||
!AIVDM,1,1,,B,33bE4P5000Of3c>MR@=ewRb:0000,0*5E
|
||||
!AIVDM,2,1,2,A,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*00
|
||||
!AIVDM,2,2,2,A,0016:0:2<69T0?TmhCTi@@0000000000000,2*64
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4L@MR@T0F`CBP000,0*1F
|
||||
!AIVDM,2,1,3,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*08
|
||||
!AIVDM,2,2,3,B,0016=H=4;v?Te;1hTmh@000000000000000,2*6F
|
||||
!AIVDM,2,1,4,B,53m:7K02;lo<h4PCR20HDDB0PDhLDh4pB222,0*34
|
||||
!AIVDM,2,2,4,B,22169H?856?j0:1hTmhH888888888888880,2*4E
|
||||
!AIVDM,1,1,,B,33bU7n5000Of2gBMRB0:CTs00000,0*73
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5AtMR?;0egwD0D`b,0*20
|
||||
!AIVDM,1,1,,B,33bE4P5000Of3c6MR@>M9Rb:0000,0*33
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5B>MR?9hegwF0DiJ,0*13
|
||||
!AIVDM,1,1,,A,3815;hU0P2wfUdHMPfQ888WR0E0J,0*0D
|
||||
!AIVDM,2,1,5,A,53m:7K02;lo<h4PCR20HDDB0PDhLDh4pB222,0*36
|
||||
!AIVDM,2,2,5,A,22169H?856?j0:1hTmhH888888888888880,2*4C
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5B:MR?<PegwD0Dh:,0*5A
|
||||
!AIVDM,2,1,6,A,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*04
|
||||
!AIVDM,2,2,6,A,0016:0:2<69T0?TmhCTi@@0000000000000,2*60
|
||||
!AIVDM,1,1,,B,33aB7F5001Of4I8MR@T8h8CBP000,0*1D
|
||||
!AIVDM,2,1,7,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0C
|
||||
!AIVDM,2,2,7,B,0016=H=4;v?Te;1hTmh@000000000000000,2*6B
|
||||
!AIVDM,1,1,,A,3815;hU1P0wfUdHMPfQ=r8WV0Dbr,0*2E
|
||||
!AIVDM,1,1,,B,33bU7n5000Of2glMRBFrCTs20000,0*61
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3btMR@>M6Bb:0000,0*6C
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T0v`CDP000,0*57
|
||||
!AIVDM,1,1,,A,33bU7n5000Of2gTMRB<JCTs20000,0*18
|
||||
!AIVDM,2,1,8,B,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*09
|
||||
!AIVDM,2,2,8,B,0016:0:2<69T0?TmhCTi@@0000000000000,2*6D
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5C2MR??0p?wD0Dar,0*3F
|
||||
!AIVDM,2,1,9,B,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*3E
|
||||
!AIVDM,2,2,9,B,2216:08666?S0=ihTmhH888888888888880,2*54
|
||||
!AIVDM,2,1,0,B,5815;hT2AUU=KMMSR20q??N2v1<E9@4v2222,0*16
|
||||
!AIVDM,2,2,0,B,221JLP0:P4hd0N43lU850C0Sm8888888880,2*2A
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5BDMR?<hp?wF0Dib,0*0A
|
||||
!AIVDM,1,1,,B,3815;hUwP1wfUdHMPfQ=S`WV0DVr,0*27
|
||||
!AIVDM,1,1,,A,33m:7K5000Of4MpMR=O8gWlD0000,0*65
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5CDMR?=Pp?wD0DjJ,0*18
|
||||
!AIVDM,2,1,1,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0A
|
||||
!AIVDM,2,2,1,B,0016=H=4;v?Te;1hTmh@000000000000000,2*6D
|
||||
!AIVDM,2,1,2,A,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*36
|
||||
!AIVDM,2,2,2,A,2216:08666?S0=ihTmhH888888888888880,2*5C
|
||||
!AIVDM,1,1,,A,3815;hUwh1wfUdHMPfQ0j8W`0Djr,0*7A
|
||||
!AIVDM,2,1,3,B,53m:7K02;lo<h4PCR20HDDB0PDhLDh4pB222,0*33
|
||||
!AIVDM,2,2,3,B,22169H?856?j0:1hTmhH888888888888880,2*49
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T7v8CDP000,0*08
|
||||
!AIVDM,1,1,,B,3815;hUwh0wfUdHMPfQ0e8WT0DMb,0*74
|
||||
!AIVDM,1,1,,A,33bU7n5000Of2hBMRB<rCTs20000,0*39
|
||||
!AIVDM,1,1,,B,33bE4P5000Of3c0MR@=JJ2b:0000,0*22
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4I8MR@T1h`CDP000,0*4B
|
||||
!AIVDM,2,1,4,A,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0C
|
||||
!AIVDM,2,2,4,A,0016=H=4;v?Te;1hTmh@000000000000000,2*6B
|
||||
!AIVDM,2,1,5,B,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*32
|
||||
!AIVDM,2,2,5,B,2216:08666?S0=ihTmhH888888888888880,2*58
|
||||
!AIVDM,1,1,,B,33bU7n5000Of2hFMRB<rCTs20000,0*3E
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3bvMR@=`Tjb<0000,0*0C
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5BLMR?<Pp?wF0Dg:,0*6C
|
||||
!AIVDM,2,1,6,B,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*67
|
||||
!AIVDM,2,2,6,B,00169H=666?i0<ihTmh@000000000000000,2*16
|
||||
!AIVDM,1,1,,B,33bE4P5P@0Of3c0MR@=WaRb<0000,0*62
|
||||
!AIVDM,2,1,7,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0C
|
||||
!AIVDM,2,2,7,B,0016=H=4;v?Te;1hTmh@000000000000000,2*6B
|
||||
!AIVDM,2,1,8,A,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*3C
|
||||
!AIVDM,2,2,8,A,2216:08666?S0=ihTmhH888888888888880,2*56
|
||||
!AIVDM,2,1,9,A,5815;hT2AUU=KMMSR20q??N2v1<E9@4v2222,0*1C
|
||||
!AIVDM,2,2,9,A,221JLP0:P4hd0N43lU850C0Sm8888888880,2*20
|
||||
!AIVDM,1,1,,A,3815;hU101wfUdHMPfQ;@8Wb0Dsb,0*4E
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T0?8ADP000,0*44
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5C@MR?;@p?wF0D`r,0*39
|
||||
!AIVDM,2,1,0,A,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*62
|
||||
!AIVDM,2,2,0,A,00169H=666?i0<ihTmh@000000000000000,2*13
|
||||
!AIVDM,1,1,,B,3815;hUwh1wfUdHMPfQ6L`WR0DlJ,0*0D
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4I8MR@T0<`ADP000,0*1C
|
||||
!AIVDM,2,1,1,A,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*09
|
||||
!AIVDM,2,2,1,A,0016=H=4;v?Te;1hTmh@000000000000000,2*6E
|
||||
!AIVDM,2,1,2,B,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*35
|
||||
!AIVDM,2,2,2,B,2216:08666?S0=ihTmhH888888888888880,2*5F
|
||||
!AIVDM,2,1,3,B,5815;hT2AUU=KMMSR20q??N2v1<E9@4v2222,0*15
|
||||
!AIVDM,2,2,3,B,221JLP0:P4hd0N43lU850C0Sm8888888880,2*29
|
||||
!AIVDM,1,1,,A,3815;hUwh1wfUdHMPfQ1p8Wd0DsJ,0*44
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c8MR@=IeRb<0000,0*63
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T5:8ADP000,0*44
|
||||
!AIVDM,2,1,4,B,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*65
|
||||
!AIVDM,2,2,4,B,00169H=666?i0<ihTmh@000000000000000,2*14
|
||||
!AIVDM,1,1,,B,33bE4P5000Of3c<MR@=70Rb<0000,0*4F
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5BrMR?;0p?wH0DW:,0*08
|
||||
!AIVDM,2,1,5,A,53aB7F02?1U90PdR2208D5Dl4LT>22222222,0*31
|
||||
!AIVDM,2,2,5,A,2216:08666?S0=ihTmhH888888888888880,2*5B
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c>MR@=GQRb<0000,0*5F
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5BvMR??@p?wF0De:,0*47
|
||||
!AIVDM,2,1,6,A,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*64
|
||||
!AIVDM,2,2,6,A,00169H=666?i0<ihTmh@000000000000000,2*15
|
||||
!AIVDM,1,1,,B,3815;hU0@1wfUdHMPfQ558WN0E3r,0*3A
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4I8MR@T=Q8ADP000,0*24
|
||||
!AIVDM,2,1,7,B,53bE4P029KAA08Dt000DhU<48E@R0d000000,0*66
|
||||
!AIVDM,2,2,7,B,00169H=666?i0<ihTmh@000000000000000,2*17
|
||||
!AIVDM,1,1,,B,3815;hU0P1wfUdHMPfQ058WT0Dcr,0*64
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4I8MR@T6E8ADP000,0*3B
|
||||
!AIVDM,1,1,,B,33bU7n5000Of2glMRAwJCTs40000,0*6D
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c<MR@=B5jb<0000,0*04
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5BfMR?:0b?wF0Dk:,0*3E
|
||||
!AIVDM,1,1,,A,33m:7K5000Of4MlMR=T`gWnF0000,0*3A
|
||||
!AIVDM,1,1,,B,33bE4P5000Of3c<MR@=S>Rb<0000,0*25
|
||||
!AIVDM,2,1,8,B,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*09
|
||||
!AIVDM,2,2,8,B,0016:0:2<69T0?TmhCTi@@0000000000000,2*6D
|
||||
!AIVDM,2,1,9,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*02
|
||||
!AIVDM,2,2,9,B,0016=H=4;v?Te;1hTmh@000000000000000,2*65
|
||||
!AIVDM,2,1,0,A,53m:7K02;lo<h4PCR20HDDB0PDhLDh4pB222,0*33
|
||||
!AIVDM,2,2,0,A,22169H?856?j0:1hTmhH888888888888880,2*49
|
||||
!AIVDM,1,1,,A,33aB7F5000Of4I8MR@T9M8ADP000,0*3F
|
||||
!AIVDM,2,1,1,A,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*03
|
||||
!AIVDM,2,2,1,A,0016:0:2<69T0?TmhCTi@@0000000000000,2*67
|
||||
!AIVDM,1,1,,B,33aB7F5000Of4I8MR@T2g8ADP000,0*1D
|
||||
!AIVDM,2,1,2,A,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0A
|
||||
!AIVDM,2,2,2,A,0016=H=4;v?Te;1hTmh@000000000000000,2*6D
|
||||
!AIVDM,1,1,,B,33bU7n5000Of2hBMRB6bCTs40000,0*26
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c<MR@=lijb>0000,0*74
|
||||
!AIVDM,1,1,,B,33bE4P5Oh0Of3c<MR@=nEBb>0000,0*56
|
||||
!AIVDM,2,1,3,B,53bU7n02=f5I09`h00058dhuN18E<tiHD000,0*02
|
||||
!AIVDM,2,2,3,B,0016:0:2<69T0?TmhCTi@@0000000000000,2*66
|
||||
!AIVDM,1,1,,A,33aO?TUP00Of5C8MR?<Pb?wF0Dh:,0*07
|
||||
!AIVDM,2,1,4,B,53aO?TT2C4pe09IP00058dhuN08D4<tp0000,0*0F
|
||||
!AIVDM,2,2,4,B,0016=H=4;v?Te;1hTmh@000000000000000,2*68
|
||||
!AIVDM,1,1,,A,33bE4P5000Of3c>MR@>2ORb>0000,0*35
|
||||
!AIVDM,1,1,,B,33aO?TUP00Of5BRMR?>hb?wD0Dnb,0*09
|
Loading…
Reference in New Issue
Block a user