-
Notifications
You must be signed in to change notification settings - Fork 14
Plugins 101
플러그인은 shared library (공유 라이브러리)로 삽입한다. 플러그인은 standard C++ classes (표준 c++ 클래스)로 모든 기능에 직접 접근하여 사용 가능하다.
플러그인은 아래와 같은 이유로 유용하다:
- 개발자가 가제보의 거의 모든 부분을 제어할 수 있다
- 쉽게 공유할 수 있는 독립적인 루틴이다
- 실행중인 시스템에서 삽입 및 제거가 가능하다
이전 버전의 가제보에서는 controllers (컨트롤러)를 사용했다. 컨트롤러는 플러그인과 같은 방식으로 동작하지만, 정적으로 컴파일되었다 (statically compiled). 플러그인은 보다 더 융통성이 있어 (flexible), 사용자가 시뮬레이션에 포함할 기능을 고르고 선택할 수 있다.
아래와 같은 경우 플러그인을 사용해야 한다:
- 프로그래밍 방식 (programmatically)으로 시뮬레이션을 변경하기를 원하는 경우
예: 모델 이동, 이벤트 대응, 전제 조건을 가진 새로운 모델 삽입
- 전송 층 (transport layer)의 오버헤드(overhead) 없이 가제보와 빠른 인터페이스를 원하는 경우
예: 메시지의 직렬화 및 비 직렬화가 없다.
- 다른사람에게 도움이 되거나 공유하기를 원하는 코드가 있는 경우
현재는 6 가지 플러그인이 있다.
- World
- Model
- Sensor
- System
- Visual
- GUI (Graphical User Interface)
각 플러그인은 가제보의 다른 요소로 관리된다. 예를 들어, Model Plugin은 가제보의 특정 모델에 첨부하여 제어된다. 마찬가지로 World plugin 은 world에, Sensor plugin은 특정 센서에 적용된다. System plugin은 명령줄 (command line)에서 지정되고, 가제보가 시작하는 동안 로딩된다. 이 플러그인은 사용자가 시작 프로세스(Startup process)를 제어할 수 있도록 제공한다.
플러그인은 원하는 기능을 기반으로 선택해야 한다. World plugin은 물리 엔진, 주변 조명 등의 world 속성을 제어하는데 사용한다. Model plugin 은 모델의 조인트 및 상태를 제어하는데 사용한다. Sensor plugin은 센서 정보를 수집하고 센서 속성을 제어하는데 사용한다.
플러그인은 단순하게 설계되어있다. Bare bones world plugin은 몇 가지 멤버 함수가 있는 클래스로 구성되어있다.
먼저 debian에서 가제보를 설치했다면, 가제보 개발 파일을 설치했는지 확인해라. 만약 source로 가제보를 설치했다면, 이 단계를 무시할 수 있다. 만약 가제보 6가 아닌 다른 버전을 가지고 있다면, 버전을 6으로 바꾸어라.
$ sudo apt-get install libgazebo6-dev
그리고 새로운 플러그인을 위한 디렉토리와 .cc 파일을 만든다:
$ mkdir ~/gazebo_plugin_tutorial
$ cd ~/gazebo_plugin_tutorial
$ gedit hello_world.cc
hello_world.cc 에 아래 내용을 복사한다:
#include <gazebo/gazebo.hh>
namespace gazebo
{
class WorldPluginTutorial : public WorldPlugin
{
public: WorldPluginTutorial() : WorldPlugin()
{
printf("Hello World!\n");
}
public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
{
}
};
GZ_REGISTER_WORLD_PLUGIN(WorldPluginTutorial)
}위 코드는 the Gazebo sources에 있으며, 그에 맞는 CMakeLists.txt 파일도 함께있다: examples/plugins/hello_world/hello_world.cc
#include <gazebo/gazebo.hh>
namespace gazebo
{gazebo/gazebo.hh 파일은 기본 가제보 함수의 핵심 요소를 포함하고 있다. gazebo/physics/physics.hh, 또는 gazebo/rendering/rendering.hh, gazebo/sensors/sensors.hh는 필요시에 포함되어야하므로 포함되어있지 않다. 모든 플러그인은 가제보 네임스페이스 (namespace)가 있어야 한다.
class WorldPluginTutorial : public WorldPlugin
{
public: WorldPluginTutorial() : WorldPlugin()
{
printf("Hello World!\n");
}플러그인은 플러그인 타입을 상속해야 하며, 이 경우는 WorldPlugin class를 상속한 것이다.
public: void Load(physics::WorldPtr _world, sdf::ElementPtr _sdf)
{
}Load 함수의에서 다른 인자는 SDF인데, 로드된 SDF 파일에는 요소(elements)와 속성(attributes)이 포함되어있다.
GZ_REGISTER_WORLD_PLUGIN(WorldPluginTutorial)마지막으로, 플러그인은 GZ_REGISTER_WORLD_PLUGIN 매크로(macro)를 사용하여 시뮬레이터에 등록해야 한다. 이 매크로의 유일한 파라미터(parameter)는 클래스 이름이다. 각 플러그인 타입에 따라 사용하는 매크로가 있다: GZ_REGISTER_MODEL_PLUGIN, GZ_REGISTER_SENSOR_PLUGIN, GZ_REGISTER_GUI_PLUGIN, GZ_REGISTER_SYSTEM_PLUGIN and GZ_REGISTER_VISUAL_PLUGIN.
다음 섹션에서는 이 플러그인을 컴파일 하는 방법에 대하여 설명한다.
가제보가 올바르게 설치되어있는지 확인한다.
위 플러그인을 컴파일하려면 ~/gazebo_plugin_tutorial/CMakeLists.txt을 생성해야 한다:
$ gedit ~/gazebo_plugin_tutorial/CMakeLists.txt
CMakeLists.txt 파일에 아래 내용을 복사한다:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package(gazebo REQUIRED)
include_directories(${GAZEBO_INCLUDE_DIRS})
link_directories(${GAZEBO_LIBRARY_DIRS})
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")
add_library(hello_world SHARED hello_world.cc)
target_link_libraries(hello_world ${GAZEBO_LIBRARIES})모든 downstream software를 가제보에 컴파일하기 위해서는 c++11 플래그가 필요하다. 아래 내용을 추가한다:
list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")빌드 디렉토리를 생성한다
$ mkdir ~/gazebo_plugin_tutorial/build
$ cd ~/gazebo_plugin_tutorial/build
$ cmake ../
$ make
컴파일하면 가제보 시뮬레이션에 삽입할 수 있는 공유라이브러리가 생성된다: ~/gazebo_plugin_tutorial/build/libhello_world.so
마지막으로 라이브러리 경로를 GAZEBO_PLUGIN_PATH에 추가한다:
$ export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:~/gazebo_plugin_tutorial/build
Note: 이것은 현재 쉘 경로만 변경한다. 만약 새로운 터미널을 열때마다 너의 플러그인을 사용하고 싶다면,
~/.bashrc파일에 위 내용을 추가해라.
플러그인을 위와같이 공유 라이브러리로 컴파일하면, world, model, 또는 SDF 파일 (상세 정보는 SDF 문서 참고)에 연결할 수 있다. 시작 시 가제보는 SDF 파일을 분석(parsing)하고, 플러그인을 찾아 코드를 로드한다. 가제보가 플러그인을 찾을 수 있게 하는 것이 중요하다. 플러그인에 대한 전체 경로가 지정되었거나 플러그인이 GAZEBO_PLUGIN_PATH 환경변수의 경로에 존재해야 한다.
world 파일을 만들고 아래 코드를 복사한다. 예제 파일은 examples/plugins/hello_world/hello.world에서 찾을 수 있다.
$ gedit ~/gazebo_plugin_tutorial/hello.world
<?xml version="1.0"?>
<sdf version="1.4">
<world name="default">
<plugin name="hello_world" filename="libhello_world.so"/>
</world>
</sdf>이제 가제보와 함께 실행한다:
$ gzserver ~/gazebo_plugin_tutorial/hello.world --verbose
아래와 비슷한 결과를 볼 수 있다:
Gazebo multi-robot simulator, version 6.1.0
Copyright (C) 2012-2015 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org
[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 172.23.1.52```
Hello World!
-
Robot Simulators
-
Build a Robot
- Model structure and requirements
- How to contribute a model
- Make a model
- Make a Mobile Robot
- The relationship among Link, Joint and Axis
- Import Meshes
- Attach Meshes
- Add a Sensor to a Robot
- Make a Simple Gripper
- Attach Gripper to Robot
- Nested model
- Model Editor
- Animated Box
- Make an animated model(actor)
- Inertial parameters of triangle meshes
- Visibility layers
-
Model Editor
-
Build a World
-
Tools and utilities
-
Write a plugin
-
Plugins
-
Sensors
-
User input
-
Transport Library
-
Rendering Library
-
Connect to ROS
-
Ros Control - Advanced
-
DRCSIM for ROS Kinetic (Ubuntu16.04)
-
DRCSIM
- DRC Simulator installation
- Launchfile options
- Spawn Atlas into a custom world
- Animate joints
- Atlas Keyboard Teleoperation over ROS
- Teleoperate atlas with a music mixer
- Visualization and logging
- Atlas MultiSense SL head
- How to use the Atlas Sim Interface
- Atlas fake walking
- Grasp with Sandia hands
- DRC vehicle tele-operation
- DRC vehicle tele operation with Atlas
- Sending joint commands with ROS
- Atlas control over ROS with python
- Modify environment
- Atlas switching control modes
- Atlas Controller Synchronization over ROS Topics
- Changing Viscous Damping Coefficients Over ROS Service
- Running BDI controller demo
- Using the RobotiQ 3 Finger Adaptive Robot Gripper
- BDI Atlas Robot Interface 3.0.0 Stand In Example
-
HAPTIX
- HAPTIX software install and update
- HAPTIX C API
- HAPTIX Matlab and Octave API
- HAPTIX Simulation World API
- HAPTIX Teleoperation
- HAPTIX environment setup
- HAPTIX Optitrack Control
- HAPTIX Tactor Glove
- HAPTIX Simulation World API with Custom World Example
- HAPTIX logging
- HAPTIX DEKA Luke hand installation
- HAPTIX Simulation Scoring Plugin Example
-
MoveIt!
-
Rviz & rqt & ROSBAG
- Control Theory
- TroubleShooting
- Solidworks model to URDF
- ROS-Gazebo with MATLab
- MATLab installation in Linux
- [Gazebo simulation with MATLab]