diff options
author | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-23 11:40:23 +0100 |
---|---|---|
committer | Thomas Gubler <thomasgubler@gmail.com> | 2015-01-23 11:58:24 +0100 |
commit | d7e57061c976ba18c69d8be9949660e85f645126 (patch) | |
tree | 37d0c32f07f50777159e333eecb2c8f4b2ffbe8a | |
parent | 4ba57ad285884a2b01ebf8aac2c710ed63f7ffd3 (diff) | |
download | px4-firmware-d7e57061c976ba18c69d8be9949660e85f645126.tar.gz px4-firmware-d7e57061c976ba18c69d8be9949660e85f645126.tar.bz2 px4-firmware-d7e57061c976ba18c69d8be9949660e85f645126.zip |
generate message wrapper headers on ros
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | msg/templates/px4/ros/msg.h.template | 95 | ||||
-rw-r--r-- | msg/templates/px4/uorb/msg.h.template (renamed from msg/templates/px4/msg.h.template) | 10 | ||||
-rw-r--r-- | src/platforms/ros/px4_messages/px4_rc_channels.h | 25 |
6 files changed, 117 insertions, 36 deletions
diff --git a/.gitignore b/.gitignore index 764be0029..1c3f8fe04 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ tags *.orig src/modules/uORB/topics/* src/platforms/nuttx/px4_messages/* +src/platforms/ros/px4_messages/* Firmware.zip unittests/build *.generated.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 5488dbe9d..25822d719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,16 @@ include_directories( ${EIGEN_INCLUDE_DIRS} ) +## generate multiplatform wrapper headers +## note that the message header files are generated as in any ROS project with generate_messages() +set(MULTIPLATFORM_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/ros/px4_messages) +set(MULTIPLATFORM_TEMPLATE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/msg/templates/px4/ros) +set(TOPICHEADER_TEMP_DIR ${CMAKE_BINARY_DIR}/topics_temporary) +set(MULTIPLATFORM_PREFIX px4_) +add_custom_target(multiplatform_message_headers ALL ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/px_generate_uorb_topic_headers.py + -d ${CMAKE_CURRENT_SOURCE_DIR}/msg -o ${MULTIPLATFORM_HEADER_DIR} -e ${MULTIPLATFORM_TEMPLATE_DIR} + -t ${TOPICHEADER_TEMP_DIR} -p ${MULTIPLATFORM_PREFIX}) + ## Declare a cpp library add_library(px4 src/platforms/ros/px4_ros_impl.cpp @@ -133,7 +143,7 @@ add_library(px4 src/lib/mathlib/math/Limits.cpp src/modules/systemlib/circuit_breaker.cpp ) -add_dependencies(px4 ${PROJECT_NAME}_generate_messages_cpp) +add_dependencies(px4 ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) target_link_libraries(px4 ${catkin_LIBRARIES} @@ -143,7 +153,7 @@ target_link_libraries(px4 add_executable(publisher src/examples/publisher/publisher_main.cpp src/examples/publisher/publisher_example.cpp) -add_dependencies(publisher ${PROJECT_NAME}_generate_messages_cpp) +add_dependencies(publisher ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) target_link_libraries(publisher ${catkin_LIBRARIES} px4 @@ -153,7 +163,7 @@ target_link_libraries(publisher add_executable(subscriber src/examples/subscriber/subscriber_main.cpp src/examples/subscriber/subscriber_example.cpp) -add_dependencies(subscriber ${PROJECT_NAME}_generate_messages_cpp) +add_dependencies(subscriber ${PROJECT_NAME}_generate_messages_cpp multiplatform_message_headers) target_link_libraries(subscriber ${catkin_LIBRARIES} px4 @@ -226,13 +226,13 @@ updatesubmodules: MSG_DIR = $(PX4_BASE)msg UORB_TEMPLATE_DIR = $(PX4_BASE)msg/templates/uorb -MULTIPLATFORM_TEMPLATE_DIR = $(PX4_BASE)msg/templates/px4 +MULTIPLATFORM_TEMPLATE_DIR = $(PX4_BASE)msg/templates/px4/uorb TOPICS_DIR = $(PX4_BASE)src/modules/uORB/topics MULTIPLATFORM_HEADER_DIR = $(PX4_BASE)src/platforms/nuttx/px4_messages MULTIPLATFORM_PREFIX = px4_ TOPICHEADER_TEMP_DIR = $(BUILD_DIR)topics_temporary -GENMSG_PYTHONPATH = $(PX4_BASE)/Tools/genmsg/src -GENCPP_PYTHONPATH = $(PX4_BASE)/Tools/gencpp/src +GENMSG_PYTHONPATH = $(PX4_BASE)Tools/genmsg/src +GENCPP_PYTHONPATH = $(PX4_BASE)Tools/gencpp/src .PHONY: generateuorbtopicheaders generateuorbtopicheaders: diff --git a/msg/templates/px4/ros/msg.h.template b/msg/templates/px4/ros/msg.h.template new file mode 100644 index 000000000..176be0d09 --- /dev/null +++ b/msg/templates/px4/ros/msg.h.template @@ -0,0 +1,95 @@ +@############################################### +@# +@# PX4 ROS compatible message source code +@# generation for C++ +@# +@# This file generates the multiplatform wrapper +@# +@# EmPy template for generating <msg>.h files +@# Based on the original template for ROS +@# +@############################################### +@# Start of Template +@# +@# Context: +@# - file_name_in (String) Source file +@# - spec (msggen.MsgSpec) Parsed specification of the .msg file +@# - md5sum (String) MD5Sum of the .msg specification +@############################################### +/**************************************************************************** + * + * Copyright (C) 2013-2015 PX4 Development Team. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name PX4 nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* Auto-generated by genmsg_cpp from file @file_name_in */ + +@{ +import genmsg.msgs +import gencpp + +cpp_class = 'px4_%s'%spec.short_name +native_type = spec.short_name +topic_name = spec.short_name +}@ + +#pragma once + +@############################## +@# Generic Includes +@############################## +#include <uORB/topics/@(topic_name).h> +#include "platforms/px4_message.h" + +@############################## +@# Class +@############################## + +namespace px4 +{ + +class @(cpp_class) : + public PX4Message<@(native_type)> +{ +public: + @(cpp_class)() : + PX4Message<@(native_type)>() + {} + + @(cpp_class)(@(native_type) msg) : + PX4Message<@(native_type)>(msg) + {} + + ~@(cpp_class)() {} + + static PX4TopicHandle handle() {return "@(topic_name)";} +}; + +}; diff --git a/msg/templates/px4/msg.h.template b/msg/templates/px4/uorb/msg.h.template index ba0fbd4bf..2d4251107 100644 --- a/msg/templates/px4/msg.h.template +++ b/msg/templates/px4/uorb/msg.h.template @@ -56,7 +56,7 @@ import genmsg.msgs import gencpp cpp_class = 'px4_%s'%spec.short_name -uorb_struct = '%s_s'%spec.short_name +native_type = '%s_s'%spec.short_name topic_name = spec.short_name }@ @@ -76,15 +76,15 @@ namespace px4 { class __EXPORT @(cpp_class) : - public PX4Message<@(uorb_struct)> + public PX4Message<@(native_type)> { public: @(cpp_class)() : - PX4Message<@(uorb_struct)>() + PX4Message<@(native_type)>() {} - @(cpp_class)(@(uorb_struct) msg) : - PX4Message<@(uorb_struct)>(msg) + @(cpp_class)(@(native_type) msg) : + PX4Message<@(native_type)>(msg) {} ~@(cpp_class)() {} diff --git a/src/platforms/ros/px4_messages/px4_rc_channels.h b/src/platforms/ros/px4_messages/px4_rc_channels.h deleted file mode 100644 index 5e9dc72cd..000000000 --- a/src/platforms/ros/px4_messages/px4_rc_channels.h +++ /dev/null @@ -1,25 +0,0 @@ -#include "px4/rc_channels.h" -#include "platforms/px4_message.h" - -#pragma once -namespace px4 -{ - -class px4_rc_channels : - public PX4Message<rc_channels> -{ -public: - px4_rc_channels() : - PX4Message<rc_channels>() - {} - - px4_rc_channels(rc_channels msg) : - PX4Message<rc_channels>(msg) - {} - - ~px4_rc_channels() {} - - static PX4TopicHandle handle() {return "rc_channels";} -}; - -} |