GithubHelp home page GithubHelp logo

lylemoffitt / godot_ros Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flynneva/godot_ros

0.0 1.0 0.0 437 KB

Godot module to use ROS 2 within Godot

License: MIT License

C++ 70.46% Python 4.62% C 5.90% GDScript 19.02%

godot_ros's Introduction

godot_ros

This repo is a Godot Module meant to connect Robotic Operating System 2 (ROS2) and the Godot Game Engine.

image

Update: Support for Godot4

It now supports Godot4, use the godot4 branch

When compiling, recommended commands are the following, setting the path where you have downloaded the godot_ros module:

source /opt/ros/${ROS_DISTRO}/setup.bash
scons -j$(nproc) custom_modules=/ABS_PATH_TO/godot_4_modules

Quick Start

Make sure to have both ROS2 and the Godot source installed on your workstation.

Clone this repo into your godot/modules/ directory.

Alternatively you can place this module in an external ~/modules directory and pass in the filepath to scons at build time.

Modify the godot_ros/SCsub file with your ROS2 distro and desired cpp compiler flag.

# godot_ros/SCsub file within this repo, lines 5 and 6
ros_distro = "galactic"
cpp_version = "-std=c++17"

Compile Godot:

# make sure you are in the Godot source root directory
cd godot/
scons -j8 platform=x11  # specific for linux/ubuntu

If you have placed the godot_ros module in an external ~/module/ directory, pass in the filepath to scons with the following command:

cd godot/
scons -j8 platform=x11 custom_modules=/path/to/modules/directory

Once compiled, you should be able to start Godot:

cd godot/
./bin/godot.x11.tools.64

A simple GDScript talker demo would look something like this:

extends Node2D

signal timeout

# calls rclcpp::init(0, nullptr) to make sure ROS is started up
var ros_talker = Talker.new()

var g_timer = null

var count = 1

# Called when the node enters the scene tree for the first time.
func _ready():
	# spin nodes that were added to executors
	# not really need for talker demo but will be needed later for subscribing
	# to ROS2 topics
	ros_talker.spin_some()
	
	g_timer = Timer.new()
	add_child(g_timer)
	# connect the talk signal with the talk callback
	g_timer.connect("timeout", self, "_on_Timer_timeout")
	g_timer.set_wait_time(1.0)
	g_timer.set_one_shot(false)
	g_timer.start()
	pass # Replace with function body.

func _on_Timer_timeout():
  print("godot is talking: " + String(count))
  ros_talker.talk(count)
  count += 1

Other GDScript examples are in the gdscript/ directory

Troubleshooting

Make sure you have sourced your ROS overlay before trying to start Godot....otherwise you will see this error:

./bin/godot.x11.tools.64: error while loading shared libraries: librclcpp.so: cannot open shared object file: No such file or directory

To solve this, just run source /opt/ros/<ros-distro>/setup.bash and restart Godot.

Future work

  • support other platforms, should be just configuring the SCsub file I think (i.e. Windows)
  • add other ROS2 features to godot_ros
  • generate documentation for this module
  • add more demos/examples to documentation

godot_ros's People

Contributors

flynneva avatar rdaneelolivav avatar lylemoffitt avatar

Watchers

 avatar

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.