Giter VIP home page Giter VIP logo

airsim-client's Introduction

Rust Airsim

A Rust Client library for Microsoft Airsim

Contributions are welcome!

Build Status airsim-client crate minimum rustc 1.56 Docs Maintenance GitHub pull-requests GitHub pull-requests closed ViewCount License: MIT

How to use

See examples folder for more!

Use e.g this settings.json to configure multirotor in Airsim

Once you have Airsim up and running (some examples below on how run), execute the snippet:

use airsim_client::{DrivetrainType, MultiRotorClient, NetworkResult, Path, Vector3, YawMode};
use async_std::task;

async fn connect_drone() -> NetworkResult<()> {
    let address = "<Airsim IP here>:41451"; // set with env variable
    let vehicle_name = ""; // use default vehicle name
    log::info!("Start!");

    // connect
    log::info!("connect");
    let client = MultiRotorClient::connect(address, vehicle_name).await?;

    // confirm connect
    log::info!("confirm connection");
    let res = client.confirm_connection().await?;
    log::info!("Response: {:?}", res);

    // arm drone
    log::info!("arm drone");
    client.arm_disarm(true).await?;
    log::info!("Response: {:?}", res);

    // take off
    log::info!("take off drone");
    client.take_off_async(20.0).await?;
    log::info!("take off completed");

    log::info!("move on path");
    client
        .move_on_path_async(
            Path(vec![
                Vector3::new(-25.0, 0.0, -20.0),
                Vector3::new(-50.0, 50.0, -20.0),
                Vector3::new(-50.0, -50.0, -25.0),
            ]),
            5.0,
            1000.0,
            DrivetrainType::MaxDegreeOfFreedom,
            YawMode::new(false, 90.0),
            None,
            None,
        )
        .await?;
    log::info!("done!");

    log::info!("go home");
    client.go_home_async(20.0).await?;
    log::info!("got home");

    log::info!("land drone");
    let landed = client.land_async(20.0).await?;
    log::info!("drone landed: {landed}");

    log::info("Disarm drone")
    client.arm_disarm(false).await?;
    client.enable_api_control(false).await?;
    Ok(())
}

fn main() -> NetworkResult<()> {
    env_logger::init();
    task::block_on(connect_drone())
}

Pre-requisites to build project

$ sudo apt install build-ess    ential

Running with Docker

Install docker-nvidia first

then

$ make airsim-up

WSL2 (client) and Windows 11 Server

https://docs.microsoft.com/en-us/windows/wsl/networking

Open Windows PowerShell in directory Blocks\Blocks\WindowsNoEditor and type:

./Blocks.exe -ResX=640 -ResY=480 -windowed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.