Commit 09fa2477 by Sebastian Stern

fixed publisher/subscriber generation for use with ADTF 3.5.X and ROS2 Crystal…

fixed publisher/subscriber generation for use with ADTF 3.5.X and ROS2 Crystal && refactored subscriber base class
parent 35e68a0e

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -25,10 +25,13 @@ Alternativ kann auch die beiliegende virtualenv genutzt werden.
<td>Ardent Apalone</td>
<td>ament</td>
</tr>
<tr>
<td>Bouncy Bolson</td>
<td>colcon</td>
</tr>
</tr>
<td>Crystal Clemmys</td>
<td>colcon</td>
</tr>
</table>
Es ist darauf zu achten das für die jewailige ROS2-Version passende Buildsystem zu verwenden,
......@@ -38,8 +41,8 @@ da sonst die ROS2 Installation beschädigt werden kann.
* Version >= 3.3.1
### Compliler
* MSVC, Visual Studio 2015 oder 2017 Abhängig von ROS2 Release
* GCC 5.4 on Ubuntu 1604
* MSVC, Visual Studio 2015 und evtl. 2017 Abhängig von ROS2 Release
* GCC >= 5.4 auf Ubuntu
## übersicht
<img src="./documentation/pics/ADTF_ROS2_codegen.png" alt="overview"/>
......@@ -76,7 +79,9 @@ ament build --only-package adtf_ros2_system_service
```
colcon build --packages-select adtf_ros2_system_service
```
Nach dem Build und Install Vorgang liegen die Plugindateien im angegebenen Pfad.
Unter Umständen kanne s sein das man die Umgebungsvariable ADTF_DIR setzen muss.
Nach dem Build und Install Vorgang liegen die Plugindateien unter ADTF_DIR/bin/ros2
### Umgebung in ADTF
#### Windows
......
name: codegen_py
channels:
- defaults
dependencies:
- pip=10.0.1=py36_0
- python=3.6.5
- setuptools=40.0.0=py36_0
- wheel=0.31.1=py36_0
- pyparsing
- pip:
- prettytable
- colorama
- cogapp
- empy
prefix: C:\Anaconda3\envs\codegen_py
......@@ -9,8 +9,15 @@ function(adtf_ros2_install_subscriber TARGET INSTALL_PATH)
adtf_add_plugin(${TARGET} ${SOURCES})
target_link_libraries(${TARGET} adtf::systemsdk adtf::filtersdk)
ament_target_dependencies(${TARGET} ${ARGN})
if(WIN32)
set(PLUGIN_DESCRIPTION_GENERATOR adtf_plugin_description_generator.exe)
else()
set(PLUGIN_DESCRIPTION_GENERATOR adtf_plugin_description_generator)
endif()
adtf_install_filter(${TARGET} ${INSTALL_PATH})
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${ADTF_DIR}/bin/adtf_plugin_description_generator.exe -plugin=${INSTALL_PATH}/${TARGET}.adtfplugin -output=${INSTALL_PATH}/${TARGET}.plugindescription)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${ADTF_DIR}/bin/${PLUGIN_DESCRIPTION_GENERATOR} -plugin=${INSTALL_PATH}/${TARGET}.adtfplugin -output=${INSTALL_PATH}/${TARGET}.plugindescription)
endfunction()
##########################################################
......@@ -24,20 +31,13 @@ function(adtf_ros2_install_publisher TARGET INSTALL_PATH)
adtf_add_plugin(${TARGET} ${SOURCES})
target_link_libraries(${TARGET} adtf::systemsdk adtf::filtersdk)
ament_target_dependencies(${TARGET} ${ARGN})
if(WIN32)
set(PLUGIN_DESCRIPTION_GENERATOR adtf_plugin_description_generator.exe)
else()
set(PLUGIN_DESCRIPTION_GENERATOR adtf_plugin_description_generator)
endif()
adtf_install_filter(${TARGET} ${INSTALL_PATH})
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${ADTF_DIR}/bin/adtf_plugin_description_generator.exe -plugin=${INSTALL_PATH}/${TARGET}.adtfplugin -output=${INSTALL_PATH}/${TARGET}.plugindescription)
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${ADTF_DIR}/bin/${PLUGIN_DESCRIPTION_GENERATOR} -plugin=${INSTALL_PATH}/${TARGET}.adtfplugin -output=${INSTALL_PATH}/${TARGET}.plugindescription)
endfunction()
############################################################################
# This function installs a system service with linked ros cpp dependencies #
############################################################################
function(adtf_ros2_install_service TARGET INSTALL_PATH)
set(SOURCES
src/${TARGET}.cpp
src/${TARGET}.h)
adtf_add_plugin(${TARGET} ${SOURCES})
target_link_libraries(${TARGET} adtf::systemsdk adtf::filtersdk)
ament_target_dependencies(${TARGET} ${ARGN})
adtf_install_service(${TARGET} ${INSTALL_PATH})
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${ADTF_DIR}/bin/adtf_plugin_description_generator.exe -plugin=${INSTALL_PATH}/${TARGET}.adtfplugin -output=${INSTALL_PATH}/${TARGET}.plugindescription)
endfunction()
\ No newline at end of file
......@@ -22,17 +22,16 @@
using namespace adtf::util;
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::system;
using namespace adtf::mediadescription;
template<class T>
class cRos2SampleReader : public cSampleReader
class cRos2SampleReader : public adtf::streaming::ant::cSampleReader
{
public:
~cRos2SampleReader() = default;
virtual ~cRos2SampleReader() = default;
cRos2SampleReader(const tChar* strStreamName, const tChar* strDDL);
tResult Push(const IStreamItem& oStreamItem, tTimeStamp tmTime) override;
......@@ -59,7 +58,7 @@ private:
std::shared_ptr<rclcpp::Publisher<msgType>> m_pPublisher;
std::shared_ptr<rclcpp::Node> m_pNode;
cSampleCodecFactory m_oCodecFactory;
adtf::streaming::antcSampleCodecFactory m_oCodecFactory;
tVoid Logging(const std::pair<cString, cVariant> &oItem) const;
};
......@@ -142,7 +141,9 @@ tVoid cRos2SampleReader<T>::Logging(const std::pair<cString, cVariant> &oItem) c
template<class T>
class cRos2PublisherBase : public cSampleStreamingSink, public cRos2SampleReader<T>
class cRos2PublisherBase :
public adtf::streaming::catwo::cSampleStreamingSink,
public cRos2SampleReader<T>
{
public:
......@@ -201,7 +202,7 @@ tResult cRos2PublisherBase<T>::Construct()
object_ptr<IStreamType> pType;
RETURN_IF_FAILED(create_adtf_default_stream_type(cRos2SampleReader<T>::m_strStreamName, cRos2SampleReader<T>::m_strDDL, pType));
RETURN_IF_FAILED(create_pin(*this, *this, "in", pType));
RETURN_IF_FAILED(adtf::streaming::ant::create_pin(*this, *this, "in", pType));
RETURN_NOERROR;
}
......
......@@ -15,20 +15,16 @@
#include <memory>
#include <map>
#include <a_utils_platform_inc.h>
#include <adtf_base.h>
#include <adtf_systemsdk.h>
#include <adtf_streaming3.h>
#include <rclcpp/rclcpp.hpp>
#include <adtf3.h>
using namespace adtf::util;
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::system;
using namespace adtf::mediadescription;
using std::placeholders::_1;
template<class T>
class cRos2SubscriberBase : public cSampleStreamingSource
class cRos2SubscriberBase : public adtf::streaming::catwo::cSampleStreamingSource
{
public:
......@@ -48,30 +44,30 @@ protected:
virtual tVoid Mapping(const msgSharedPtrType pMsg) = 0;
virtual tVoid MakeMap() = 0;
std::map<cString, cVariant> m_oMap;
std::map<adtf_util::cString, adtf_util::cVariant> m_oMap;
private:
property_variable<cString> m_propNodeName;
property_variable<cString> m_propTopicName;
property_variable<tBool> m_propLogging;
adtf::base::ant::property_variable<adtf_util::cString> m_propNodeName;
adtf::base::ant::property_variable<adtf_util::cString> m_propTopicName;
adtf::base::ant::property_variable<tBool> m_propLogging;
tBool m_bLogging;
cString m_strNodeName;
cString m_strTopicName;
cString m_strStreamName;
cString m_strDDL;
tBool m_bLogging;
adtf_util::cString m_strNodeName;
adtf_util::cString m_strTopicName;
adtf_util::cString m_strStreamName;
adtf_util::cString m_strDDL;
std::shared_ptr<rclcpp::Node> m_pNode;
std::shared_ptr<rclcpp::Subscription<msgType>> m_pSubscription;
object_ptr<adtf::services::IReferenceClock> m_pClock;
adtf::ucom::object_ptr<adtf::services::ant::IReferenceClock> m_pClock;
kernel_thread m_oThread;
cSampleWriter m_oWriter;
cSampleCodecFactory m_oCodecFactory;
std::unique_ptr<adtf::system::kernel_thread> m_pThread;
adtf::streaming::ant::cSampleWriter m_oWriter;
adtf::mediadescription::ant::cSampleCodecFactory m_oCodecFactory;
tVoid Callback(const msgSharedPtrType pMsg);
tVoid Logging(const std::pair<cString, cVariant> &oItem) const;
tVoid Logging(const std::pair<adtf_util::cString, adtf_util::cVariant> &oItem) const;