Skip to content

swan0421/RobotControl2022

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

36 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

[2022-1] Robot Control ์‹ค์Šต

Gazebo Simulation for RoK-3.

๋ณธ ํŒจํ‚ค์ง€๋Š” ํœด๋จธ๋…ธ์ด๋“œ ๋กœ๋ด‡ RoK-3์˜ ๊ต์œก์šฉ Gazebo Simulation ์ž…๋‹ˆ๋‹ค. ์ด ๋ฌธ์„œ๋Š” ํŒจํ‚ค์ง€์˜ ์„ค๋ช… ๋ฌธ์„œ์ด๋ฉฐ, ๊ตฌ์„ฑ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

  • What to do before simulation

  • Simulation Manual

    1. Download and Setting RobotControl2022
    2. Libraries used in RobotControl2022 Package
    3. How to run RobotControl2022 package, Please read section 2 before proceeding.

What to do before simulation

  1. RoS-Kinetic install, link : https://wiki.ros.org/kinetic/Installation/Ubuntu
  2. Gazeobo-7 install, link : https://gazebosim.org/tutorials?cat=install&tut=install_ubuntu&ver=7.0
  3. Netbeans-IDE install, link : https://netbeans.apache.org/download/index.html

Java install before Netbeans install

  • terminal
sudo apt update
sudo apt install openjdk-8-jdk
java -version

Netbeans-IDE install

1. ๊ธฐ์กด NetBeans๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ๋Š”๊ฒฝ์šฐ
(NetBeans๊ฐ€ ์„ค์น˜๋˜์–ด ์žˆ์ง€ ์•Š๋‹ค๋ฉด 2๋ฒˆ์œผ๋กœ ์ด๋™)
  • terminal
cd /usr/local/netbeans-x.x
//๊ธฐ์กด netbeans์˜ uninstall.sh๊ฐ€ ์žˆ๋Š” ํด๋”๋กœ ์ด๋™. (x.x๋Š” ํ˜„์žฌ๋ฒ„์ „)
//๊ฒฝ๋กœ๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์œผ๋‹ˆ ํ™•์ธํ•  ๊ฒƒ

sudo sh uninstall.sh
//uninstall ์‹คํ–‰
2. Apache NetBeans 13 IDE install Guide
  1. NetBeans 13_linux install ๋งํฌ๋กœ ์ ‘์† ํ•ฉ๋‹ˆ๋‹ค.

  2. HTTP ํ•˜๋‹จ์˜ ๋งํฌ๋ฅผ ํด๋ฆญํ•˜์—ฌ .sh ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œ ๋ฐ›์Šต๋‹ˆ๋‹ค.
    .sh ํŒŒ์ผ์˜ ๋‹ค์šด๋กœ๋“œ ๊ฒฝ๋กœ๋Š” /home/user_name/Downloads ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
    (๋งŒ์•ฝ ๋‹ค์šด๋กœ๋“œ๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด, ๋งํฌ๋ฅผ ๋ณต์‚ฌํ•˜์—ฌ **wget -c** ๋ช…๋ น์–ด๋กœ ์ง์ ‘ ์‹คํ–‰)

  • terminal
---example---
wget -c https://dlcdn.apache.org/...linux-x64.sh
  1. ๋‹ค์šด๋กœ๋“œ๋œ ํŒŒ์ผ์— ์‹คํ–‰๊ถŒํ•œ์„ ๋ถ€์—ฌํ•˜๊ณ , ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  • terminal
chmod +x Apache-NetBeans-13-bin-linux-x64.sh

./Apache-NetBeans-13-bin-linux-x64.sh
3.Apache NetBeans 13 Setting
  1. ์„ค์น˜๋œ applications ์—์„œ Apache NetBeans IDE 13์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  2. ์ƒ๋‹จ Menu์˜ Tools ํ•ญ๋ชฉ ์ค‘ Plugins๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

  3. Plugins์ฐฝ์ด ๋œจ๋ฉด, Settings ์นดํ…Œ๊ณ ๋ฆฌ๋กœ ๋“ค์–ด๊ฐ€์„œ, NetBeans 8.2 Plugin Portal ์˜ Active์— ์ฒดํฌํ•œ ํ›„, Available Plugins ์นดํ…Œ๊ณ ๋ฆฌ๋กœ ๋“ค์–ด๊ฐ€ check for Newest ๋ฅผ ํด๋ฆญํ•˜์—ฌ ์—…๋ฐ์ดํŠธ๋ฅผ ์ง„ํ–‰ํ•ด ์ค๋‹ˆ๋‹ค.

  4. ์—…๋ฐ์ดํŠธ๋ฅผ ์ง„ํ–‰ ํ›„ ๋‚˜ํƒ€๋‚˜๋Š” c/c++ ์— install ์„ ์ฒดํฌํ•˜๊ณ  ํ•˜๋‹จ์˜ install ๋ฒ„ํŠผ์„ ํด๋ฆญํ•˜์—ฌ ์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

4. Create New Project
  1. ์ƒ๋‹จ Menu์˜ File ํ•ญ๋ชฉ์—์„œ New Project๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  2. Choose Project Step
    categories : C/C++
    Projects : C/C++ Project with Existing Sources

Choose Project

next

  1. Select Mode Step
    specify the folder : /home/user_name/catkin_ws
    (user_name ์˜ ๊ฒฝ์šฐ Ubuntu ์„ค์น˜ ์‹œ ์‚ฌ์šฉ์ž๊ฐ€ ์„ค์ •ํ•œ ์ด๋ฆ„์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.)
    Build Host : localhost
    Tool Collection : Default(GNU(GNU))
    Use Build Analyzer Check
    Configuration Mode : Custom

Select Mode

next

  1. Pre-Build Action Step
    Pre-Build Step is Required uncheck

Pre-Build Action

next

  1. Build Actions Step
    Working Directory : /home/user_name/catkin_ws
    Clean Command : devel/env.sh catkin_make clean
    Build Command : devel/env.sh catkin_make
    Clean and Build after Finish check

Build Actions

next

  1. Source Files Step
    Source FIle Folders : /home/user_name/catkin_ws

Source Files

next

  1. Code Assistance Configuration Step
    Automatic Configuration check

Code Assistance Configuration

next

  1. Project Name and Location Step
    Project Name : catkin_ws
    Project Location : /home/user_name/NetBeansProjects
    Project Folder : /home/user_name/NetBeansProjects/catkin_ws
    Build Host : localhost
    Tool Collection : Default(GNU(GNU))

Project Name and Location

ํ•˜๋‹จ์˜ ๋นจ๊ฐ„์ƒ‰ ๊ฒฝ๊ณ ๋Š” ์ด๋ฏธ ํ•ด๋‹น ํด๋”๊ฐ€ ์ด๋ฏธ ๋งŒ๋“ค์–ด์ ธ ์žˆ๋‹ค๋Š” ๊ฒฝ๊ณ ์ด๋ฏ€๋กœ, ์ฒ˜์Œ ์„ธํŒ…ํ•  ๊ฒฝ์šฐ์—๋Š” ๋“ฑ์žฅํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
finish


  1. GitHub์— ๋ฏธ๋ฆฌ ๊ฐ€์ž…ํ•œ ์ƒํƒœ๋ฉด, ํ•ด๋‹น ํŒจํ‚ค์ง€๋ฅผ ๊ณต๋™ ์ž‘์—…ํ•˜๋Š”๋ฐ ์žˆ์–ด ๋„์›€์ด๋ฉ๋‹ˆ๋‹ค.
    ๋”ฐ๋ผ์„œ, ๊ฐ€์ž…์„ ํฌ๋งํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ, Token password๋ฅผ ๋ฐœ๊ธ‰๋ฐ›๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
    ํ† ํฐ ๋ฐœ๊ธ‰ ๋ฐฉ๋ฒ• ์„ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
    ํ† ํฐ์€ ์ƒ์„ฑ ์ดํ›„์— ๋‹ค์‹œ ํ™•์ธํ•  ์ˆ˜ ์—†์œผ๋‹ˆ, ๋”ฐ๋กœ ์ €์žฅํ•ด๋‘์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

Simulation Manual

1.Download and Setting RobotControl2022

  1. RobotControl2022 Repository์— ์ ‘์†, link : https://github.com/swan0421/RobotControl2022

  2. ํ•ด๋‹น Repository์— ์ ‘์† ํ›„, ์šฐ์ธก ์ƒ๋‹จ์˜ Fork๋ฅผ ํด๋ฆญํ•˜์—ฌ, ๋ณธ์ธ์˜ Github Repository์— ๋ณต์ œ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
    (swan0421/Robotcontrol2022 -> User_id/Robotcontrol2022)

Fork๋ž€?  

๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ Github Repository ์—์„œ ๋‚ด๊ฐ€ ์ˆ˜์ •ํ•˜๊ฑฐ๋‚˜ ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ณ ์ž ํ•  ๋•Œ,  
ํ•ด๋‹น Repository๋ฅผ ๋‚ด Github Repository๋กœ ๊ทธ๋Œ€๋กœ ๋ณต์ œํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค.

Forkํ•œ Repository๋Š” ์›๋ณธ Repository์™€ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ์–ด,  
์›๋ณธ Repository์— ๋ณ€ํ™”๊ฐ€ ์ƒ๊ธฐ๋ฉด, Forkํ•œ Repository์— ๋ฐ˜์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.
  1. ๋ณต์ œ๋œ ๋ณธ์ธ์˜ Repository์— ์ ‘์† ํ›„์—, Code โ–ผ๋ผ๋Š” ์ดˆ๋ก์ƒ‰ ๋ฒ„ํŠผ์ด ์žˆ๋Š”๋ฐ ํด๋ฆญํ•˜์—ฌ URL ์ฃผ์†Œ (https:/~)์„ ๋ณต์‚ฌํ•˜๊ฑฐ๋‚˜,Download ZIP ์„ ํ†ตํ•ด ํ•ด๋‹น ํŒจํ‚ค์ง€๋ฅผ ๋‹ค์šด ๋ฐ›์Šต๋‹ˆ๋‹ค.

  2. NetBeans์˜ Team > Git > clone ์„ ๋ˆ„๋ฅธํ›„, Repository URL์„ https://github.com/User_id/RobotControl2022.git ์œผ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
    (๋ณธ์ธ์˜ Repository ๊ฒฝ๋กœ)
    (๋งŒ์•ฝ, NetBeans์—์„œ Team > Git > clone ๊ฒฝ๋กœ๊ฐ€ ๋ณด์ด์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, NetBeans ํ™”๋ฉด ์ขŒ์ธก์— ์žˆ๋Š” Projects ํŒจ๋„์—์„œ catkin_ws ๋ฅผ ํด๋ฆญํ•˜๋ฉด ๋ณด์ด๋ฉฐ, ์œ„์˜ ๊ฒฝ๋กœ๋Š” git์— ์—ฐ๋™๋˜์—ˆ์„ ๋•Œ ํ™œ์„ฑํ™”๋˜๋Š” ๊ฒฝ๋กœ์ด๋ฏ€๋กœ ์ฒ˜์Œ ์—ฐ๋™ํ•˜๋Š” ๊ฒƒ์ด๋ผ๋ฉด, Team > git > clone์œผ๋กœ ํ•ด๋„ ๋จ)
    User์—๋Š” GitHUB์˜ user_name์„ ์“ฐ๊ณ , Password์—๋Š” GitHUB์˜ Token password๋ฅผ ์ž…๋ ฅํ•œ ํ›„ NEXT๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

  3. Select Remote Branches๋ฅผ master* ๋กœ ์„ ํƒํ•˜๊ณ  Next๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

  4. Parent Directory๋ฅผ ์‚ฌ์šฉ์ž์˜ home/user_name/catkin_ws/src ๊ฒฝ๋กœ๋กœ ์„ค์ •ํ•˜๊ณ , Clone name์„ ์‚ฌ์šฉ์ž๊ฐ€ ์›ํ•˜๋Š” ์ด๋ฆ„์œผ๋กœ ์„ค์ •ํ•˜๊ณ , (์ฐธ๊ณ  : Clone Name์€ ํŒจํ‚ค์ง€์— ๊ด€๋ จ๋œ ์ด๋ฆ„์œผ๋กœ ์จ์„œ ๋‹ค๋ฅธ ํด๋”๋“ค๊ณผ ๊ตฌ๋ณ„ ์ง€์„ ๊ฒƒ) Checkout Branch๋Š” master* ๋กœ ์„ค์ •ํ•˜๊ณ , Remote Name์€ origin์œผ๋กœ ์„ค์ •ํ•œ ํ›„ Finish๋ฅผ ๋ˆ„๋ฆ…๋‹ˆ๋‹ค.

  5. ์‚ฌ์šฉ์ž์˜ catkin_ws/src ์œ„์น˜์— Step5์—์„œ ์„ค์ •ํ•œ Clone Name ์„ ๊ฐ–๋Š” ํด๋”๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ณ , ํด๋” ๋‚ด๋ถ€์— ํŒจํ‚ค์ง€ ๊ตฌ์„ฑ ํŒŒ์ผ๋“ค(world ํด๋”, src ํด๋”, launch ํด๋” ๋“ฑ)๊ณผ model ํด๋”(=rok3_model)์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

  6. rok3_model ํด๋”๋ฅผ HOME/.gazebo/models/ ํด๋”๋กœ ๊ฐ€์ ธ์™€์„œ ์‹œ๋ฎฌ๋ ˆ์ด์…˜์„ ์œ„ํ•œ ํŒŒ์ผ ์…‹ํŒ…์„ ๋งˆ๋ฌด๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
    (.gazebo ํด๋”๊ฐ€ ๋ณด์ด์ง€ ์•Š์œผ๋ฉด, Home ํด๋”์—์„œ, Ctrl+H ๋ฅผ ๋ˆŒ๋Ÿฌ์„œ ํด๋” ์ˆจ๊น€ ํ•ด์ œ๋ฅผ ํ•  ๊ฒƒ)
    (Gazebo๋ฅผ ์‹คํ–‰ํ•œ ์ ์ด ์—†๋Š” ๊ฒฝ์šฐ, ์ˆจ๊น€ํ•ด์ œ๋ฅผ ํ•˜์—ฌ๋„ ํด๋”๊ฐ€ ๋ณด์ด์ง€ ์•Š์„ ์ˆ˜ ์žˆ์Œ. Terminal ์—์„œ gazebo๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ํ•œ๋ฒˆ ์‹คํ–‰ํ•ด์ค€ ํ›„ ๋‹ค์‹œ ํ™•์ธํ•  ๊ฒƒ)

  7. ํŒจํ‚ค์ง€๋ฅผ ์ปดํŒŒ์ผํ•˜๊ธฐ ์œ„ํ•ด Netbeans์—์„œ ํ„ฐ๋ฏธ๋„ ์ฐฝ์„ ์—ด๊ฑฐ๋‚˜ ๊ธฐ๋ณธ ํ„ฐ๋ฏธ๋„ ์ฐฝ์—์„œ cd ~/catkin_ws && catkin_make์„ ์ž…๋ ฅํ•˜์—ฌ ์ปดํŒŒ์ผ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค. (ํ„ฐ๋ฏธ๋„ ์ฐฝ์ด ์•ˆ๋ณด์ธ๋‹ค๋ฉด, Netbeans์˜ ์ƒ๋‹จ Winodow > IDE Tools > Termianl ์„ ํด๋ฆญ)

  8. ๋งŒ์•ฝ, catkin_make๊ฐ€ ์•ˆ๋  ๊ฒฝ์šฐ, section 2๋ฅผ ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.


2.Libraries used in RobotControl2022 Package

Library Description
Eigen Eigen is a C++ template library for linear algebra: matrices, vectors, numerical solvers, and related algorithms.
RBDL RBDL library contains highly efficient code for both forward and inverse dynamics for kinematic chains and branched models.

Recommended to re-install RBDL

RBDL์˜ ์žฌ์„ค์น˜๋ฅผ ๊ถŒ์žฅํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ž๋งˆ๋‹ค root ๊ณ„์ • ํ˜น์€ user ๊ณ„์ •์œผ๋กœ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, Build ํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์žฌ์„ค์น˜๋ฅผ ํ•ด์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค. ๋ณธ ํŒจํ‚ค์ง€๋ฅผ root ๊ณ„์ •์—์„œ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ, ์žฌ์„ค์น˜๊ฐ€ ํ•„์š”์—†์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

RBDL Build

  1. RobotControl2022/src/RBDL/addons/urdfreader ํด๋” ๋‚ด์— ์žˆ๋Š” CMakeList.txt ํŒŒ์ผ์— include_directories๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ถ”๊ฐ€ํ•ด์ค๋‹ˆ๋‹ค.
  • Before :
IF (DEFINED ENV{ROS_ROOT})
	MESSAGE (STATUS "ROS found: $ENV{ROS_ROOT}")
	find_package(catkin REQUIRED COMPONENTS urdf)
  • After :
IF (DEFINED ENV{ROS_ROOT})
	MESSAGE (STATUS "ROS found: $ENV{ROS_ROOT}")
	find_package(catkin REQUIRED COMPONENTS urdf)
	include_directories(include ${catkin_INCLUDE_DIRS})
  1. RBDL make & install (build ํด๋”๊ฐ€ ์กด์žฌํ•  ๊ฒฝ์šฐ, ์‚ญ์ œ) RBDL ํด๋”์—์„œ ํ„ฐ๋ฏธ๋„ ์ฐฝ์„ ์ผœ๊ณ  ์•„๋ž˜์˜ ๋ช…๋ น์–ด๋ฅผ ์ž…๋ ฅํ•จ์œผ๋กœ์จ, RBDL ์žฌ์„ค์น˜๋ฅผ ๋๋ƒ…๋‹ˆ๋‹ค.
RBDL ํด๋” -> ์˜ค๋ฅธ์ชฝ ๋งˆ์šฐ์Šค ํด๋ฆญ -> Open in Terminal
๋˜๋Š”
cd catkin_ws/src/RobotControl2022/src/RBDL

mkdir build 
cd build/ 
cmake -D CMAKE_BUILD_TYPE=Release ../
cmake -D RBDL_BUILD_ADDON_URDFREADER=true ../
make 
sudo make install
  1. ๊ทธ๋ฆฌ๊ณ  ๋‹ค์‹œ ํŒจํ‚ค์ง€๋ฅผ ์ปดํŒŒ์ผํ•˜๊ธฐ ์œ„ํ•ด Netbeans์—์„œ ํ„ฐ๋ฏธ๋„ ์ฐฝ์„ ์—ด๊ฑฐ๋‚˜ ๊ธฐ๋ณธ ํ„ฐ๋ฏธ๋„ ์ฐฝ์—์„œ cd ~/catkin_ws && catkin_make์„ ์ž…๋ ฅํ•˜์—ฌ ์ปดํŒŒ์ผ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

3.How to run RobotControl2022 package

!! ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰ ์ „์— ํ™•์ธ ํ•ด์•ผํ•˜๊ฑฐ๋‚˜ ์…‹ํŒ… !!

  • Setting for Fixed / Floating Dynamics

HOME/.gazebo/models/rok3_modelํด๋”์— ์žˆ๋Š” model.sdf๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Fixed / Floating Dynamics์„ ์œ„ํ•ด <fixed to world>์˜ joint๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์…‹ํŒ… ํ•ฉ๋‹ˆ๋‹ค.

Setting Floating Dynamics in model.sdf

<?xml version="1.0"?>
<sdf version='1.6'>
  <model name='rok3_model'>
  <!--joint name="fixed to world" type="fixed">
      <parent>world</parent>
      <child>base_link</child>
    </joint-->
.
.
.
  </model>
</sdf>

Setting Fixed Dynamics in model.sdf

<?xml version="1.0"?>
<sdf version='1.6'>
  <model name='rok3_model'>
  <joint name="fixed to world" type="fixed">
      <parent>world</parent>
      <child>base_link</child>
    </joint>
.
.
.
  </model>
</sdf>

๋‹ค์Œ์œผ๋กœ, catkin_ws/src/RobotControl2022/worldsํด๋”์— ์žˆ๋Š” rok3.world๋ฅผ ์—ฝ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Fixed / Floating Dynamics์„ ์œ„ํ•ด ๋ชจ๋ธ์˜ <pose frame>์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์…‹ํŒ… ํ•ฉ๋‹ˆ๋‹ค.

Setting Floating Dynamics in rok3.world

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="rok3">
.
.
.
    <include>
      <uri>model:https://rok3_model</uri>
      <pose frame=''>0 0 0.947 0 0 0</pose>
      <plugin name="rok3_plugin" filename="librok3_pkgs.so"/> 
    </include>
  </world>
</sdf>

Setting Fixed Dynamics in rok3.world

<?xml version="1.0" ?>
<sdf version="1.6">
  <world name="rok3">
.
.
.
    <include>
      <uri>model:https://rok3_model</uri>
      <pose frame=''>0 0 1.947 0 0 0</pose>
      <plugin name="rok3_plugin" filename="librok3_pkgs.so"/> 
    </include>
  </world>
</sdf>
  • Check model.urdf file path for using RBDL in rok3_plugin.cc

  • rok3_plugin.cc๋Š” Gazebo main code ์ด๋ฉฐ, /catkin_ws/src/RobotControl2022/src์— ์žˆ์Šต๋‹ˆ๋‹ค.

  • ๊ทธ๋ฆฌ๊ณ , rok3_plugin.cc์—์„œ ์‚ฌ์šฉ์ž๋Š” ๋ฐ˜๋“œ์‹œ Load(physics::ModelPtr _model, sdf::ElementPtr /*_sdf*/)ํ•จ์ˆ˜์—์„œ, ์•„๋ž˜ ์ฝ”๋“œ ์˜ˆ์‹œ์™€ ๊ฐ™์ด Addons::URDFReadFromFile() ํ•จ์ˆ˜ ์•ˆ์— ์ ์šฉ๋˜์–ด ์žˆ๋Š” rok3_model.urdf์˜ ๊ฒฝ๋กœ๋ฅผ ํ™•์ธํ•ด์ฃผ์‹œ๊ณ , ํ‹€๋ฆฐ๋‹ค๋ฉด ๋ฐ”๋กœ์žก์•„์ฃผ์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

  • rok3_model.urdf๋Š” home/.gazebo/models/rok3_model/urdf ํด๋”์— ์žˆ์œผ๋ฉฐ, ํŒŒ์ผ ์†์„ฑ ํ™•์ธ์„ ํ†ตํ•ด ์ •ํ™•ํ•œ ๊ฒฝ๋กœ ํ™•์ธํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.
    rok3_model.sdf ํŒŒ์ผ ์˜ค๋ฅธ์ชฝ ํด๋ฆญ -> Properties -> Location ํ™•์ธ

In rok3_plugin.cc

void gazebo::rok3_plugin::Load(physics::ModelPtr _model, sdf::ElementPtr /*_sdf*/)
{
    /*
     * Loading model data and initializing the system before simulation 
     */

    //* model.sdf file based model data input to [physics::ModelPtr model] for gazebo simulation
    model = _model;

    //* [physics::ModelPtr model] based model update
    GetJoints();



    //* RBDL API Version Check
    int version_test;
    version_test = rbdl_get_api_version();
    printf(C_GREEN "RBDL API version = %d\n" C_RESET, version_test);

    //* model.urdf file based model data input to [Model* rok3_model] for using RBDL
    Model* rok3_model = new Model();
    Addons::URDFReadFromFile("/root/.gazebo/models/rok3_model/urdf/rok3_model.urdf", rok3_model, true, true);
    //โ†‘โ†‘โ†‘ Check File Path โ†‘โ†‘โ†‘
    nDoF = rok3_model->dof_count - 6; // Get degrees of freedom, except position and orientation of the robot
    joint = new ROBO_JOINT[nDoF]; // Generation joint variables struct

    //* initialize and setting for robot control in gazebo simulation
    SetJointPIDgain();


    //* setting for getting dt
    last_update_time = model->GetWorld()->GetSimTime();
    update_connection = event::Events::ConnectWorldUpdateBegin(boost::bind(&rok3_plugin::UpdateAlgorithm, this));

}

๋ชจ๋“  ์ค€๋น„ ๊ณผ์ •์ด ๋๋‚˜๋ฉด, catkin_make์„ ์ž…๋ ฅํ•˜์—ฌ ์ปดํŒŒ์ผ์„ ์ง„ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

cd ~/catkin_ws && catkin_make

์ตœ์ข…์ ์œผ๋กœ, ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ์‹œ๋ฎฌ๋ ˆ์ด์…˜ ์‹คํ–‰

roslaunch rok3_study_pkgs rok3.launch

1. ์‹ค์Šต 1 : 3-Link Planar Arm์˜ Forward Kinematics

  • void Practice() ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ
void Practice()
  • Practice() ํ•จ์ˆ˜์•ˆ์— matrix ์ƒ์„ฑ ๋ฐ ํ„ฐ๋ฏธ๋„์ฐฝ์— ์ธ์‡„ํ•˜๊ธฐ
  • cout ์‚ฌ์šฉ
std::cout << "C_IE = " << C_IE << std::endl;
  • Load ํ•จ์ˆ˜ ์ฒซ์ค„์— Practice() ํ•จ์ˆ˜ ์‚ฌ์šฉ
  • 3-link planar arm๋ฅผ ์œ„ํ•œ Homogeneous Transformation Matrix ๋งŒ๋“ค๊ธฐ
  • ๋ชจ๋“  ๋งํฌ์˜ ๊ธธ์ด๋Š” 1m๋กœ ๊ฐ€์ •
MatrixXd getTransformI0()
MatrixXd jointToTransform01(VectorXd q)
MatrixXd jointToTransform12(VectorXd q)
MatrixXd jointToTransform23(VectorXd q)
MatrixXd getTransform3E()
  • Forward Kinematics ๋งŒ๋“ค๊ธฐ
VectorXd jointToPosition(VectorXd q)
MatrixXd jointToRotMat(VectorXd q)
VectorXd rotToEuler(MatrixXd rotMat)	// EulerZYX

2. ์‹ค์Šต 2 : RoK-3์˜ Forward Kinematics

rok-3 frame

  • Homogeneous Transformation Matrix ๋งŒ๋“ค๊ธฐ
MatrixXd getTransformI0()
MatrixXd jointToTransform01(VectorXd q)
MatrixXd jointToTransform12(VectorXd q)
MatrixXd jointToTransform23(VectorXd q)
MatrixXd jointToTransform34(VectorXd q)
MatrixXd jointToTransform45(VectorXd q)
MatrixXd jointToTransform56(VectorXd q)
MatrixXd getTransform6E()
  • Forward Kinematics ๋งŒ๋“ค๊ธฐ
VectorXd jointToPosition(VectorXd q)
MatrixXd jointToRotMat(VectorXd q)
VectorXd rotToEuler(MatrixXd rotMat)
  • q=[10;20;30;40;50;60] ์ผ๋•Œ, End-effector์˜ position๊ณผ Rotation Matrix ๊ตฌํ•˜๊ธฐ
  • ์ด๋•Œ, Euler Angle ๊ตฌํ•˜๊ธฐ

์ œ์ถœ์ž๋ฃŒ

  1. source ์ฝ”๋“œ
  2. ์ถœ๋ ฅ๋œ ๊ฒฐ๊ณผ๋ฌผ capture ํŒŒ์ผ

3. ์‹ค์Šต 3 : RoK-3์˜ Geometric Jacobian

  • jointToPosJac ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ
MatrixXd jointToPosJac(VectorXd q)
{
    // Input: vector of generalized coordinates (joint angles)
    // Output: J_P, Jacobian of the end-effector translation which maps joint velocities to end-effector linear velocities in I frame.
    MatrixXd J_P = MatrixXd::Zero(3,6);
    MatrixXd T_I0(4,4), T_01(4,4), T_12(4,4), T_23(4,4), T_34(4,4), T_45(4,4), T_56(4,4), T_6E(4,4);
    MatrixXd T_I1(4,4), T_I2(4,4), T_I3(4,4), T_I4(4,4), T_I5(4,4), T_I6(4,4);
    MatrixXd R_I1(3,3), R_I2(3,3), R_I3(3,3), R_I4(3,3), R_I5(3,3), R_I6(3,3);
    Vector3d r_I_I1(3), r_I_I2(3), r_I_I3(3), r_I_I4(3), r_I_I5(3), r_I_I6(3);
    Vector3d n_1(3), n_2(3), n_3(3), n_4(3), n_5(3), n_6(3);
    Vector3d n_I_1(3),n_I_2(3),n_I_3(3),n_I_4(3),n_I_5(3),n_I_6(3);
    Vector3d r_I_IE(3);


    //* Compute the relative homogeneous transformation matrices.
    T_I0 = 
    T_01 = 
    T_12 = 
    T_23 = 
    T_34 =
    T_45 = 
    T_56 = 
    T_6E = 

    //* Compute the homogeneous transformation matrices from frame k to the inertial frame I.
    T_I1 = 
    T_I2 = 
    T_I3 = 
    T_I4 = 
    T_I5 =
    T_I6 = 

    //* Extract the rotation matrices from each homogeneous transformation matrix. Use sub-matrix of EIGEN. https://eigen.tuxfamily.org/dox/group__QuickRefPage.html
    R_I1 = T_I1.block(0,0,3,3);
    R_I2 = 
    R_I3 = 
    R_I4 = 
    R_I5 = 
    R_I6 = 

    //* Extract the position vectors from each homogeneous transformation matrix. Use sub-matrix of EIGEN.
    r_I_I1 = 
    r_I_I2 = 
    r_I_I3 = 
    r_I_I4 = 
    r_I_I5 = 
    r_I_I6 = 

    //* Define the unit vectors around which each link rotate in the precedent coordinate frame.
    n_1 << 0,0,1;
    n_2 << 
    n_3 << 
    n_4 << 
    n_5 << 
    n_6 << 

    //* Compute the unit vectors for the inertial frame I.
    n_I_1 = R_I1*n_1;
    n_I_2 = 
    n_I_3 = 
    n_I_4 = 
    n_I_5 = 
    n_I_6 = 

    //* Compute the end-effector position vector.
    r_I_IE = 


    //* Compute the translational Jacobian. Use cross of EIGEN.
    J_P.col(0) << n_I_1.cross(r_I_IE-r_I_I1);
    J_P.col(1) << 
    J_P.col(2) << 
    J_P.col(3) << 
    J_P.col(4) << 
    J_P.col(5) << 

    //std::cout << "Test, JP:" << std::endl << J_P << std::endl;

    return J_P;
}
  • jointToRotJac ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ
MatrixXd jointToRotJac(VectorXd q)
{
   // Input: vector of generalized coordinates (joint angles)
    // Output: J_R, Jacobian of the end-effector orientation which maps joint velocities to end-effector angular velocities in I frame.
    MatrixXd J_R(3,6);
    MatrixXd T_I0(4,4), T_01(4,4), T_12(4,4), T_23(4,4), T_34(4,4), T_45(4,4), T_56(4,4), T_6E(4,4);
    MatrixXd T_I1(4,4), T_I2(4,4), T_I3(4,4), T_I4(4,4), T_I5(4,4), T_I6(4,4);
    MatrixXd R_I1(3,3), R_I2(3,3), R_I3(3,3), R_I4(3,3), R_I5(3,3), R_I6(3,3);
    Vector3d n_1(3), n_2(3), n_3(3), n_4(3), n_5(3), n_6(3);

    //* Compute the relative homogeneous transformation matrices.


    //* Compute the homogeneous transformation matrices from frame k to the inertial frame I.


    //* Extract the rotation matrices from each homogeneous transformation matrix.


    //* Define the unit vectors around which each link rotate in the precedent coordinate frame.


    //* Compute the translational Jacobian.


    //std::cout << "Test, J_R:" << std::endl << J_R << std::endl;

    return J_R;
}
  • q=[10;20;30;40;50;60] ์ผ๋•Œ, Geometric Jacobian ๊ตฌํ•˜๊ธฐ

์ œ์ถœ์ž๋ฃŒ

  1. source ์ฝ”๋“œ
  2. ์ถœ๋ ฅ๋œ ๊ฒฐ๊ณผ๋ฌผ capture ํŒŒ์ผ

์‹ค์Šต 4 : RoK-3์˜ Pseudo-Inverse ํ•จ์ˆ˜์™€ rotTatToRotVec ํ•จ์ˆ˜ ๋งŒ๋“ค๋ฆฌ

  • pseudoInverseMat ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ
MatrixXd pseudoInverseMat(MatrixXd A, double lambda)
{
    // Input: Any m-by-n matrix
    // Output: An n-by-m pseudo-inverse of the input according to the Moore-Penrose formula
    MatrixXd pinvA;





    return pinvA;
}
  • rotMatToRotVec ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ : rotation matrix๋ฅผ ์ž…๋ ฅ์œผ๋กœ ๋ฐ›์•„์„œ rotation vector๋ฅผ ๋‚ด๋ณด๋‚ด๋Š” ํ•จ์ˆ˜
VectorXd rotMatToRotVec(MatrixXd C)
{
    // Input: a rotation matrix C
    // Output: the rotational vector which describes the rotation C
    Vector3d phi,n;
    double th;
    
    
    if(fabs(th)<0.001){
         n << 0,0,0;
    }
    else{

    }
        
    phi = th*n;
    
   
    return phi;
}

๊ณผ์ œ

  • q=[10;20;30;40;50;60] ์ผ๋•Œ, Jacobian์˜ pseudoInverse ๊ตฌํ•˜๊ธฐ
pinvJ = pseudoInverseMat(J);
  • q_des=[10;20;30;40;50;60], q_init=0.5q_des ์ผ๋•Œ, C_err(dph)=C_des*C_init.transpose() ๊ตฌํ•˜๊ธฐ
  • rotMatToRotVec ํ•จ์ˆ˜๋กœ dph๊ตฌํ•˜๊ธฐ
dph = rotMatToRotVec(C_err);

์ œ์ถœ์ž๋ฃŒ

  1. source ์ฝ”๋“œ
  2. ์ถœ๋ ฅ๋œ ๊ฒฐ๊ณผ๋ฌผ capture ํŒŒ์ผ => dph = [0.00;1.14;-0.19]

5. ์‹ค์Šต 5 : RoK-3์˜ Numerical Inverse Kinematics

  • inverseKinematics ํ•จ์ˆ˜ ๋งŒ๋“ค๊ธฐ
VectorXd inverseKinematics(Vector3d r_des, MatrixXd C_des, VectorXd q0, double tol)
{
    // Input: desired end-effector position, desired end-effector orientation, initial guess for joint angles, threshold for the stopping-criterion
    // Output: joint angles which match desired end-effector position and orientation
    double num_it;
    MatrixXd J_P(6,6), J_R(6,6), J(6,6), pinvJ(6,6), C_err(3,3), C_IE(3,3);
    VectorXd q(6),dq(6),dXe(6);
    Vector3d dr(3), dph(3);
    double lambda;
    
    //* Set maximum number of iterations
    double max_it = 200;
    
    //* Initialize the solution with the initial guess
    q=q0;
    C_IE = ...;
    C_err = ...;
    
    //* Damping factor
    lambda = 0.001;
    
    //* Initialize error
    dr = ... ;
    dph = ... ;
    dXe << dr(0), dr(1), dr(2), dph(0), dph(1), dph(2);
    
    ////////////////////////////////////////////////
    //** Iterative inverse kinematics
    ////////////////////////////////////////////////
    
    //* Iterate until terminating condition
    while (num_it<max_it && dXe.norm()>tol)
    {
        
        //Compute Inverse Jacobian
        J_P = ...;
        J_R = ...;

        J.block(0,0,3,6) = J_P;
        J.block(3,0,3,6) = J_R; // Geometric Jacobian
        
        // Convert to Geometric Jacobian to Analytic Jacobian
        dq = pseudoInverseMat(J,lambda)*dXe;
        
        // Update law
        q += 0.5*dq;
        
        // Update error
        C_IE = ...;
        C_err = ...;
        
        dr = ...;
        dph = ...;
        dXe << dr(0), dr(1), dr(2), dph(0), dph(1), dph(2);
                   
        num_it++;
    }
    std::cout << "iteration: " << num_it << ", value: " << q << std::endl;
    
    return q;
}

๊ณผ์ œ 1

  • q=[10;20;30;40;50;60] ์ผ๋•Œ, ์ด ๊ด€์ ˆ๊ฐ๋„์— ํ•ด๋‹นํ•˜๋Š” end-effoctor์˜ ๊ฐ’์„ r_des์™€ C_des๋กœ ์„ค์ •ํ•˜๊ณ ,
  • r_des์™€ C_des์— ๋Œ€ํ•œ joint angle ๊ตฌํ•˜๊ธฐ
void Practice()
{
        ...
        // q = [10;20;30;40;50;60]*pi/180;
        r_des = jointToPostion(q);
        C_des = jointToRotMat(q);
        
        q_cal = inverseKinematics(r_des, C_des, q*0.5, 0.001);
}

์ œ์ถœ์ž๋ฃŒ

  1. source ์ฝ”๋“œ
  2. ์ถœ๋ ฅ๋œ ๊ฒฐ๊ณผ๋ฌผ capture ํŒŒ์ผ

๊ณผ์ œ 2

  • Desired Pos = [0;0.105;-0.55] & Desired Orientation = Base
  • Result = [0;0;-63.756;127.512;-63.756]

6. ์‹ค์Šต 6 : RoK-3์˜ Motion Control

  • 1-cos ํ•จ์ˆ˜๋กœ trajectory ์ƒ์„ฑํ•˜๊ธฐ
double func_1_cos(double t, double, init, double final, double T)
{
        double des;
        
        ...
        
        return des;
}

๊ณผ์ œ

  1. 5์ดˆ๋™์•ˆ, ์ดˆ๊ธฐ์ž์„ธ์—์„œ ์‹ค์Šต5-2์˜ ์ž์„ธ๋กœ ์›€์ง์ด๊ธฐ in Joint Coordinates
  2. 5์ดˆ๋™์•ˆ, z๋ฐฉํ–ฅ์œผ๋กœ 0.2m ์ด๋™ํ•˜๊ธฐ(๋‹ค๋ฆฌ๋“ค๊ธฐ) in Cartesian Coordinates
  3. 5์ดˆ๋™์•ˆ 0.2m ๋‹ค๋ฆฌ๋“ค๊ธฐ, 5์ดˆ๋™์•ˆ 0.2m ๋‹ค๋ฆฌ๋‚ด๋ฆฌ๊ธฐ in Cartesian Coordinates
  4. 5์ดˆ๋™์•ˆ 0.2m ๋‹ค๋ฆฌ๋“ค๊ธฐ, 5์ดˆ๋™์•ˆ, z์ถ•์œผ๋กœ 90๋„ ํšŒ์ „ํ•˜๊ธฐ in Cartesian Coordinates

7. ์‹ค์Šต 7 : Static walking in the air (2-step walking)

  1. 5์ดˆ๋™์•ˆ, Walk ready ์ž์„ธ ๋งŒ๋“ค๊ธฐ
    • Right foot : Desired Pos = [0;0.105;-0.55] & Desired Orientation = Base) (Joint Coordinates)
    • Left foot : Desried Pos = [0;-0.105;-0.55] & Desired Orientation = Base) (Joint Coordinates)
  2. ์˜ค๋ฅธ๋ฐœ ์ง€์ง€ํ•˜๋ฉฐ, ์™ผ๋ฐœ ๋“ค๊ธฐ (Cartesian Coordinates)
  3. ๋‘๋ฐœ ์ง€์ง€ (Cartesian Coordinates)
  4. ์™ผ๋ฐœ ์ง€์ง€ํ•˜๋ฉฐ, ์˜ค๋ฅธ๋ฐœ ๋“ค๊ธฐ (Cartesian Coordinates)
  5. ๋‘๋ฐœ ์ง€์ง€ (Cartesian Coordinates)

๊ณผ์ œ

  • ๋•…์—์„œ ์‹ค์Šต 7 ์ˆ˜ํ–‰ํ•˜๊ธฐ

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published