Resources

Topics

RobWorkProject
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

#####################################################
# Template for building RobWork dependent projects
# - the src should contain code for putting into libraries
# - the plugins contain code for multiple RobWorkStudio plugins
# - the test for testing
# - the example dir for illustrativ examples of your project
#
# Use config.cmake to change default settings and edit this
# file for adding additional dependencies to external projects
#####################################################
#
# Test CMake version
#
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
# 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(WIN32)
# On Windows platforms, the RW/RWS installers create the necessary environment variables
IF(DEFINED ENV{RW_ROOT} AND DEFINED ENV{RWS_ROOT})
SET(RW_ROOT "$ENV{RW_ROOT}")
SET(RWSTUDIO_ROOT "$ENV{RWS_ROOT}")
ELSE()
SET(RW_ROOT "${ROOT}/../../../RobWork")
SET(RWSTUDIO_ROOT "${ROOT}/../../../RobWorkStudio")
ENDIF()
ELSEIF(UNIX)
# On Ubuntu platforms, the Debian packages install into /usr/local or /usr
IF(EXISTS "/usr/local/RobWork" AND EXISTS "/usr/local/RobWorkStudio")
SET(RW_ROOT "/usr/local/RobWork")
SET(RWSTUDIO_ROOT "/usr/local/RobWorkStudio")
ELSEIF(EXISTS "/usr/RobWork" AND EXISTS "/usr/RobWorkStudio")
SET(RW_ROOT "/usr/RobWork")
SET(RWSTUDIO_ROOT "/usr/RobWorkStudio")
ELSE()
SET(RW_ROOT "${ROOT}/../../../RobWork")
SET(RWSTUDIO_ROOT "${ROOT}/../../../RobWorkStudio")
ENDIF()
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)
INCLUDE_DIRECTORIES( ${ROBWORK_INCLUDE_DIRS} )
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()
# MOC
IF(RWS_USE_QT5)
QT5_WRAP_CPP(MocSrcFiles SamplePlugin.hpp)
ELSE()
QT4_WRAP_CPP(MocSrcFiles SamplePlugin.hpp)
ENDIF()
# Rcc the files:
IF(RWS_USE_QT5)
QT5_ADD_RESOURCES(RccSrcFiles resources.qrc)
ELSE()
QT4_ADD_RESOURCES(RccSrcFiles resources.qrc)
ENDIF()
# Add the source files to build
SET(SrcFiles SamplePlugin.cpp)
# The shared library to build:
ADD_LIBRARY(SamplePlugin MODULE ${SrcFiles} ${MocSrcFiles} ${RccSrcFiles})
TARGET_LINK_LIBRARIES(SamplePlugin ${ROBWORKSTUDIO_LIBRARIES} ${ROBWORK_LIBRARIES})
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 "plugin.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 /*RINGONHOOKPLUGIN_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