Skip to content

DenWaritthon/fun5mini_ws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FUN5/2: Mini project

ทำการสร้าง เกม โดยใช้ ประยุกต์ใข้ MICRO-ROS

game_introl

Table of Contents (TOC)

Demo Video

Click --> Demo Video

Futures

เราสร้างเกมที่เต่าจะแข่งกันกินพิซซ่ากับบอทของเรา โดยนำ Turtlesim_plus และ Micro-Ros มาประยุกต์ในการสร้างเกมนี้ขึ้นมา

System architecture

system architecture

ระบบของเรามีทั้งหมด 6 Node 2 namespace ได้แก่

  • ling (namespace ของผู้เล่น)
    • ling/cubemx_node (micro-ros)
    • ling/controller_node
  • bot (namespace ของbot)
    • bot/bot_node
    • bot/controller_node
  • ไม่มี namespace
    • spawn_target_node
    • turtlesim+

Micro-ros (ling/cubemx_node)

ตัว Micro ros จะส่ง topic

/ling/cmd_vel
  • /ling/cmd_vel จะสร้าง cmd_vel เพื่อส่งค่าความเร็วไปควบคุมเต่า ling

และส่งSerive client

/ling/call_eat
  • /ling/call_eat จะเป็น Service client เพื่อส่งคำส่งกินพิซซ่าในระยะ

โดยควบคุมผ่าน "funduino joystick shield" Funduino_joystick_shield รูปภาพจาก rajivelectronics

Controller_node

ตัว Controller จะ Sub topic

/namespace/pose
/target 
  • /namespace/pose จะรับตำแหน่งของเต่า จาก namesapce ที่ตั้งไว้
  • /target จะรับตำแหน่งของพิซซ่าที่จะเกิดขึ้น

และยังมี Service

/namespace/call_eat
/namespace/eat
/call_target 
  • /namesapce/call_eat จะเป็น Serive server โดยจะรับคำสั่งเมื่อจะกิน แต่จะกินในระยะ

  • /namespace/eat จะเป็น Service client จะ Call ไปหา turtlesim+ เพื่อกินพิซซ่าในระยะ

  • /call_target จะเป็น Service client จะ call ไปหา spawn_target_node เพื่อเรืยกหา พิซซ่า

spawn_target_node

ตัว spawn_target_node จะ pub topic

/target
  • /target จะเป็น topic จะส่งตำแหน่งของ พิซซ่าที่จะเกิดขึ้นมา

และสร้าง service

/call_target
/spawn_pizza
  • /call_target จะเป็น Service Server ที่รับค่าเมื่อมี node bot หริอ ling เมื่อมีตัวใดตัวนึงกิน พิซซ่าเข้าไป
  • /spawn_pizza จะเป็น Service client ที่จะส่งค่าเมื่อไปหา turtlesim+ เพื่อสร้างพิซซ่า

bot_node

ตัว bot_node สร้าง topic

/bot/cmd_vel
/bot/pose
/target
  • /bot/cmd_vel จะสร้าง cmd_vel เพื่อส่งค่าความเร็วไปควบคุมเต่า
  • /bot/pose จะรับตำแหน่งของเต่าเข้ามา
  • /target จะรับตำแหน่งของพิซซ่าที่ถูกสร้างขี้น

และสร้าง service

/bot/call_eat
  • /bot/call_eat จะเป็น Serive server โดยจะรับคำสั่งเมื่อจะกิน แต่จะกินในระยะ

การเล่นเบื้องต้น

เราจะควบคุมโดยใช้ก้าน Analog (วงสีฟ้า) เพื่อคุมคุมเต่า และปุ่ม B (วงสีม่วง) เพื่อเป็นการกิน

วงก้านกับปุ่ม

Analog

  • ดันไป ด้านหน้า --> ไปข้างหน้า
  • ดันไป ด้านหลัง --> ไปข้างหลัง
  • ด้นไป ทางซ้าย --> ไปด้านซ้าย
  • ดันไป ทางขาว --> ไปด้านขวา

ปุ่ม B

  • กดปุ่ม --> กินในพิซซ่าในระยะ

การติดตั้ง

1. Clone Project from github

git clone https://github.com/DenWaritthon/fun5mini_ws

cd fun5mini_ws

ถ้ายังไม่มี turtlesim_plus ของอารจารย์ PI ให้ติดตั้งก่อน โดยสามารถติดตั้งได้ตาม 1.1 ติดตั้ง turtlesim_plus ถ้ามีแล้ว สามารถข้ามขั้นตอนนี้ได้ ไปที่ 2. Build Project

1.1 ติดตั้ง turtlesim_plus อาจารย์ Pi

cd src/
git clone https://github.com/tchoopojcharoen/turtlesim_plus.git
cd ..

2. Build Project

ทำให้อยู้ใน Foler ws ของเราในที่นี้คือ fun5mini_ws

#อยู่ที่ Folder fun5mini_ws
colcon build #optional --parallel-workers 2 

(--parallel-workers เพื่อเพิ่ม CPU ในการประมวลผล ตอนรันครั้งแรกจะประมวลไม่ทันแล้วคอมค้าง จะใช้หรือไม่ใช้ก็ได้)

3. Sourcs Project

source install/setup.bash 

4. Launch Project

เรามี 3 ตัวเลือกได้แก่

  1. มีแค่ ling (คนเดียว) ไม่มี bot มาเล่นด้วย
ros2 launch turtle_game turtle_game_ling.launch.py
  1. มีแค่ bot ไม่มีคนมาเล่นด้วยมีแต่บอทมากินพิซซ่า
ros2 launch turtle_game turtle_game_bot.launch.py
  1. มีทั้ง ling และ bot สามารถเล่นพร้อมกันได้
ros2 launch turtle_game turtle_game_lingvsbot.launch.py

ผู้จัดทำ

  • 65340500004 ไกรวิชญ์ วิชาโคตร - @ThepokKung
  • 65340500050 วริทธิ์ธร คงหนู - @DenWaritthon

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages