为方便查阅,此文是原网站文档翻译,如有侵权,请与本人联系。
官网
Chrono中的GPS使用球面坐标系和指定模拟原点的GPS参考位置来计算纬度、经度和海拔高度。GPS假设Chrono系统为Z-Up、X-East、Y-North。 # GPS创建
// create a noise model
auto gps_noise_model=chrono_types::make_shared<ChNoiseNormal>(
ChVector<float>(1.f, 1.f, 1.f), // Mean
ChVector<float>(2.f, 3.f, 1.f) // Standard Deviation
);
auto gps = chrono_types::make_shared<ChGPSSensor>(
parent_body, // body to which the GPS is attached
gps_update_rate, // update rate
gps_offset_pose, // offset pose from body
gps_reference, // reference GPS location (GPS coordinates of simulation origin)
gps_noise_model // noise model to use for adding GPS noise
);
gps->SetName("GPS");
gps->SetLag(gps_lag);
gps->SetCollectionWindow(gps_collection_time);
// GPS data accessfilter
gps->PushFilter(chrono_types::make_shared<ChFilterGPSAccess>());
// Addsensorto manager
manager->AddSensor(gps);
GPS data access
utils::CSV_writergps_csv(" ");
UserGPSBufferPtr bufferGPS;
while () {
bufferGPS=gps->GetMostRecentBuffer<UserGPSBufferPtr>();
if(bufferGPS->Buffer) {
// Save the gpsdata to file
GPSDatagps_data= bufferGPS->Buffer[0];
gps_csv<<std::fixed <<std::setprecision(6);
gps_csv<<gps_data.Latitude; // Latitude
gps_csv<<gps_data.Longitude; // Longitude
gps_csv<<gps_data.Altitude; // Altitude
gps_csv<<gps_data.Time; // Time
gps_csv<<std::endl;
}
}
gps_csv.write_to_file(gps_file);