airsim之settings解析

settings.json存放的位置

ubuntu: ~/Documents/Airsim

可用的设置和默认值

“SimMode”: 选择car或者miltimotor
“ViewMode”: 选择FlyWithMe(for drones)或者 SpringArmChase(for cars)
"SettingsVersion"是必须的,设为1.2

OriginGeopoint

此设置指定放置在环境中的“”Player Start“ 的纬度、经度和高度,使用该变换计算车辆的原点。请注意,该API使用的坐标都是国际单位制的NED系统,这意味着每辆车在NED系统中从(0,0,0)开始。计算“origingeopoint”中指定的地理坐标的时间设置。
NED系统即:north (x+) east(y+) down(z+) 与gazebo只有z相反

APIs for car

setCarControls:
可以设置throttle(节气门)/ steering(转向) / handbrake(手刹) / auto/manual gear(自动或手动驾驶)
getCarState:
获取speed current gear 和6个运动学参数(position orientation linear/angular velocity linear/angular acceleration)
除了angular velocity和acceleration 在车坐标系下,其他在世界坐标系 且均为NED系统

#include 
#include "vehicles/car/api/CarRpcLibClient.hpp"

int main() 
{
    msr::airlib::CarRpcLibClient client;
    client.enableApiControl(true); //this disables manual control
    CarControllerBase::CarControls controls;

    std::cout << "Press enter to drive forward" << std::endl; std::cin.get();
    controls.throttle = 1;
    client.setCarControls(controls);

    std::cout << "Press Enter to activate handbrake" << std::endl; std::cin.get();
    controls.handbrake = true;
    client.setCarControls(controls);

    std::cout << "Press Enter to take turn and drive backward" << std::endl; std::cin.get();
    controls.handbrake = false;
    controls.throttle = -1;
    controls.steering = 1;
    client.setCarControls(controls);

    std::cout << "Press Enter to stop" << std::endl; std::cin.get();
    client.setCarControls(CarControllerBase::CarControls());

    return 0;
}

sensors

每个传感器有自己对应的num:

相机

  • 相机没有num
int getStereoAndDepthImages() 
{
    using namespace std;
    using namespace msr::airlib;
    
    typedef VehicleCameraBase::ImageRequest ImageRequest;
    typedef VehicleCameraBase::ImageResponse ImageResponse;
    typedef VehicleCameraBase::ImageType ImageType;

    //for car use
    //msr::airlib::CarRpcLibClient client;
    msr::airlib::MultirotorRpcLibClient client;

    //get right, left and depth images. First two as png, second as float16.
    vector request = { 
        //png format
        ImageRequest("0", ImageType::Scene),
        //uncompressed RGB array bytes
        ImageRequest("1", ImageType::Scene, false, false),       
        //floating point uncompressed image  
        ImageRequest("1", ImageType::DepthPlanner, true) 
    };

    const vector& response = client.simGetImages(request);
    //do something with response which contains image data, pose, timestamp etc
}
  • barometer 气压计:1
  • imu :2
  • gps :3
  • magnetometer 磁力计:4
  • Distance Sensor :5
  • Lidar :6

默认传感器:

  • 飞行器:barometer imu gps magnetometer
  • 车:gps
"DefaultSensors": {
    "Barometer": {
         "SensorType": 1,
         "Enabled" : true
    },
    "Imu": {
         "SensorType": 2,
         "Enabled" : true
    },
    "Gps": {
         "SensorType": 3,
         "Enabled" : true
    },
    "Magnetometer": {
         "SensorType": 4,
         "Enabled" : true
    },
    "Distance": {
         "SensorType": 5,
         "Enabled" : true
    },
    "Lidar2": { 
         "SensorType": 6,
         "Enabled" : true,
         "NumberOfChannels": 4,
         "PointsPerSecond": 10000
    }
},

C++ API

  • Barometer
msr::airlib::BarometerBase::Output getBarometerData(const std::string& barometer_name, const std::string& vehicle_name);
  • IMU
msr::airlib::ImuBase::Output getImuData(const std::string& imu_name = "", const std::string& vehicle_name = "");
  • GPS
msr::airlib::GpsBase::Output getGpsData(const std::string& gps_name = "", const std::string& vehicle_name = "");
  • Distance sensor
msr::airlib::DistanceBase::Output getDistanceSensorData(const std::string& distance_sensor_name = "", const std::string& vehicle_name = "");
  • Lidar
    参考之前的

你可能感兴趣的:(airsim)