Skip to content

Commit

Permalink
modified the examples and update of README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
1r0b1n0 committed Nov 19, 2017
1 parent 748b3a9 commit 28e0be6
Show file tree
Hide file tree
Showing 11 changed files with 136 additions and 330 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
CMakeLists.txt.user*
/ros_lib

19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
# rosserial_qt

Client implementation for rosserial using the multi-platform Qt library.
For the moment it only supports TCP/IP, but it should be easily adapted to UDP (using QUdpSocket) or serial port (using QSerialPort) communications.
For the moment it only supports TCP/IP, but it could be easily adapted for UDP (using QUdpSocket) or serial port (using QSerialPort) communications.

## Usage

1. Generate the source files by running `rosrun rosserial_qt make_library.py <output_path>`
2. Compile your client application using the library. You should add the roslib library to you include path, and add the .cpp files to your source files.

Remarks:
* Unlike other clients of rosserial, the *NodeHandle* uses a dynamically sized buffer.
* There is no need to call spinOnce() manually : the *NodeHandle* will call spinOnce() periodically and on reception of new data
* C++11 support is required
* Unlike other client implementations of rosserial, the *NodeHandle* uses a dynamically sized buffer.
* There is no need to call spinOnce() manually : the *NodeHandle* will call spinOnce() periodically and on reception of new data, using the Qt event loopŝ
* Unlike rosserial_arduino using C-style arrays, the message generation script will convert arrays to std::vector and std::array

## Examples
Some simple examples of applications using the library are in the *test* directory
To use the examples you should first generate the *ros_lib* directory, for example like this :
```
roscd rosserial_qt
rosrun rosserial_qt make_library.py .
```

## Performance
CPU usage is quite close to native roscpp nodes :
CPU usage seems to be quite close to native roscpp nodes.
(TODO : add some data)

## Supported platforms
This library should work on all platforms supported by Qt (Linux, Windows, macos, ios, android ...)
This library should work on all platforms supported by Qt (Linux, Windows, Android, ios...)
I have succesfully tested this library on :
* Linux
* Windows

## Server-side configuration

The current implementation needs the message length to be coded on 4 bytes (rosserial's default is 2 bytes). This has been implemented in rosserial-server, but has to be configured with the *msg_length_bytes* parameter.
The current implementation needs the message length to be coded on 4 bytes (rosserial's default is 2 bytes). This has been implemented in rosserial-server (modified version available here : [https://github.com/1r0b1n0/rosserial](https://github.com/1r0b1n0/rosserial) ), but has to be configured with the *msg_length_bytes* parameter.
You should also configure the receive buffer size depending of your application.
The rosserial-python server implementation will not work, as it doesn't support 4 bytes coding of the message length.

Expand Down
2 changes: 2 additions & 0 deletions launch/rosserial_python_server.launch
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<launch>
<!-- Do not use ; does not yet work with 32bit messages -->

<node pkg="rosserial_python" type="serial_node.py" name="serial_node" output="screen">
<param name="port" value="tcp"/>
</node>
Expand Down
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/ros_lib
/build*/
*pro.user*
31 changes: 15 additions & 16 deletions test/Basic/Basic.pro
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,26 @@ CONFIG -= app_bundle

TEMPLATE = app

INCLUDEPATH += ../../src/ros_lib
INCLUDEPATH += ../ros_lib
INCLUDEPATH += ../../ros_lib

SOURCES += main.cpp \
../../src/ros_lib/duration.cpp \
../../src/ros_lib/time.cpp \
../../src/ros_lib/RosQtSocket.cpp \
../../src/ros_lib/node_handle.cpp \
../../ros_lib/duration.cpp \
../../ros_lib/time.cpp \
../../ros_lib/RosQtSocket.cpp \
../../ros_lib/node_handle.cpp \
node.cpp

DEFINES += QT_DEPRECATED_WARNINGS

HEADERS += \
../../src/ros_lib/ros/duration.h \
../../src/ros_lib/ros/msg.h \
../../src/ros_lib/ros/node_handle.h \
../../src/ros_lib/ros/publisher.h \
../../src/ros_lib/ros/ros.h \
../../src/ros_lib/ros/service_client.h \
../../src/ros_lib/ros/service_server.h \
../../src/ros_lib/ros/subscriber.h \
../../src/ros_lib/ros/time.h \
../../src/ros_lib/ros/RosQtSocket.h \
../../ros_lib/ros/duration.h \
../../ros_lib/ros/msg.h \
../../ros_lib/ros/node_handle.h \
../../ros_lib/ros/publisher.h \
../../ros_lib/ros/ros.h \
../../ros_lib/ros/service_client.h \
../../ros_lib/ros/service_server.h \
../../ros_lib/ros/subscriber.h \
../../ros_lib/ros/time.h \
../../ros_lib/ros/RosQtSocket.h \
node.h
16 changes: 8 additions & 8 deletions test/Basic/Basic.pro.user
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.4.1, 2017-11-17T18:18:00. -->
<!-- Written by QtCreator 4.0.2, 2017-11-19T23:20:42. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{b4f30ced-7693-4a4b-b90f-54df2b2dcced}</value>
<value type="QByteArray">{879e81b6-cba8-47ee-9e58-98b9c532cb3d}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
Expand Down Expand Up @@ -61,19 +61,19 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{95f7913d-7084-4d5d-9839-c0c5e82f5474}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{4dd4c15a-e3fc-4f28-ad62-08eacb8bfbf3}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robopec/Projects/Phenomobile/ws_phenofield/src/rosserial_qt/test/build-Basic-Desktop-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robin/rosserial/ws/src/rosserial_qt/test/build-Basic-Desktop-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
Expand Down Expand Up @@ -126,7 +126,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robopec/Projects/Phenomobile/ws_phenofield/src/rosserial_qt/test/build-Basic-Desktop-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/robin/rosserial/ws/src/rosserial_qt/test/build-Basic-Desktop-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
Expand Down Expand Up @@ -244,13 +244,13 @@
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Basic</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/robopec/Projects/Phenomobile/ws_phenofield/src/rosserial_qt/test/Basic/Basic.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/robin/rosserial/ws/src/rosserial_qt/test/Basic/Basic.pro</value>
<value type="bool" key="QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath">true</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">Basic.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/robopec/Projects/Phenomobile/ws_phenofield/src/rosserial_qt/test/build-Basic-Desktop-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">/home/robin/rosserial/ws/src/rosserial_qt/test/build-Basic-Desktop-Debug</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
Expand Down
36 changes: 36 additions & 0 deletions test/Basic/Basic.pro_
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
QT += core
QT -= gui
QT += network

CONFIG += c++11

TARGET = Basic
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

INCLUDEPATH += ../../src/ros_lib
INCLUDEPATH += ../ros_lib

SOURCES += main.cpp \
../../src/ros_lib/duration.cpp \
../../src/ros_lib/time.cpp \
../../src/ros_lib/RosQtSocket.cpp \
../../src/ros_lib/node_handle.cpp \
node.cpp

DEFINES += QT_DEPRECATED_WARNINGS

HEADERS += \
../../src/ros_lib/ros/duration.h \
../../src/ros_lib/ros/msg.h \
../../src/ros_lib/ros/node_handle.h \
../../src/ros_lib/ros/publisher.h \
../../src/ros_lib/ros/ros.h \
../../src/ros_lib/ros/service_client.h \
../../src/ros_lib/ros/service_server.h \
../../src/ros_lib/ros/subscriber.h \
../../src/ros_lib/ros/time.h \
../../src/ros_lib/ros/RosQtSocket.h \
node.h
Loading

0 comments on commit 28e0be6

Please sign in to comment.