Communicating with godot engine through shared memory

GodotAIGym

logo

Make your Godot project into OpenAI Gym environment to train RL models with PyTorch. This project only runs on Linux systems.

Requirements

  1. Godot Engine version >= 3.2 compiled from source (see compiling requirements for your platform)
  2. Boost interprocess (apt install libboost-container-dev libboost-system-dev libboost-locale-dev)
  3. Pytorch version >= 1.5
  4. OpenAI Gym
  5. Python setuptools

Installation

First, in setup.py change the variable GODOT_PATH to the root directory of godot engine source. Then run:

python setup.py

This script does several things:

  1. Downloads libtorch cpu only version, unpacks it
  2. Copies GodotSharedMemory module and compiles standard godot editor (x11 platform).
  3. Compiles x11 export template, dev tools and server templates
  4. Installs python module GodotEnv that is used to communicate with the engine.

Docs

InvPendulum tutorial shows how to make an environment, speed up its execution, train a model and deploy back to the engine.

API lists classes and function in python and godot.

TODO

Resolve the bug:

handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7f79ead5a210] (??:0)
[2] ./InvPendulum.x86_64() [0x812e16] (/usr/include/c++/9/bits/basic_string.h:2301)
[3] ./InvPendulum.x86_64() [0x63942e] (/home/lupoglaz/Projects/godot/./core/os/memory.h:119)
Comments
  • boost::interprocess_exception::library_error

    boost::interprocess_exception::library_error

    Hello,

    I am getting a lot of boost::interprocess_exception::library_error errors with my custom environment. I've read a little bit about the boost managed_shared_memory class, but I don't quite see how to determine exactly what the problem is or how to work around it.

    The error seems to get thrown at random. Sometimes I can go 100 iterations without issue, sometimes it comes up right away. I am writing a whole image to the semaphore using a 4096 int array. That does work, except sending a large array seems to make the problem more likely to occur. If instead of sending a 4096 byte array I send one byte, the problem doesn't usually come up.

    I added a bit more print statements and found that the error happens either when sending the action data or reading the observation data. The program will print these exception messages and then either segfault or hang.

    I wonder if there is some issue where both processes try to access the object in memory at the same time? Might be less likely with the examples which all send state as a few bytes.

    I will share my code for training a 3D vehicle using Google Dreamer V2 once I get it working. If anyone has any insight it would be appreciated. Thank you!

  • Program crashed with signal 11

    Program crashed with signal 11

    Hi I see this error quite often: (every minute or two)

    handle_crash: Program crashed with signal 11 do you know what is causing this? and how to avoid\solve it?

  • Shared memory crashes in Godot 3.2

    Shared memory crashes in Godot 3.2

    I was able to compile and run GodotGymAI successfully on my system (Ubuntu 18.0, Python 3.8) using Godot 3.1, but it crashes for Godot 3.2. Specifically, in Godot 3.2 the shared memory module throws the following exception when I call the getFloatArray() function:

    "Dynamic exception type: boost::interprocess::interprocess_exception std::exception::what: No such file or directory"

  • Typo in Tutorial documentation

    Typo in Tutorial documentation

    Awesome project! I believe there is a small typo with "shows" here: https://github.com/lupoglaz/GodotGymAI/blob/f55e245dbb344c2febefc7a9787b8bedc11e4c36/docs/tutorial.html#L132

    Cheers!

  • compile error

    compile error

    Hi I download godot version 3.2 from https://github.com/godotengine/godot/archive/3.2-stable.tar.gz and I'm trying to compile I get this error In file included from modules/GodotSharedMemory/cSharedMemory.cpp:3:0: modules/GodotSharedMemory/cSharedMemory.h:5:10: fatal error: core/object/reference.h: No such file or directory #include "core/object/reference.h"

    any idea how to solve it?

  • Bug fixes in compilation and MoonLander bug fixes

    Bug fixes in compilation and MoonLander bug fixes

    Compilation-> Fixing some tyeps errors plus removing "set_mouse_in_window", which is not anymore supported by godot.

    MoonLander-> Fixing Landing detection and force Lander object to be wake up all the time. (Removing bugs in movement of Lander.)

  • Add Uint type for screen frame transfer

    Add Uint type for screen frame transfer

    Hello,

    Thank you for sharing the code. It works well.

    I find it is too slow to send the image frame as an observation value by using the Float, Int type. Therefore, I add the Uint type to send the PoolVector as an observation value.

    I add my own environment and README file under the Tutorials/DogdeCreepTut folder.

    Thank you

  • Can't find Project Settings referenced in

    Can't find Project Settings referenced in "Speedup Tutorial"

    My Project Settings don't seem to have Physics > Common > Timestep > Method. Any guidance would be appreciated!

    Godot version: Godot Engine v3.2.3.stable.custom_build.31d0f8ad8

    image

  • Compiling with the latest Godot

    Compiling with the latest Godot

    Hello!

    Very happy to see an OpenAI gym connector! I discovered that this does not compile with the latest Godot, so I have been working on the necessary changes. I've got a commit here with some of the changes necessary, and I wanted to share it.

    https://github.com/tlalexander/GodotAIGym/commit/e6a85eaa807347c190fdae984eeef94d8f70e362

    My remaining issues as far as I'm able to see right now seem to be related to changes in the Godot String class.

    modules/GodotSharedMemory/cSharedMemory.cpp: In member function 'void cSharedMemory::sendIntArray(const String&, const Vector<int>&)':
    modules/GodotSharedMemory/cSharedMemory.cpp:100:25: error: 'const class String' has no member named 'c_str'
      100 |  std::wstring ws = name.c_str();
          |                         ^~~~~
    modules/GodotSharedMemory/cSharedMemory.cpp: In member function 'void cSharedMemory::sendFloatArray(const String&, const Vector<float>&)':
    modules/GodotSharedMemory/cSharedMemory.cpp:116:25: error: 'const class String' has no member named 'c_str'
      116 |  std::wstring ws = name.c_str();
    
    

    The method c_str has changed to get_data but also returns a different type. So if you just change the affected c_str calls (only those attached to the Godot String class) to get_data, you get a new error:

    odules/GodotSharedMemory/cSharedMemory.h:80:46: error: conversion from 'const char32_t*' to non-scalar type 'std::wstring' {aka 'std::__cxx11::basic_string<wchar_t>'} requested
       80 |           std::wstring ws = sem_name.get_data();
    
    

    Seems pretty solvable but I've got to head to work and take a break on this so I thought I would share my progress! I'm not sure if some of my other changes were appropriate, but I'll keep testing! I know I can run an old version of Godot if I get stuck but I thought it would be nice to contribute. If anyone sees this and has some ideas please let me know. Thanks!

  • Improve setup.py

    Improve setup.py

    I ran into some issues when trying to set this up on my machine so I made some changes to the setup.py in order to make this more accessible to new users. The changes include:

    • Always delete the libtorch folder and extract libtorch.zip. I had the problem that the setup.py failed silently after cleaning the git repository since there was an empty libtorch folder. This lead to libtorch.zip not being extracted. This is fixed by deleting the folder each time setup.py runs. Also this makes sure there are no old files left in case the value of url was changed. I think the few seconds needed to extract the file is nothing compared to how long this script runs.
    • On some operating systems python is not available but is called python3 so I added a check for that.
    • Install the python module as user because it would fail without sudo.
    • Added libtorch to gitignore because this was showing up as 1000+ untracked files.
A MySQL-compatible relational database with a storage agnostic query engine. Implemented in pure Go.

go-mysql-server go-mysql-server is a SQL engine which parses standard SQL (based on MySQL syntax) and executes queries on data sources of your choice.

Jan 2, 2023
MySQL Storage engine conversion,Support mutual conversion between MyISAM and InnoDB engines.

econvert MySQL Storage engine conversion 简介 此工具用于MySQL存储引擎转换,支持CTAS和ALTER两种模式,目前只支持MyISAM和InnoDB存储引擎相互转换,其它引擎尚不支持。 注意:当对表进行引擎转换时,建议业务停止访问或者极少量访问时进行。 原

Oct 25, 2021
MatrixOne is a planet scale, cloud-edge native big data engine crafted for heterogeneous workloads.
MatrixOne is a planet scale, cloud-edge native big data engine crafted for heterogeneous workloads.

What is MatrixOne? MatrixOne is a planet scale, cloud-edge native big data engine crafted for heterogeneous workloads. It provides an end-to-end data

Dec 26, 2022
It's a Go console utility for migration from MSSQL to MySQL engine.

A tool for migration the databases to MySQL It's a Go console utility for migration from MSSQL to MySQL engine. The databases should have prepopulated

Jan 4, 2022
Zinc Search engine. A lightweight alternative to elasticsearch that requires minimal resources, written in Go.
Zinc Search engine. A lightweight alternative to elasticsearch that requires minimal resources, written in Go.

Zinc Zinc is a search engine that does full text indexing. It is a lightweight alternative to elasticsearch and runs in less than 100 MB of RAM. It us

Jan 8, 2023
Hybrid Engine for emulate trading flow

Deridex Backend This is a backend implementation for Deridex market. The system

Dec 15, 2021
Go module for communicating with the Veryfi OCR API
Go module for communicating with the Veryfi OCR API

veryfi-go is a Go module for communicating with the Veryfi OCR API Installing This package can be installed by cloning this directory: git clone https

Jan 5, 2023
The note-tinygo Go library for communicating with Blues Wireless Notecard via serial or I²C

Blues Wireless The note-tinygo Go library for communicating with Blues Wireless Notecard via serial or I²C. This library allows you to control a Notec

Nov 29, 2021
A Go library for communicating with Tesla Powerwall appliances via the local-network API

go-powerwall A Go library for communicating with Tesla Powerwall appliances via the local-network API. Many thanks to Vince Loschiavo and other contri

Dec 10, 2022
👻 A simple API to inter-process communicating between Go and Node

go-to-node A simple API to inter-process communicating between Go and NodeJS. Quick start Go to Node main.go: package main import ( "fmt" "os" "os

Jan 7, 2022
Episode VI: The sentients (RPC autonomously communicating server-client)

APITrials0.6 Episode VI: The sentients (RPC autonomously communicating server-client) Captain's log: As we stray deeper into the machine inner convers

Jan 10, 2022
A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I2C bus.

tinygo-multi-i2c A reimplementation of the TinyGo drivers package for communicating with multiples of the same (supported) devices on one individual I

Mar 10, 2022
A CLI tool for communicating with github.

go-github A Golang CLI tool built with Cobra (& cobra-cli). Pre-requisites Go SDK Getting started You can decide to do one of two things: Clone the re

Jul 31, 2022
This library aims to make it easier to interact with Ethereum through de Go programming language by adding a layer of abstraction through a new client on top of the go-ethereum library.

Simple ethereum client Simple ethereum client aims to make it easier for the developers to interact with Ethereum through a new layer of abstraction t

May 1, 2022
Speed up the memory allocation and improve the GC performance, especially for dynamic-memory-heavy applications.
Speed up the memory allocation and improve the GC performance, especially for dynamic-memory-heavy applications.

Linear Allocator for Golang Goal Speed up the memory allocation and improve the GC performance, especially for dynamic-memory-heavy applications. Pote

Dec 20, 2022
gpu-memory-monitor is a metrics server for collecting GPU memory usage of kubernetes pods.

gpu-memory-monitor is a metrics server for collecting GPU memory usage of kubernetes pods. If you have a GPU machine, and some pods are using the GPU device, you can run the container by docker or kubernetes when your GPU device belongs to nvidia. The gpu-memory-monitor will collect the GPU memory usage of pods, you can get those metrics by API of gpu-memory-monitor

Jul 27, 2022
Memory-Alignment: a tool to help analyze layout of fields in struct in memory
Memory-Alignment: a tool to help analyze layout of fields in struct in memory

Memory Alignment Memory-Alignment is a tool to help analyze layout of fields in struct in memory. Usage go get github.com/vearne/mem-aligin Example p

Oct 26, 2022
Misou is a personal search engine very much inspired by monocle that looks through my knowledge sources.
Misou is a personal search engine very much inspired by monocle that looks through my knowledge sources.

?? Mi 搜 - a personal search engine Misou is a personal search engine very much inspired by monocle that looks through my knowledge sources. It is writ

Nov 7, 2022
vkectl is a tool to manage VKE(VolcanoEngine Kubernetes Engine) resources through a CLI

vkectl Introduction vkectl is a tool to manage VKE(VolcanoEngine Kubernetes Engine) resources through a CLI(Command Line Interface). It is written in

Aug 26, 2022
Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, XML document namespaces, and tree magic for mounted volumes, generated from the XDG shared-mime-info database.

mimemagic Powerful and versatile MIME sniffing package using pre-compiled glob patterns, magic number signatures, xml document namespaces, and tree ma

Nov 3, 2022