Giter Club home page Giter Club logo

fgfs-binary-protocol's Introduction

C++ binary protocol for Flightgear

This is a sample of a binary protocol for Flightgear written in C++ with the purpose of controlling via Arduino (or CLI) the Cessna C172P Model.

How to try it out

DISCLAMER: I'm working on Ubuntu 18.04, and this repo is developed with Linux-only in mind.

Tested with Flightgear version: 2018.3.1. Using Arduino NANO.

  1. Clone this repository:
$ git clone https://github.com/danieleperot/fgfs-binary-protocol.git
  1. CD into the repository and build the executables:
# Build the client executable (control FlightGear through CLI)
$ make client
# Build the serial executable (control FlightGear through Arduino)
$ make seria
  1. Copy the generic protocol file binary-protocol.xml into the Protocol folder of Flightgear:
# Flightgear main folder ($FG_ROOT) is usually /usr/share/games/flightgear
# You might need to be root to execute this command!
$ cp ./binary-protocol.xml /usr/share/games/flightgear/Protocol/
# There is also a make option with the default $FG_ROOT folder
$ make copy-protocl
  1. Run Flightgear:
    • Are you using the GUI? Click on Settings and add the following line under Additional Settings:
    --generic=socket,in,1,,10540,udp,binary-protocol
    
    • Are you using the CLI version? Execute this command:
    $ fgfs --generic=socket,in,1,,10540,udp,binary-protocol
  2. Run the executable
# In the repository folder
$ ./client
# or
$ ./serial

Arduino schematic

If you want to use Arduino, build a prototype following this schematic:

Arduino schematic

You can find the sketch in arduino-protocol.

Change UDP Port

The protocol is a binary protocol working on a UDP Socket on the port 10540.

You can change the port by going inside serial.cpp or client.cpp and changing the following line:

// From
FlightGear* flightgear = new FlightGear(10540);
// To 
FlightGear* flightgear = new FlightGear(/* Your port number */);

Then change the port number in the --generic string as well.

# From
--generic=socket,in,1,,10540,udp,binary-protocol
# To
--generic=socket,in,1,,[Your Port Number],udp,binary-protocol

Change USB Port

Inside serial.cpp, simply add the string of the USB port to the ArduinoConnect constructor:

ArduinoConnect *arduino = new ArduinoConnect("/dev/ttyUSB0");

Conclusion

Be aware that I'm not a real C++ developer, so don't get too scared on what you will see!

Feel free to fork and modify this repository as you need.

I'm actually happy to learn from other people, so don't esistate to share with me your ideas =)

fgfs-binary-protocol's People

Contributors

danieleperot avatar

Stargazers

 avatar  avatar  avatar  avatar

fgfs-binary-protocol's Issues

Changing the code to receive data from the simulator

Hello @danieleperot
I understand that the project is outdated and is no longer supported by you, but could you suggest, perhaps by analogy with your code, to receive data from flightgear via the serial port in arduino?
Did you do this, or did you just send data to the simulator?

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.