Skip to content

TF2 tutorial for Ros 2 Foxy and Snake game functionalities

Notifications You must be signed in to change notification settings

RocaPiedra/ros2_snake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Environment: Ros 2 Foxy, Python 3, Ubuntu 20.04 Use the prepared docker environment for fast deployment and testing, instructions available in launch_docker_env.md

Packages:

learning_tf2_py:

Finished tf2 tutorial

snake_tf2:

Package with base programming practice:

Functionality number 1: Full application launch + turtle follow upon contact using:

  • Center body follow:

ros2 launch snake_tf2 snake_base.launch.py

VIDEO

  • Tail follow (follower stays slightly behind):

ros2 launch snake_tf2 snake_fixed_frame.launch.py

VIDEO

Functionality number 2: Wait for service launch + turtle follow upon contact using:

Empty service
  • Center body follow for Empty service call:

ros2 launch snake_tf2 snake_wait_call.launch.py

VIDEO

  • Tail follow for Empty service call(follower stays slightly behind):

ros2 launch snake_tf2 snake_fixed_frame_wait_call.launch.py

VIDEO

Launch one of those launch.py and then call a ros2 service with the name /start_turtlesim_snake like this to spawn turtle in random point:

ros2 service call /start_turtlesim_snake std_srvs/Empty

Initial location service
  • Center body follow for service call with input location:

ros2 launch snake_tf2 snake_wait_initial_pose.launch.py

VIDEO

  • Tail follow for service call with input location(follower stays slightly behind):

ros2 launch snake_tf2 snake_fixed_frame_wait_initial_pose.launch.py

VIDEO

Launch one of those launch.py and then call a ros2 service with the name /start_turtlesim_snake like this to spawn turtle in specific place:

ros2 service call /start_turtlesim_snake snake_interfaces/srv/TurtlePos "{pos_x: 1, pos_y: 1, angle: 1}"

Snake Game

Snake game needs heavy debugging. The multinode modular approach is not capable of handing all the nodes in one core process and the speed commands are too slow/irregular to move the turtles correctly. The dynamic spawn works fine and creates complex nodes but from a single computer perspective it needs refinement to achieve proper performance. A simpler approach just accessing the data as a service would probably work better.

ros2 launch snake_tf2 game_of_snake.launch.py 
Other Functionalities
  • Change the simulation background color when the turtle is eaten. Good example on how to set parameters from other packages using their own services with a minimal client that belongs to the listener class.

snake_interfaces:

C++ package with the additional msg and srv types used in the snake package.

About

TF2 tutorial for Ros 2 Foxy and Snake game functionalities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages