forked from Archive/PX4-Autopilot
generate message wrapper headers on ros
This commit is contained in:
parent
4ba57ad285
commit
d7e57061c9
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
6
Makefile
6
Makefile
|
@ -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:
|
||||
|
|
|
@ -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)";}
|
||||
};
|
||||
|
||||
};
|
|
@ -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)() {}
|
|
@ -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";}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue