RobWorkProject  0.7.0
Getting Started

Getting started with Lua

TODO: describe how to use lua (embedded vs external) together with RobWork and present some usefull scripts

From the command line

TODO: describe how lua can be used with RobWork from the commandline

RobWorkStudio embedded Lua

TODO: describe how lua can be used with RobWork both from the luaeditor plugin.

Getting started with Python

TODO: describe how to use python together with RobWork and present some usefull scripts

Compose a RobWork WorkCell

TODO: add a simple tutorial on creating a robwork workcell in the XML format

Command line tools

TODO: add all command line tools, split them in categories eg. geometry, grasping, planning

Writing RobWork programs

This section will present project templates that can be used for different types of project purposes. All templates are based on CMake.

Plugins

TODO: add

GUI Plugins

The GUI plugin is a Qt plugin for RobWorkStudio and as such is very different from the more general plugin structure in RobWork. The GUI plugin must inherit the rws::RobWorkStudioPlugin class and implement at least some of its functions. In this section we present two common project templates for creating a GUI plugin. The first template is the simplest and Qt gui functionality needs to be added in the hpp/cpp plugin file. The second template use the Qt designer to create an ui file which describe the layout.

Common to both templates is how to load the plugin into RobWorkStudio when they have compiled. The compiled output will be a dynamically linkable file (win32 its .dll and linux its .so). To use the plugin in your robworkstudio installation add the following lines to the RobWorkStudio.ini file in the RobWorkStudio.exe directory:

SamplePlugin\DockArea=2
SamplePlugin\Filename=libSamplePlugin
SamplePlugin\Path=PATH_TO_PLUGIN
SamplePlugin\Visible=true  

Not using Qt designer

This template can be found in the folder RobWorkStudio/example/pluginapp . The files include:

Lets start with CMakeLists.txt

# Test CMake version
cmake_minimum_required(VERSION 3.5)
# The name of the project.
project(PluginApp)
# Used to resolve absolute path names
set(ROOT ${CMAKE_CURRENT_SOURCE_DIR})
# Now set the RW/RWS root (edit this if necessary)
if(DEFINED ENV{RW_ROOT} AND DEFINED ENV{RWS_ROOT})
file(TO_CMAKE_PATH "$ENV{RW_ROOT}" RW_ROOT)
file(TO_CMAKE_PATH "$ENV{RWS_ROOT}" RWSTUDIO_ROOT)
else()
set(RW_ROOT "${ROOT}/../../../RobWork")
set(RWSTUDIO_ROOT "${ROOT}/../../../RobWorkStudio")
endif()
# If not the -DCMAKE_BUILD_TYPE option is given when running CMake, use Release as default.
if( NOT DEFINED CMAKE_BUILD_TYPE )
set(CMAKE_BUILD_TYPE Release)
endif()
message("-- Build type: " ${CMAKE_BUILD_TYPE})
# Include default settings for constructing a RobWork dependent project
set(RobWork_DIR ${RW_ROOT}/cmake)
find_package(RobWork REQUIRED)
link_directories( ${ROBWORK_LIBRARY_DIRS} )
message("-- RobWork found: " ${RW_ROOT})
# Include default settings for constructing a RobWorkStudio dependent project
set(RobWorkStudio_DIR ${RWSTUDIO_ROOT}/cmake)
find_package(RobWorkStudio REQUIRED)
include_directories( ${ROBWORKSTUDIO_INCLUDE_DIRS} )
link_directories( ${ROBWORKSTUDIO_LIBRARY_DIRS} )
message("-- RobWorkStudio found: " ${RWSTUDIO_ROOT})
# Set the output dir for generated libraries and binaries
if(MSVC)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${ROOT}/bin" CACHE PATH "Runtime directory" FORCE)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ROOT}/libs" CACHE PATH "Library directory" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${ROOT}/libs" CACHE PATH "Archive directory" FORCE)
else()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${ROOT}/bin/${CMAKE_BUILD_TYPE}" CACHE PATH "Runtime directory" FORCE)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${ROOT}/libs/${CMAKE_BUILD_TYPE}" CACHE PATH "Library directory" FORCE)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${ROOT}/libs/${CMAKE_BUILD_TYPE}" CACHE PATH "Archive directory" FORCE)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# Add the source files to build
set(SrcFiles SamplePlugin.cpp resources.qrc)
# The shared library to build:
add_library(SamplePlugin MODULE ${SrcFiles})
target_link_libraries(SamplePlugin PUBLIC ${ROBWORKSTUDIO_LIBRARIES} ${ROBWORK_LIBRARIES})
target_include_directories(SamplePlugin PUBLIC ${ROBWORKSTUDIO_INCLUDE_DIRS} ${ROBWORK_INCLUDE_DIRS})
message("-- " ${PROJECT_NAME} " done!")
#ifndef SAMPLEPLUGIN_HPP
#define SAMPLEPLUGIN_HPP
#include <RobWorkStudioConfig.hpp> // For RWS_USE_QT5 definition
#include <rws/RobWorkStudioPlugin.hpp>
class QPushButton;
class SamplePlugin: public rws::RobWorkStudioPlugin
{
Q_OBJECT
Q_INTERFACES( rws::RobWorkStudioPlugin )
#if RWS_USE_QT5
Q_PLUGIN_METADATA(IID "dk.sdu.mip.Robwork.RobWorkStudioPlugin/0.1" FILE "SamplePlugin.json")
#endif
public:
SamplePlugin();
virtual ~SamplePlugin();
virtual void open(rw::models::WorkCell* workcell);
virtual void close();
virtual void initialize();
private slots:
void clickEvent();
void stateChangedListener(const rw::kinematics::State& state);
private:
QPushButton* _btn0,*_btn1;
};
#endif /*SAMPLEPLUGIN_HPP*/
#include "SamplePlugin.hpp"
#include <QPushButton>
#include <QGridLayout>
#include <RobWorkStudio.hpp>
#include <boost/bind.hpp>
using namespace rw::math;
SamplePlugin::SamplePlugin():
RobWorkStudioPlugin("Sample", QIcon(":/pa_icon.png"))
{
QWidget* base = new QWidget(this);
QGridLayout* pLayout = new QGridLayout(base);
base->setLayout(pLayout);
this->setWidget(base);
int row = 0;
_btn0 = new QPushButton("Button0");
pLayout->addWidget(_btn0, row++, 0);
connect(_btn0, SIGNAL(clicked()), this, SLOT(clickEvent()));
_btn1 = new QPushButton("Button1");
pLayout->addWidget(_btn1, row++, 0);
connect(_btn1, SIGNAL(clicked()), this, SLOT(clickEvent()));
pLayout->setRowStretch(row,1);
}
SamplePlugin::~SamplePlugin()
{
}
void SamplePlugin::initialize() {
getRobWorkStudio()->stateChangedEvent().add(boost::bind(&SamplePlugin::stateChangedListener, this, _1), this);
}
void SamplePlugin::open(WorkCell* workcell)
{
}
void SamplePlugin::close() {
}
void SamplePlugin::clickEvent() {
QObject *obj = sender();
if(obj == _btn0){
log().info() << "Button 0 pressed!\n";
} else if(obj == _btn1){
log().info() << "Button 1 pressed!\n";
std::vector<VectorND<2> > vertices, hullvertices;
vertices.resize(100);
for(size_t i=0;i<vertices.size();i++){
vertices[i][0] = Random::ran(-10,10);
vertices[i][1] = Random::ran(-10,10);
}
QHullND<2> qhull;
qhull.rebuild(vertices);
hullvertices = qhull.getHullVertices();
std::cout << "\n INPUT: \n";
for(size_t i=0; i<vertices.size();i++){
std::cout << vertices[i][0] << "\t" << vertices[i][1] << "\n";
}
std::cout << "\n OUTPUT: \n";
for(size_t i=0; i<hullvertices.size();i++){
std::cout << hullvertices[i][0] << "\t" << hullvertices[i][1] << "\n";
}
}
}
void SamplePlugin::stateChangedListener(const State& state) {
log().info() << "State changed!";
}
#if !RWS_USE_QT5
#include <QtCore/qplugin.h>
Q_EXPORT_PLUGIN(SamplePlugin);
#endif

Using Qt designer

TODO: add the robworkstudio template projects

Programs

TODO: add template c++ projects that link to robwork libraries