-
Notifications
You must be signed in to change notification settings - Fork 14
GUI Overlay
Gazebo GUI 오버레이는 렌더링 윈도우의 꼭대기에있는 투명한 2D 레이어로 생각할 수 있습니다. QT 위젯은 플러그인 인터페이스를 통해이 레이어에 추가 할 수 있습니다. 메인 Gazebo 메뉴 바에서 View-> GUI Overlays를 클릭하여 모든 GUI 오버레이를 보이거나 감출 수 있습니다. 이 자습서에서는 GUI 오버레이 플러그인을 만들고 사용하여 Gazebo의 사용자 인터페이스를 만드는 방법을 설명합니다.
GUI 오버레이 기능을 보여주기 위해 두 가지 예가 사용됩니다. 첫 번째 예제에서는 구를 생성하는 버튼을 만들고 두 번째 예제에서는 현재 시뮬레이션 시간을 표시합니다. 이 두 예제는 Gazebo로 데이터를 보내고 Gazebo에서 데이터를 수신하는 방법을 보여줍니다.
https://bitbucket.org/osrf/gazebo/src/gazebo9/examples/plugins/gui_overlay_plugin_spawn/ 소스코드는 여기서 찾을 수 있습니다.
1.최신 Gazebo 버전을 설치하십시오.
2.설치 페이지의 지시 사항을 따르십시오.
mkdir ~/gazebo_gui_spawn
cd ~/gazebo_gui_spawn
-
GUI 오버레이 플러그인의 소스 코드 다운로드 (OsX에서 wget은 curl -OL로 바꿀 수 있음)
wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_spawn/GUIExampleSpawnWidget.hh wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_spawn/GUIExampleSpawnWidget.cc wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_spawn/CMakeLists.txt
4.헤더 파일을 살펴보십시오.
gedit GUIExampleSpawnWidget.hh
GUI 오버레이 플러그인은 GUIPlugin 클래스를 상속 받아 Qt의 Q_OBJECT 매크로를 사용해야합니다.
class GAZEBO_VISIBLE GUIExampleSpawnWidget : public GUIPlugin
{
Q_OBJECT
나머지 플러그인에는 사용자의 필요에 맞게 플러그인을 작성하는 데 필요한 코드가 포함될 수 있습니다. 이 예에서는 QT 슬롯을 사용하여 버튼을 누릅니다.
/// \brief Callback trigged when the button is pressed.
protected slots: void OnButton()
Gazebo의 공장 기능을 사용하여 SDF 스폰 메시지를 gzserver로 전송합니다.:
/// \brief Node used to establish communication with gzserver.
private: transport::NodePtr node;
/// \brief Publisher of factory messages.
private: transport::PublisherPtr factoryPub;
5.소스 파일을 살펴보십시오.
gedit GUIExampleSpawnWidget.cc
이 파일의 생성자는 QT를 사용하여 버튼을 만들고이를 OnButton 콜백에 연결합니다.:
// Create a push button, and connect it to the OnButton function
QPushButton *button = new QPushButton(tr("Spawn Sphere"));
connect(button, SIGNAL(clicked()), this, SLOT(OnButton()));
그 생성자는 또한 Gazebo의 전송 메커니즘에 연결하고 공장 게시자를 만듭니다:
// Create a node for transportation
this->node = transport::NodePtr(new transport::Node());
this->node->Init();
this->factoryPub = this->node->Advertise<msgs::Factory>("~/factory");
OnButton 콜백은 새로운 구형 SDF 문자열을 만듭니다.:
std::ostringstream newModelStr;
newModelStr << "<sdf version='" << SDF_VERSION << "'>"
<< msgs::ModelToSDF(model)->ToString("")
<< "</sdf>";
그리고 가제보에게 문자열을 보냅니다.:
msgs::Factory msg;
msg.set_sdf(newModelStr.str());
this->factoryPub->Publish(msg);
}
6.플러그인 컴파일
cd ~/gazebo_gui_spawn
mkdir build
cd build
cmake ../
make
7.이제 우리는 Gazebo가 플러그인을 찾을 수 있도록해야합니다. 빌드 디렉토리를 GAZEBO_PLUGIN_PATH 환경 변수에 추가하여이 작업을 수행 할 수 있습니다.
cd ~/gazebo_gui_spawn/build
export GAZEBO_PLUGIN_PATH=`pwd`:$GAZEBO_PLUGIN_PATH
위의 명령은 현재 쉘에서만 작동합니다. 새 터미널을 열 때 플러그인이 작동하는지 확인하려면 플러그인을 / usr / local / lib와 같은 일반적인 검색 경로 나 GAZEBO_PLUGIN_PATH 라이브러리에 지정된 경로 중 하나에 설치하십시오.
8.또한 오버레이 플러그인을로드해야한다고 Gazebo에 알릴 필요가 있습니다.
이 작업을 수행하는 데는 두 가지 방법이 있습니다.
1.SDF world file : GUI 플러그인을 포함하도록 world SDF 파일을 수정하십시오. 예 :
<?xml version="1.0" ?>
<sdf version="1.5">
<world name="default">
<gui>
<plugin name="sample" filename="libgui_example_spawn_widget.so"/>
</gui>
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
</world>
</sdf>
Tip: Download the world file above:
cd ~/gazebo_gui_spawn
wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_spawn/spawn_widget_example.world
2.GUI INI 파일 : Gazebo가 실행될 때마다 플러그인이로드되도록 ~ / .gazebo / gui.ini 파일을 수정하십시오.
gedit ~/.gazebo/gui.ini
Add the following lines:
[overlay_plugins]
filenames=libgui_example_spawn_widget.so
- 이제 Gazebo를 실행하면 렌더링 윈도우의 왼쪽 상단에 버튼이 나타납니다.
GUI 플러그인으로 사용자 정의 SDF 월드 파일을 생성 한 경우 :
gazebo spawn_widget_example.world
또는 ~ / .gazebo / gui.ini를 수정 한 경우
gazebo
Click on the button to spawn spheres.
이 예제의 소스 코드는 여기에서 찾을 수 있습니다.
1.작업 디렉토리 만들기 mkdir ~/gazebo_gui_time cd ~/gazebo_gui_time
2.GUI 오버레이 플러그인의 소스 코드 다운로드
wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_time/GUIExampleTimeWidget.hh
wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_time/GUIExampleTimeWidget.cc
wget https://bitbucket.org/osrf/gazebo/raw/gazebo9/examples/plugins/gui_overlay_plugin_time/CMakeLists.txt
3.헤더 파일을 살펴보십시오.
gedit GUIExampleTimeWidget.hh
첫 번째 예제와 마찬가지로이 플러그인은 GUIPlugin 클래스에서 상속 받고 Qt의 Q_OBJECT 매크로를 사용합니다.
class GAZEBO_VISIBLE GUIExampleTimeWidget : public GUIPlugin
{
Q_OBJECT
표시된 시뮬레이션 시간을 업데이트하기 위해 SetSimTime 신호를 스레드 안전 메커니즘으로 사용합니다.
/// \brief A signal used to set the sim time line edit.
/// \param[in] _string String representation of sim time.
signals: void SetSimTime(QString _string);
OnStats 콜백은 Gazebo에서 정보를 수신하는 데 사용됩니다.
/// \brief Callback that received world statistics messages.
/// \param[in] _msg World statistics message that is received.
protected: void OnStats(ConstWorldStatisticsPtr &_msg);
또한 Gazebo의 전송 메커니즘을 사용하여 Gazebo에서 메시지를 수신합니다.
/// \brief Node used to establish communication with gzserver.
private: transport::NodePtr node;
/// \brief Subscriber to world statistics messages.
private: transport::SubscriberPtr statsSub;
4.소스 파일을 살펴보십시오.
gedit GUIExampleTimeWidget.cc
생성자에서 시간을 표시하는 QLabel을 만들고이를 SetSimeTime 신호에 연결합니다.
// Create a time label
QLabel *timeLabel = new QLabel(tr("00:00:00.00"));
// Add the label to the frame's layout
frameLayout->addWidget(label);
frameLayout->addWidget(timeLabel);
connect(this, SIGNAL(SetSimTime(QString)),
timeLabel, SLOT(setText(QString)), Qt::QueuedConnection);
생성자는 Gazebo의 ~ / world_stats 항목에도 연결됩니다.
// Create a node for transportation
this->node = transport::NodePtr(new transport::Node());
this->node->Init("default");
this->statsSub = this->node->Subscribe("~/world_stats",
&GUIExampleTimeWidget::OnStats, this);
메시지를 받으면 OnStats 함수가 호출되고 표시된 시간이 업데이트됩니다.
void GUIExampleTimeWidget::OnStats(ConstWorldStatisticsPtr &_msg)
{
this->SetSimTime(QString::fromStdString(
this->FormatTime(_msg->sim_time())));
5.이전 튜토리얼과 같은 단계에 따라 플러그인을 컴파일하고 Gazebo에 찾아서 gui.ini 또는 SDF world 파일을 통해로드하십시오.
Tip: 다음과 같이 두 플러그인을 모두 gui.ini에 추가 할 수 있습니다.
gedit ~/.gazebo/gui.ini
[overlay_plugins] 섹션을 다음과 같이 변경하십시오.
[overlay_plugins]
filenames=libgui_example_spawn_widget.so:libgui_example_time_widget.so
이전 예제의 spawn sphere plugin과이 예제의 time plugin을 모두로드합니다.
6.Gazebo가 실행되면 스폰 버튼 오른쪽에 새 텍스트 상자에 시뮬레이션 시간이 표시됩니다.
gazebo
-
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]