-
Notifications
You must be signed in to change notification settings - Fork 14
System Plugin
Overview / HelloWorld Plugin Tutorial
Source: gazebo/examples/plugins/system_gui_plugin
이 튜토리얼에서는 /tmp/gazebo_frames
디렉토리에 이미지를 저장하도록 설계된 gzclient의 시스템 플러그인 소스파일을 작성한다.
~/gazebo_plugin_tutorial
로 이동하여 system_gui.cc
파일을 만든다:
$ cd ~/gazebo_plugin_tutorial
$ gedit system_gui.cc
아래 내용을 system_gui.cc
에 복사한다
#include <functional>
#include <gazebo/gui/GuiIface.hh>
#include <gazebo/rendering/rendering.hh>
#include <gazebo/gazebo.hh>
namespace gazebo
{
class SystemGUI : public SystemPlugin
{
/////////////////////////////////////////////
/// \brief Destructor
public: virtual ~SystemGUI()
{
this->connections.clear();
if (this->userCam)
this->userCam->EnableSaveFrame(false);
this->userCam.reset();
}
/////////////////////////////////////////////
/// \brief Called after the plugin has been constructed.
public: void Load(int /*_argc*/, char ** /*_argv*/)
{
this->connections.push_back(
event::Events::ConnectPreRender(
std::bind(&SystemGUI::Update, this)));
}
/////////////////////////////////////////////
// \brief Called once after Load
private: void Init()
{
}
/////////////////////////////////////////////
/// \brief Called every PreRender event. See the Load function.
private: void Update()
{
if (!this->userCam)
{
// Get a pointer to the active user camera
this->userCam = gui::get_active_camera();
// Enable saving frames
this->userCam->EnableSaveFrame(true);
// Specify the path to save frames into
this->userCam->SetSaveFramePathname("/tmp/gazebo_frames");
}
// Get scene pointer
rendering::ScenePtr scene = rendering::get_scene();
// Wait until the scene is initialized.
if (!scene || !scene->Initialized())
return;
// Look for a specific visual by name.
if (scene->GetVisual("ground_plane"))
std::cout << "Has ground plane visual\n";
}
/// Pointer the user camera.
private: rendering::UserCameraPtr userCam;
/// All the event connections.
private: std::vector<event::ConnectionPtr> connections;
};
// Register this plugin with the simulator
GZ_REGISTER_SYSTEM_PLUGIN(SystemGUI)
}
Load
와 Init
함수는 절대 주석처리(block)하면 안된다. Load
와 Init
함수는 시작할 때 가제보가 로드되기 전에 호출된다.
첫 번째 업데이트에서 사용자가 카메라 (그래픽 인터페이스에서 사용된 카메라)에 대한 포인터를 가져와 프레임 저장을 활성화 한다.
- 사용자의 카메라를 가져온다
this->userCam = gui::get_active_camera();
- 프레임 저장을 enable 한다
this->userCam->EnableSaveFrame(true);
- 프레임이 저장될 위치를 지정한다
this->userCam->SetSaveFramePathname("/tmp/gazebo_frames");
Hello WorldPlugin tutorial을 거쳤다면 ~/gazebo_plugin_tutorial/CMakeLists.txt
에 아래 내용을 추가한다.
add_library(system_gui SHARED system_gui.cc)
target_link_libraries(system_gui ${GAZEBO_LIBRARIES})
빌드하여 libsystem_gui.so
를 생성한다
$ cd ~/gazebo_plugin_tutorial/build
$ cmake ../
$ make
먼저 gzserver를 백그라운드(background)로 실행한다:
$ gzserver &
플러그인과 함께 클라이언트(client)를 실행한다:
$ gzclient -g libsystem_gui.so
현재의 플러그인으로 부터 저장된 이미지는 /tmp/gazebo_frames
에서 확인할 수 있다.
Note: 클라이언트를 종료한 후 백그라운드 서버를 종료해야함을 기억해야 한다. 백그라운드를 실행한 터미널에서 foreground로 변경해준다:
$ fg
그리고
Ctrl-C
를 눌러 종료한다. 아니면, gzserver process를 종료시킨다(kill):
$ killall gzserver
-
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]