diff --git a/CMakeLists.txt b/CMakeLists.txt index 019984d9ba..30ded0df5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -295,11 +295,11 @@ add_definitions(${definitions}) #============================================================================= # source code generation # -file(GLOB_RECURSE msg_files msg/*.msg) +file(GLOB msg_files msg/*.msg) px4_generate_messages(TARGET msg_gen MSG_FILES ${msg_files} OS ${OS} - DEPENDS git_genmsg git_gencpp + DEPENDS git_genmsg git_gencpp prebuild_targets ) px4_generate_parameters_xml(OUT parameters.xml BOARD ${BOARD}) px4_generate_airframes_xml(OUT airframes.xml BOARD ${BOARD}) diff --git a/Makefile b/Makefile index df7ebeafe5..3f9922144f 100644 --- a/Makefile +++ b/Makefile @@ -155,6 +155,9 @@ px4-stm32f4discovery_default: px4fmu-v2_ekf2: $(call cmake-build,nuttx_px4fmu-v2_ekf2) +px4fmu-v2_lpe: + $(call cmake-build,nuttx_px4fmu-v2_lpe) + mindpx-v2_default: $(call cmake-build,nuttx_mindpx-v2_default) diff --git a/Tools/px_generate_uorb_topic_headers.py b/Tools/px_generate_uorb_topic_headers.py index 7ed0b3af19..0dba2468f3 100755 --- a/Tools/px_generate_uorb_topic_headers.py +++ b/Tools/px_generate_uorb_topic_headers.py @@ -49,6 +49,7 @@ sys.path.append(px4_tools_dir + "/genmsg/src") sys.path.append(px4_tools_dir + "/gencpp/src") try: + import em import genmsg.template_tools except ImportError as e: print("python import error: ", e) @@ -74,24 +75,75 @@ __license__ = "BSD" __email__ = "thomasgubler@gmail.com" -msg_template_map = {'msg.h.template': '@NAME@.h'} -srv_template_map = {} -incl_default = ['std_msgs:./msg/std_msgs'] -package = 'px4' +TEMPLATE_FILE = 'msg.h.template' +OUTPUT_FILE_EXT = '.h' +INCL_DEFAULT = ['std_msgs:./msg/std_msgs'] +PACKAGE = 'px4' +TOPICS_TOKEN = '# TOPICS ' -def convert_file(filename, outputdir, templatedir, includepath): +def get_multi_topics(filename): """ - Converts a single .msg file to a uorb header + Get TOPICS names from a "# TOPICS" line """ - #print("Generating headers from {0}".format(filename)) - genmsg.template_tools.generate_from_file(filename, - package, - outputdir, - templatedir, - includepath, - msg_template_map, - srv_template_map) + ofile = open(filename, 'r') + text = ofile.read() + result = [] + for each_line in text.split('\n'): + if each_line.startswith (TOPICS_TOKEN): + topic_names_str = each_line.strip() + topic_names_str = topic_names_str.replace(TOPICS_TOKEN, "") + result.extend(topic_names_str.split(" ")) + ofile.close() + return result + + +def generate_header_from_file(filename, outputdir, templatedir, includepath): + """ + Converts a single .msg file to a uorb header file + """ + msg_context = genmsg.msg_loader.MsgContext.create_default() + full_type_name = genmsg.gentools.compute_full_type_name(PACKAGE, os.path.basename(filename)) + spec = genmsg.msg_loader.load_msg_from_file(msg_context, filename, full_type_name) + topics = get_multi_topics(filename) + if includepath: + search_path = genmsg.command_line.includepath_to_dict(includepath) + else: + search_path = {} + genmsg.msg_loader.load_depends(msg_context, spec, search_path) + md5sum = genmsg.gentools.compute_md5(msg_context, spec) + if len(topics) == 0: + topics.append(spec.short_name) + em_globals = { + "file_name_in": filename, + "md5sum": md5sum, + "search_path": search_path, + "msg_context": msg_context, + "spec": spec, + "topics": topics + } + + # Make sure output directory exists: + if not os.path.isdir(outputdir): + os.makedirs(outputdir) + + template_file = os.path.join(templatedir, TEMPLATE_FILE) + output_file = os.path.join(outputdir, spec.short_name + OUTPUT_FILE_EXT) + + if os.path.isfile(output_file): + return False + + ofile = open(output_file, 'w') + # todo, reuse interpreter + interpreter = em.Interpreter(output=ofile, globals=em_globals, options={em.RAW_OPT:True,em.BUFFERED_OPT:True}) + if not os.path.isfile(template_file): + ofile.close() + os.remove(output_file) + raise RuntimeError("Template file %s not found in template dir %s" % (template_file, templatedir)) + interpreter.file(open(template_file)) #todo try + interpreter.shutdown() + ofile.close() + return True def convert_dir(inputdir, outputdir, templatedir): @@ -122,7 +174,7 @@ def convert_dir(inputdir, outputdir, templatedir): if (maxinputtime != 0 and maxouttime != 0 and maxinputtime < maxouttime): return False - includepath = incl_default + [':'.join([package, inputdir])] + includepath = INCL_DEFAULT + [':'.join([PACKAGE, inputdir])] for f in os.listdir(inputdir): # Ignore hidden files if f.startswith("."): @@ -133,11 +185,7 @@ def convert_dir(inputdir, outputdir, templatedir): if not os.path.isfile(fn): continue - convert_file(fn, - outputdir, - templatedir, - includepath) - + generate_header_from_file(fn, outputdir, templatedir, includepath) return True @@ -151,15 +199,15 @@ def copy_changed(inputdir, outputdir, prefix='', quiet=False): if not os.path.isdir(outputdir): os.makedirs(outputdir) - for f in os.listdir(inputdir): - fni = os.path.join(inputdir, f) + for input_file in os.listdir(inputdir): + fni = os.path.join(inputdir, input_file) if os.path.isfile(fni): - # Check if f exists in outpoutdir, copy the file if not - fno = os.path.join(outputdir, prefix + f) + # Check if input_file exists in outpoutdir, copy the file if not + fno = os.path.join(outputdir, prefix + input_file) if not os.path.isfile(fno): shutil.copy(fni, fno) if not quiet: - print("{0}: new header file".format(f)) + print("{0}: new header file".format(fno)) continue if os.path.getmtime(fni) > os.path.getmtime(fno): @@ -168,11 +216,11 @@ def copy_changed(inputdir, outputdir, prefix='', quiet=False): if not filecmp.cmp(fni, fno): shutil.copy(fni, fno) if not quiet: - print("{0}: updated".format(f)) + print("{0}: updated".format(input_file)) continue if not quiet: - print("{0}: unchanged".format(f)) + print("{0}: unchanged".format(input_file)) def convert_dir_save(inputdir, outputdir, templatedir, temporarydir, prefix, quiet=False): @@ -208,11 +256,7 @@ if __name__ == "__main__": if args.file is not None: for f in args.file: - convert_file( - f, - args.outputdir, - args.templatedir, - incl_default) + generate_header_from_file(f, args.outputdir, args.templatedir, INCL_DEFAULT) elif args.dir is not None: convert_dir_save( args.dir, diff --git a/Tools/px_generate_uorb_topic_sources.py b/Tools/px_generate_uorb_topic_sources.py new file mode 100755 index 0000000000..ccba860214 --- /dev/null +++ b/Tools/px_generate_uorb_topic_sources.py @@ -0,0 +1,192 @@ +#!/usr/bin/env python +############################################################################# +# +# 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. +# +############################################################################# + +""" +px_generate_uorb_topic_sources.py +Generates cpp source files for uorb topics from .msg (ROS syntax) +message files +""" +from __future__ import print_function +import os +import shutil +import filecmp +import argparse + +import sys +px4_tools_dir = os.path.dirname(os.path.abspath(__file__)) +sys.path.append(px4_tools_dir + "/genmsg/src") +sys.path.append(px4_tools_dir + "/gencpp/src") + +try: + import em + import genmsg.template_tools +except ImportError as e: + print("python import error: ", e) + print(''' +Required python packages not installed. + +On a Debian/Ubuntu system please run: + + sudo apt-get install python-empy + sudo pip install catkin_pkg + +On MacOS please run: + sudo pip install empy catkin_pkg + +On Windows please run: + easy_install empy catkin_pkg +''') + exit(1) + +__author__ = "Sergey Belash, Thomas Gubler" +__copyright__ = "Copyright (C) 2013-2014 PX4 Development Team." +__license__ = "BSD" +__email__ = "againagainst@gmail.com, thomasgubler@gmail.com" + +TOPIC_TEMPLATE_FILE = 'msg.cpp.template' +TOPICS_LIST_TEMPLATE_FILE = 'uORBTopics.cpp.template' +OUTPUT_FILE_EXT = '.cpp' +PACKAGE = 'px4' +TOPICS_TOKEN = '# TOPICS ' + + +def get_multi_topics(filename): + """ + Get TOPICS names from a "# TOPICS" line + """ + ofile = open(filename, 'r') + text = ofile.read() + result = [] + for each_line in text.split('\n'): + if each_line.startswith (TOPICS_TOKEN): + topic_names_str = each_line.strip() + topic_names_str = topic_names_str.replace(TOPICS_TOKEN, "") + result.extend(topic_names_str.split(" ")) + ofile.close() + return result + + +def get_msgs_list(msgdir): + """ + Makes list of msg files in the given directory + """ + return [fn for fn in os.listdir(msgdir) if fn.endswith(".msg")] + + +def generate_source_from_file(filename, outputdir, template_file, quiet=False): + """ + Converts a single .msg file to a uorb source file + """ + # print("Generating sources from {0}".format(filename)) + msg_context = genmsg.msg_loader.MsgContext.create_default() + full_type_name = genmsg.gentools.compute_full_type_name(PACKAGE, os.path.basename(filename)) + spec = genmsg.msg_loader.load_msg_from_file(msg_context, filename, full_type_name) + topics = get_multi_topics(filename) + if len(topics) == 0: + topics.append(spec.short_name) + em_globals = { + "file_name_in": filename, + "spec": spec, + "topics": topics + } + + output_file = os.path.join(outputdir, spec.short_name + OUTPUT_FILE_EXT) + if os.path.isfile(output_file): + return False + generate_by_template(output_file, template_file, em_globals) + if not quiet: + print("{0}: new source file".format(output_file)) + return True + + +def generate_by_template(output_file, template_file, em_globals): + """ + Invokes empy intepreter to geneate output_file by the + given template_file and predefined em_globals dict + """ + ofile = open(output_file, 'w') + # todo, reuse interpreter + interpreter = em.Interpreter(output=ofile, globals=em_globals, options={em.RAW_OPT:True,em.BUFFERED_OPT:True}) + if not os.path.isfile(template_file): + ofile.close() + os.remove(output_file) + raise RuntimeError("Template file %s not found" % (template_file)) + interpreter.file(open(template_file)) #todo try + interpreter.shutdown() + ofile.close() + + +def convert_dir(msgdir, outputdir, templatedir, quiet=False): + """ + Converts all .msg files in msgdir to uORB sources + """ + # Make sure output directory exists: + if not os.path.isdir(outputdir): + os.makedirs(outputdir) + template_file = os.path.join(templatedir, TOPIC_TEMPLATE_FILE) + + for f in os.listdir(msgdir): + # Ignore hidden files + if f.startswith("."): + continue + fn = os.path.join(msgdir, f) + # Only look at actual files + if not os.path.isfile(fn): + continue + generate_source_from_file(fn, outputdir, template_file, quiet) + + # generate cpp file with topics list + tl_globals = {"msgs" : get_msgs_list(msgdir)} + tl_template_file = os.path.join(templatedir, TOPICS_LIST_TEMPLATE_FILE) + tl_out_file = os.path.join(outputdir, TOPICS_LIST_TEMPLATE_FILE.replace(".template", "")) + generate_by_template(tl_out_file, tl_template_file, tl_globals) + return True + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Convert msg files to uorb sources') + parser.add_argument('-d', dest='dir', help='directory with msg files') + parser.add_argument('-f', dest='file', help="files to convert (use only without -d)", nargs="+") + parser.add_argument('-e', dest='templatedir', help='directory with template files',) + parser.add_argument('-o', dest='outputdir', help='output directory for source files') + parser.add_argument('-q', dest='quiet', default=False, action='store_true', + help='string added as prefix to the output file ' + ' name when converting directories') + args = parser.parse_args() + + if args.file is not None: + for f in args.file: + generate_source_from_file(f, args.outputdir, args.templatedir, args.quiet) + elif args.dir is not None: + convert_dir(args.dir, args.outputdir, args.templatedir, args.quiet) diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake index 605ee5b1ef..41de8a94c4 100644 --- a/cmake/common/px4_base.cmake +++ b/cmake/common/px4_base.cmake @@ -359,13 +359,15 @@ function(px4_generate_messages) NAME px4_generate_messages OPTIONS VERBOSE ONE_VALUE OS TARGET - MULTI_VALUE MSG_FILES DEPENDS + MULTI_VALUE MSG_FILES DEPENDS INCLUDES REQUIRED MSG_FILES OS TARGET ARGN ${ARGN}) set(QUIET) if(NOT VERBOSE) set(QUIET "-q") endif() + + # headers set(msg_out_path ${CMAKE_BINARY_DIR}/src/modules/uORB/topics) set(msg_list) foreach(msg_file ${MSG_FILES}) @@ -390,6 +392,26 @@ function(px4_generate_messages) VERBATIM ) + # !sources + set(msg_source_out_path ${CMAKE_BINARY_DIR}/topics_sources) + set(msg_source_files_out ${msg_source_out_path}/uORBTopics.cpp) + foreach(msg ${msg_list}) + list(APPEND msg_source_files_out ${msg_source_out_path}/${msg}.cpp) + endforeach() + add_custom_command(OUTPUT ${msg_source_files_out} + COMMAND ${PYTHON_EXECUTABLE} + Tools/px_generate_uorb_topic_sources.py + ${QUIET} + -d msg + -e msg/templates/uorb + -o ${msg_source_out_path} + DEPENDS ${DEPENDS} ${MSG_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "Generating uORB topic sources" + VERBATIM + ) + set_source_files_properties(${msg_source_files_out} PROPERTIES GENERATED TRUE) + # multi messages for target OS set(msg_multi_out_path ${CMAKE_BINARY_DIR}/src/platforms/${OS}/px4_messages) @@ -411,8 +433,13 @@ function(px4_generate_messages) COMMENT "Generating uORB topic multi headers for ${OS}" VERBATIM ) - add_custom_target(${TARGET} - DEPENDS ${msg_multi_files_out} ${msg_files_out}) + + add_library(${TARGET} + ${msg_source_files_out} + ${msg_multi_files_out} + ${msg_files_out} + ) + endfunction() #============================================================================= diff --git a/cmake/configs/nuttx_px4fmu-v2_debug.cmake b/cmake/configs/nuttx_px4fmu-v2_debug.cmake new file mode 100644 index 0000000000..e0fedbb7e6 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v2_debug.cmake @@ -0,0 +1,189 @@ +set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "build type") + + +include(nuttx/px4_impl_nuttx) + +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/toolchains/Toolchain-arm-none-eabi.cmake) + +set(config_module_list + # + # Board support modules + # + drivers/device + drivers/stm32 + drivers/stm32/adc + drivers/stm32/tone_alarm + drivers/led + drivers/px4fmu + drivers/px4io + drivers/boards/px4fmu-v2 + drivers/rgbled + drivers/mpu6000 + #drivers/mpu9250 + drivers/lsm303d + drivers/l3gd20 + #drivers/hmc5883 + drivers/ms5611 + #drivers/mb12xx + #drivers/srf02 + #drivers/sf0x + #drivers/ll40ls + drivers/trone + drivers/gps + drivers/pwm_out_sim + #drivers/hott + #drivers/hott/hott_telemetry + #drivers/hott/hott_sensors + #drivers/blinkm + drivers/airspeed + drivers/ets_airspeed + drivers/meas_airspeed + #drivers/frsky_telemetry + modules/sensors + #drivers/mkblctrl + #drivers/px4flow + #drivers/oreoled + drivers/gimbal + drivers/pwm_input + drivers/camera_trigger + drivers/bst + #drivers/snapdragon_rc_pwm + #drivers/lis3mdl + + # + # System commands + # + systemcmds/bl_update + systemcmds/mixer + systemcmds/param + systemcmds/perf + systemcmds/pwm + systemcmds/esc_calib + systemcmds/reboot + #systemcmds/topic_listener + systemcmds/top + systemcmds/config + systemcmds/nshterm + systemcmds/mtd + systemcmds/dumpfile + systemcmds/ver + + # + # General system control + # + modules/commander + modules/navigator + modules/mavlink + modules/gpio_led + #modules/uavcan + modules/land_detector + + # + # Estimation modules (EKF/ SO3 / other filters) + # + # Too high RAM usage due to static allocations + # modules/attitude_estimator_ekf + modules/attitude_estimator_q + modules/ekf_att_pos_estimator + modules/position_estimator_inav + + # + # Vehicle Control + # + # modules/segway # XXX Needs GCC 4.7 fix + modules/fw_pos_control_l1 + modules/fw_att_control + modules/mc_att_control + modules/mc_pos_control + modules/vtol_att_control + + # + # Logging + # + modules/sdlog2 + + # + # Library modules + # + modules/param + modules/systemlib + modules/systemlib/mixer + modules/uORB + modules/dataman + + # + # Libraries + # + lib/controllib + lib/mathlib + lib/mathlib/math/filter + lib/ecl + lib/external_lgpl + lib/geo + lib/geo_lookup + lib/conversion + lib/launchdetection + lib/terrain_estimation + lib/runway_takeoff + lib/tailsitter_recovery + platforms/nuttx + + # had to add for cmake, not sure why wasn't in original config + platforms/common + platforms/nuttx/px4_layer + + # + # OBC challenge + # + #modules/bottle_drop + + # + # Rover apps + # + #examples/rover_steering_control + + # + # Demo apps + # + #examples/math_demo + # Tutorial code from + # https://px4.io/dev/px4_simple_app + #examples/px4_simple_app + + # Tutorial code from + # https://px4.io/dev/daemon + #examples/px4_daemon_app + + # Tutorial code from + # https://px4.io/dev/debug_values + #examples/px4_mavlink_debug + + # Tutorial code from + # https://px4.io/dev/example_fixedwing_control + #examples/fixedwing_control + + # Hardware test + #examples/hwtest +) + +set(config_extra_builtin_cmds + serdis + sercon + ) + +set(config_io_board + px4io-v2 + ) + +set(config_io_extra_libs + ) + +add_custom_target(sercon) +set_target_properties(sercon PROPERTIES + PRIORITY "SCHED_PRIORITY_DEFAULT" + MAIN "sercon" STACK_MAIN "2048") + +add_custom_target(serdis) +set_target_properties(serdis PROPERTIES + PRIORITY "SCHED_PRIORITY_DEFAULT" + MAIN "serdis" STACK_MAIN "2048") diff --git a/msg/actuator_armed.msg b/msg/actuator_armed.msg index f307e366ae..51a7ab116c 100644 --- a/msg/actuator_armed.msg +++ b/msg/actuator_armed.msg @@ -1,5 +1,4 @@ -uint64 timestamp # Microseconds since system boot bool armed # Set to true if system is armed bool prearmed # Set to true if the actuator safety is disabled but motors are not armed bool ready_to_arm # Set to true if system is ready to be armed diff --git a/msg/actuator_controls.msg b/msg/actuator_controls.msg index a802f1502a..46bf35ebff 100644 --- a/msg/actuator_controls.msg +++ b/msg/actuator_controls.msg @@ -10,6 +10,9 @@ uint8 INDEX_AIRBRAKES = 6 uint8 INDEX_LANDING_GEAR = 7 uint8 GROUP_INDEX_ATTITUDE = 0 uint8 GROUP_INDEX_ATTITUDE_ALTERNATE = 1 -uint64 timestamp uint64 timestamp_sample # the timestamp the data this control response is based on was sampled float32[8] control + +# TOPICS actuator_controls actuator_controls_0 actuator_controls_1 actuator_controls_2 actuator_controls_3 +# TOPICS actuator_controls_virtual_fw actuator_controls_virtual_mc + diff --git a/msg/actuator_controls_1.msg b/msg/actuator_controls_1.msg deleted file mode 100644 index 414eb06ddb..0000000000 --- a/msg/actuator_controls_1.msg +++ /dev/null @@ -1,5 +0,0 @@ -uint8 NUM_ACTUATOR_CONTROLS = 8 -uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp -uint64 timestamp_sample # the timestamp the data this control response is based on was sampled -float32[8] control diff --git a/msg/actuator_controls_2.msg b/msg/actuator_controls_2.msg deleted file mode 100644 index 414eb06ddb..0000000000 --- a/msg/actuator_controls_2.msg +++ /dev/null @@ -1,5 +0,0 @@ -uint8 NUM_ACTUATOR_CONTROLS = 8 -uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp -uint64 timestamp_sample # the timestamp the data this control response is based on was sampled -float32[8] control diff --git a/msg/actuator_controls_3.msg b/msg/actuator_controls_3.msg deleted file mode 100644 index 414eb06ddb..0000000000 --- a/msg/actuator_controls_3.msg +++ /dev/null @@ -1,5 +0,0 @@ -uint8 NUM_ACTUATOR_CONTROLS = 8 -uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp -uint64 timestamp_sample # the timestamp the data this control response is based on was sampled -float32[8] control diff --git a/msg/actuator_controls_virtual_fw.msg b/msg/actuator_controls_virtual_fw.msg deleted file mode 100644 index 414eb06ddb..0000000000 --- a/msg/actuator_controls_virtual_fw.msg +++ /dev/null @@ -1,5 +0,0 @@ -uint8 NUM_ACTUATOR_CONTROLS = 8 -uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp -uint64 timestamp_sample # the timestamp the data this control response is based on was sampled -float32[8] control diff --git a/msg/actuator_direct.msg b/msg/actuator_direct.msg index c798f5101f..7d22f79e75 100644 --- a/msg/actuator_direct.msg +++ b/msg/actuator_direct.msg @@ -1,4 +1,3 @@ uint8 NUM_ACTUATORS_DIRECT = 16 -uint64 timestamp # timestamp in us since system boot uint32 nvalues # number of valid values float32[16] values # actuator values, from -1 to 1 diff --git a/msg/actuator_outputs.msg b/msg/actuator_outputs.msg index 00a3c35b79..269255340d 100644 --- a/msg/actuator_outputs.msg +++ b/msg/actuator_outputs.msg @@ -1,5 +1,4 @@ uint8 NUM_ACTUATOR_OUTPUTS = 16 uint8 NUM_ACTUATOR_OUTPUT_GROUPS = 4 # for sanity checking -uint64 timestamp # output timestamp in us since system boot uint32 noutputs # valid outputs float32[16] output # output data, in natural output units diff --git a/msg/airspeed.msg b/msg/airspeed.msg index f0a109a7e7..744f9d8830 100644 --- a/msg/airspeed.msg +++ b/msg/airspeed.msg @@ -1,4 +1,3 @@ -uint64 timestamp # microseconds since system boot, needed to integrate float32 indicated_airspeed_m_s # indicated airspeed in meters per second, -1 if unknown float32 true_airspeed_m_s # true filtered airspeed in meters per second, -1 if unknown float32 true_airspeed_unfiltered_m_s # true airspeed in meters per second, -1 if unknown diff --git a/msg/battery_status.msg b/msg/battery_status.msg index e5e24cc08f..7dbdc7b1ce 100644 --- a/msg/battery_status.msg +++ b/msg/battery_status.msg @@ -1,4 +1,3 @@ -uint64 timestamp # microseconds since system boot, needed to integrate float32 voltage_v # Battery voltage in volts, 0 if unknown float32 voltage_filtered_v # Battery voltage in volts, filtered, 0 if unknown float32 current_a # Battery current in amperes, -1 if unknown diff --git a/msg/camera_trigger.msg b/msg/camera_trigger.msg index b4dcfe8ef3..384e9aa61c 100644 --- a/msg/camera_trigger.msg +++ b/msg/camera_trigger.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Timestamp when camera was triggered uint32 seq # Image sequence diff --git a/msg/commander_state.msg b/msg/commander_state.msg index 0c6a896dc7..a9c92ebb5e 100644 --- a/msg/commander_state.msg +++ b/msg/commander_state.msg @@ -14,6 +14,5 @@ uint8 MAIN_STATE_AUTO_LAND = 11 uint8 MAIN_STATE_AUTO_FOLLOW_TARGET = 12 uint8 MAIN_STATE_MAX = 13 -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data uint8 main_state # main state machine diff --git a/msg/control_state.msg b/msg/control_state.msg index 82af7aeda6..af6de428fa 100644 --- a/msg/control_state.msg +++ b/msg/control_state.msg @@ -1,5 +1,4 @@ # This is similar to the mavlink message CONTROL_SYSTEM_STATE, but for onboard use */ -uint64 timestamp # in microseconds since system start float32 x_acc # X acceleration in body frame float32 y_acc # Y acceleration in body frame float32 z_acc # Z acceleration in body frame diff --git a/msg/differential_pressure.msg b/msg/differential_pressure.msg index bb31449d6c..10fb9eb88e 100644 --- a/msg/differential_pressure.msg +++ b/msg/differential_pressure.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Microseconds since system boot, needed to integrate uint64 error_count # Number of errors detected by driver float32 differential_pressure_raw_pa # Raw differential pressure reading (may be negative) float32 differential_pressure_filtered_pa # Low pass filtered differential pressure reading diff --git a/msg/distance_sensor.msg b/msg/distance_sensor.msg index ad01ce63e0..c2e1a171f2 100644 --- a/msg/distance_sensor.msg +++ b/msg/distance_sensor.msg @@ -1,6 +1,5 @@ # DISTANCE_SENSOR message data -uint64 timestamp # Microseconds since system boot float32 min_distance # Minimum distance the sensor can measure (in m) float32 max_distance # Maximum distance the sensor can measure (in m) diff --git a/msg/ekf2_innovations.msg b/msg/ekf2_innovations.msg index 0822a473b5..225922b8b6 100644 --- a/msg/ekf2_innovations.msg +++ b/msg/ekf2_innovations.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Timestamp in microseconds since boot float32[6] vel_pos_innov # velocity and position innovations float32[3] mag_innov # earth magnetic field innovations float32 heading_innov # heading innovation diff --git a/msg/encoders.msg b/msg/encoders.msg index 505365c57e..ef863a9cba 100644 --- a/msg/encoders.msg +++ b/msg/encoders.msg @@ -1,5 +1,4 @@ uint8 NUM_ENCODERS = 4 -uint64 timestamp int64[4] counts # counts of encoder float32[4] velocity # counts of encoder/ second diff --git a/msg/esc_status.msg b/msg/esc_status.msg index b54131756b..13c0a925f8 100644 --- a/msg/esc_status.msg +++ b/msg/esc_status.msg @@ -11,7 +11,6 @@ uint8 ESC_CONNECTION_TYPE_I2C = 3 # I2C uint8 ESC_CONNECTION_TYPE_CAN = 4 # CAN-Bus uint16 counter # incremented by the writing thread everytime new data is stored -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data uint8 esc_count # number of connected ESCs uint8 esc_connectiontype # how ESCs connected to the system diff --git a/msg/estimator_status.msg b/msg/estimator_status.msg index c145a21501..9dea01893d 100644 --- a/msg/estimator_status.msg +++ b/msg/estimator_status.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Timestamp in microseconds since boot float32[32] states # Internal filter states float32 n_states # Number of states effectively used float32[3] vibe # Vibration levels in X, Y and Z diff --git a/msg/filtered_bottom_flow.msg b/msg/filtered_bottom_flow.msg index 815a38414d..1de919ee92 100644 --- a/msg/filtered_bottom_flow.msg +++ b/msg/filtered_bottom_flow.msg @@ -1,5 +1,4 @@ # Filtered bottom flow in bodyframe. -uint64 timestamp # time of this estimate, in microseconds since system start float32 sumx # Integrated bodyframe x flow in meters float32 sumy # Integrated bodyframe y flow in meters diff --git a/msg/follow_target.msg b/msg/follow_target.msg index 51ed91a28f..c93f6fc719 100644 --- a/msg/follow_target.msg +++ b/msg/follow_target.msg @@ -1,4 +1,3 @@ -uint64 timestamp # timestamp, UNIX epoch (GPS synced) float64 lat # target position (deg * 1e7) float64 lon # target position (deg * 1e7) float32 alt # target position diff --git a/msg/fw_pos_ctrl_status.msg b/msg/fw_pos_ctrl_status.msg index 641b591205..0af57b1bf5 100644 --- a/msg/fw_pos_ctrl_status.msg +++ b/msg/fw_pos_ctrl_status.msg @@ -1,5 +1,3 @@ -uint64 timestamp # timestamp this topic was emitted - float32 nav_roll float32 nav_pitch float32 nav_bearing diff --git a/msg/fw_virtual_attitude_setpoint.msg b/msg/fw_virtual_attitude_setpoint.msg index 6c12b225c8..a379477bce 100644 --- a/msg/fw_virtual_attitude_setpoint.msg +++ b/msg/fw_virtual_attitude_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data float32 roll_body # body angle in NED frame float32 pitch_body # body angle in NED frame @@ -35,3 +34,6 @@ bool fw_control_yaw # control heading with rudder (used for auto takeoff on bool disable_mc_yaw_control # control yaw for mc (used for vtol weather-vane mode) bool apply_flaps + +# WAS vehicle_attitude_setpoint mc_virtual_attitude_setpoint fw_virtual_attitude_setpoint +# TOPICS fw_virtual_attitude_setpoint diff --git a/msg/fw_virtual_rates_setpoint.msg b/msg/fw_virtual_rates_setpoint.msg index 4fa09b563f..369b68270a 100644 --- a/msg/fw_virtual_rates_setpoint.msg +++ b/msg/fw_virtual_rates_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start float32 roll # body angular rates in NED frame float32 pitch # body angular rates in NED frame diff --git a/msg/hil_sensor.msg b/msg/hil_sensor.msg index 9317722db4..e1debf8f6f 100644 --- a/msg/hil_sensor.msg +++ b/msg/hil_sensor.msg @@ -17,7 +17,6 @@ int32 MAGNETOMETER_MODE_NEGATIVE_BIAS = 2 # # NOTE: Ordering of fields optimized to align to 32 bit / 4 bytes Change with consideration only -uint64 timestamp # Timestamp in microseconds since boot, from gyro # int16[3] gyro_raw # Raw sensor values of angular velocity float32[3] gyro_rad_s # Angular velocity in radian per seconds diff --git a/msg/home_position.msg b/msg/home_position.msg index 7135c07b18..19c9d44868 100644 --- a/msg/home_position.msg +++ b/msg/home_position.msg @@ -1,5 +1,4 @@ # GPS home position in WGS84 coordinates. -uint64 timestamp # Timestamp (microseconds since system boot) float64 lat # Latitude in degrees float64 lon # Longitude in degrees diff --git a/msg/manual_control_setpoint.msg b/msg/manual_control_setpoint.msg index 81d77635ee..8295eba074 100644 --- a/msg/manual_control_setpoint.msg +++ b/msg/manual_control_setpoint.msg @@ -12,8 +12,6 @@ int8 MODE_SLOT_5 = 4 # mode slot 5 selected int8 MODE_SLOT_6 = 5 # mode slot 6 selected int8 MODE_SLOT_MAX = 6 # number of slots plus one -uint64 timestamp - # Any of the channels may not be available and be set to NaN # to indicate that it does not contain valid data. # The variable names follow the definition of the diff --git a/msg/mavlink_log.msg b/msg/mavlink_log.msg index 1161a25543..d52004fad6 100644 --- a/msg/mavlink_log.msg +++ b/msg/mavlink_log.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Timestamp in microseconds since boot uint8[50] text uint8 severity diff --git a/msg/mc_att_ctrl_status.msg b/msg/mc_att_ctrl_status.msg index 114e843b0e..c2979c3f00 100644 --- a/msg/mc_att_ctrl_status.msg +++ b/msg/mc_att_ctrl_status.msg @@ -1,4 +1,3 @@ -uint64 timestamp # in microseconds since system start float32 roll_rate_integ # roll rate inegrator float32 pitch_rate_integ # pitch rate integrator diff --git a/msg/mc_virtual_attitude_setpoint.msg b/msg/mc_virtual_attitude_setpoint.msg index 6c12b225c8..f2fe44da86 100644 --- a/msg/mc_virtual_attitude_setpoint.msg +++ b/msg/mc_virtual_attitude_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data float32 roll_body # body angle in NED frame float32 pitch_body # body angle in NED frame @@ -35,3 +34,6 @@ bool fw_control_yaw # control heading with rudder (used for auto takeoff on bool disable_mc_yaw_control # control yaw for mc (used for vtol weather-vane mode) bool apply_flaps + +# WAS vehicle_attitude_setpoint mc_virtual_attitude_setpoint fw_virtual_attitude_setpoint +# TOPICS mc_virtual_attitude_setpoint diff --git a/msg/mc_virtual_rates_setpoint.msg b/msg/mc_virtual_rates_setpoint.msg index 4fa09b563f..369b68270a 100644 --- a/msg/mc_virtual_rates_setpoint.msg +++ b/msg/mc_virtual_rates_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start float32 roll # body angular rates in NED frame float32 pitch # body angular rates in NED frame diff --git a/msg/mission.msg b/msg/mission.msg index ac135a4e09..e208d36929 100644 --- a/msg/mission.msg +++ b/msg/mission.msg @@ -1,3 +1,7 @@ int32 dataman_id # default 0, there are two offboard storage places in the dataman: 0 or 1 uint32 count # count of the missions stored in the dataman int32 current_seq # default -1, start at the one changed latest + +# fixme: there is no mission definition in objects_common.cpp +# but it's required for systemcmds/topic_listener/topic_listener +# TOPICS mission offboard_mission onboard_mission diff --git a/msg/offboard_control_mode.msg b/msg/offboard_control_mode.msg index e2d06963b6..927c8e6503 100644 --- a/msg/offboard_control_mode.msg +++ b/msg/offboard_control_mode.msg @@ -1,5 +1,4 @@ # Off-board control mode -uint64 timestamp bool ignore_thrust bool ignore_attitude diff --git a/msg/optical_flow.msg b/msg/optical_flow.msg index d34e32b8fd..a890df68a4 100644 --- a/msg/optical_flow.msg +++ b/msg/optical_flow.msg @@ -1,7 +1,6 @@ # Optical flow in NED body frame in SI units. # @see http://en.wikipedia.org/wiki/International_System_of_Units -uint64 timestamp # in microseconds since system start uint8 sensor_id # id of the sensor emitting the flow value float32 pixel_flow_x_integral # accumulated optical flow in radians around x axis float32 pixel_flow_y_integral # accumulated optical flow in radians around y axis diff --git a/msg/parameter_update.msg b/msg/parameter_update.msg index 78cebf7f4f..3fa04a7657 100644 --- a/msg/parameter_update.msg +++ b/msg/parameter_update.msg @@ -1,2 +1 @@ -uint64 timestamp # time at which the latest parameter was updated bool saved # wether the change has already been saved to disk diff --git a/msg/pwm_input.msg b/msg/pwm_input.msg index beb82021d2..8b91883532 100644 --- a/msg/pwm_input.msg +++ b/msg/pwm_input.msg @@ -1,5 +1,4 @@ -uint64 timestamp # Microseconds since system boot uint64 error_count uint32 pulse_width # Pulse width, timer counts uint32 period # Period, timer counts diff --git a/msg/qshell_req.msg b/msg/qshell_req.msg index bad96a1cec..fa75390edd 100644 --- a/msg/qshell_req.msg +++ b/msg/qshell_req.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Microseconds since system boot int32[100] string uint64 MAX_STRLEN = 100 uint64 strlen diff --git a/msg/rc_channels.msg b/msg/rc_channels.msg index b8bcc5f536..769a393216 100644 --- a/msg/rc_channels.msg +++ b/msg/rc_channels.msg @@ -20,7 +20,7 @@ uint8 RC_CHANNELS_FUNCTION_PARAM_2=17 uint8 RC_CHANNELS_FUNCTION_PARAM_3_5=18 uint8 RC_CHANNELS_FUNCTION_RATTITUDE=19 uint8 RC_CHANNELS_FUNCTION_KILLSWITCH=20 -uint64 timestamp # Timestamp in microseconds since boot time + uint64 timestamp_last_valid # Timestamp of last valid RC signal float32[18] channels # Scaled to -1..1 (throttle: 0..1) uint8 channel_count # Number of valid channels diff --git a/msg/rc_parameter_map.msg b/msg/rc_parameter_map.msg index 4a94498108..4a5cb5cfd1 100644 --- a/msg/rc_parameter_map.msg +++ b/msg/rc_parameter_map.msg @@ -1,7 +1,6 @@ uint8 RC_PARAM_MAP_NCHAN = 3 # This limit is also hardcoded in the enum RC_CHANNELS_FUNCTION in rc_channels.h uint8 PARAM_ID_LEN = 16 # corresponds to MAVLINK_MSG_PARAM_VALUE_FIELD_PARAM_ID_LEN -uint64 timestamp # time at which the map was updated bool[3] valid #true for RC-Param channels which are mapped to a param int32[3] param_index # corresponding param index, this field is ignored if set to -1, in this case param_id will be used char[51] param_id # MAP_NCHAN * (ID_LEN + 1) chars, corresponding param id, null terminated diff --git a/msg/actuator_controls_0.msg b/msg/ros/actuator_controls_0.msg similarity index 91% rename from msg/actuator_controls_0.msg rename to msg/ros/actuator_controls_0.msg index 414eb06ddb..4424f197f8 100644 --- a/msg/actuator_controls_0.msg +++ b/msg/ros/actuator_controls_0.msg @@ -1,5 +1,4 @@ uint8 NUM_ACTUATOR_CONTROLS = 8 uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp uint64 timestamp_sample # the timestamp the data this control response is based on was sampled float32[8] control diff --git a/msg/actuator_controls_virtual_mc.msg b/msg/ros/actuator_controls_virtual_mc.msg similarity index 91% rename from msg/actuator_controls_virtual_mc.msg rename to msg/ros/actuator_controls_virtual_mc.msg index 414eb06ddb..4424f197f8 100644 --- a/msg/actuator_controls_virtual_mc.msg +++ b/msg/ros/actuator_controls_virtual_mc.msg @@ -1,5 +1,4 @@ uint8 NUM_ACTUATOR_CONTROLS = 8 uint8 NUM_ACTUATOR_CONTROL_GROUPS = 4 -uint64 timestamp uint64 timestamp_sample # the timestamp the data this control response is based on was sampled float32[8] control diff --git a/msg/safety.msg b/msg/safety.msg index be0fadad1e..34d66d12cc 100644 --- a/msg/safety.msg +++ b/msg/safety.msg @@ -1,3 +1,2 @@ -uint64 timestamp bool safety_switch_available # Set to true if a safety switch is connected bool safety_off # Set to true if safety is off diff --git a/msg/satellite_info.msg b/msg/satellite_info.msg index 24cb03facc..0efa030a87 100644 --- a/msg/satellite_info.msg +++ b/msg/satellite_info.msg @@ -1,6 +1,5 @@ uint8 SAT_INFO_MAX_SATELLITES = 20 -uint64 timestamp # Timestamp of satellite info uint8 count # Number of satellites in satellite info uint8[20] svid # Space vehicle ID [1..255], see scheme below uint8[20] used # 0: Satellite not used, 1: used for navigation diff --git a/msg/sensor_accel.msg b/msg/sensor_accel.msg index 0ed71957ef..9dcefa6b87 100644 --- a/msg/sensor_accel.msg +++ b/msg/sensor_accel.msg @@ -1,4 +1,3 @@ -uint64 timestamp uint64 integral_dt # integration time uint64 error_count float32 x # acceleration in the NED X board axis in m/s^2 diff --git a/msg/sensor_baro.msg b/msg/sensor_baro.msg index 315d5a56ec..9fe621f1c8 100644 --- a/msg/sensor_baro.msg +++ b/msg/sensor_baro.msg @@ -1,5 +1,4 @@ float32 pressure float32 altitude float32 temperature -uint64 timestamp uint64 error_count diff --git a/msg/sensor_combined.msg b/msg/sensor_combined.msg index ec58e6f923..fab3dcad02 100644 --- a/msg/sensor_combined.msg +++ b/msg/sensor_combined.msg @@ -25,7 +25,6 @@ uint32 SENSOR_PRIO_MAX = 255 # # NOTE: Ordering of fields optimized to align to 32 bit / 4 bytes Change with consideration only -uint64 timestamp # Timestamp in microseconds since boot, from gyro uint64[3] gyro_timestamp # Gyro timestamps int16[9] gyro_raw # Raw sensor values of angular velocity float32[9] gyro_rad_s # Angular velocity in radian per seconds diff --git a/msg/sensor_gyro.msg b/msg/sensor_gyro.msg index badaec0eb5..31636d148a 100644 --- a/msg/sensor_gyro.msg +++ b/msg/sensor_gyro.msg @@ -1,4 +1,3 @@ -uint64 timestamp uint64 integral_dt # integration time uint64 error_count float32 x # angular velocity in the NED X board axis in rad/s diff --git a/msg/sensor_mag.msg b/msg/sensor_mag.msg index 8ea03d1fc3..662ebdbb79 100644 --- a/msg/sensor_mag.msg +++ b/msg/sensor_mag.msg @@ -1,4 +1,3 @@ -uint64 timestamp uint64 error_count float32 x float32 y diff --git a/msg/servorail_status.msg b/msg/servorail_status.msg index f473cc1e28..39edf80e4f 100644 --- a/msg/servorail_status.msg +++ b/msg/servorail_status.msg @@ -1,3 +1,2 @@ -uint64 timestamp # microseconds since system boot float32 voltage_v # Servo rail voltage in volts float32 rssi_v # RSSI pin voltage in volts diff --git a/msg/system_power.msg b/msg/system_power.msg index cb2a7c0eb0..e6648ceec7 100644 --- a/msg/system_power.msg +++ b/msg/system_power.msg @@ -1,4 +1,3 @@ -uint64 timestamp # microseconds since system boot float32 voltage5V_v # peripheral 5V rail voltage uint8 usb_connected # USB is connected when 1 uint8 brick_valid # brick power is good when 1 diff --git a/msg/tecs_status.msg b/msg/tecs_status.msg index 4dcd16b2ca..7576112c57 100644 --- a/msg/tecs_status.msg +++ b/msg/tecs_status.msg @@ -6,7 +6,6 @@ uint8 TECS_MODE_LAND_THROTTLELIM = 4 uint8 TECS_MODE_BAD_DESCENT = 5 uint8 TECS_MODE_CLIMBOUT = 6 -uint64 timestamp # timestamp, in microseconds since system start */ float32 altitudeSp float32 altitude_filtered diff --git a/msg/telemetry_status.msg b/msg/telemetry_status.msg index cdcef931af..e7c653c6f5 100644 --- a/msg/telemetry_status.msg +++ b/msg/telemetry_status.msg @@ -4,7 +4,6 @@ uint8 TELEMETRY_STATUS_RADIO_TYPE_UBIQUITY_BULLET = 2 uint8 TELEMETRY_STATUS_RADIO_TYPE_WIRE = 3 uint8 TELEMETRY_STATUS_RADIO_TYPE_USB = 4 -uint64 timestamp uint64 heartbeat_time # Time of last received heartbeat from remote system uint64 telem_time # Time of last received telemetry status packet, 0 for none uint8 type # type of the radio hardware diff --git a/msg/templates/px4/uorb/msg.h.template b/msg/templates/px4/uorb/msg.h.template index 2d42511074..1707dfc015 100644 --- a/msg/templates/px4/uorb/msg.h.template +++ b/msg/templates/px4/uorb/msg.h.template @@ -55,7 +55,6 @@ import genmsg.msgs import gencpp -cpp_class = 'px4_%s'%spec.short_name native_type = '%s_s'%spec.short_name topic_name = spec.short_name }@ @@ -74,6 +73,11 @@ topic_name = spec.short_name namespace px4 { +@[for multi_topic in topics]@ +@{ +cpp_class = 'px4_%s'%multi_topic +}@ + class __EXPORT @(cpp_class) : public PX4Message<@(native_type)> @@ -89,7 +93,8 @@ public: ~@(cpp_class)() {} - static PX4TopicHandle handle() {return ORB_ID(@(topic_name));} + static PX4TopicHandle handle() {return ORB_ID(@(multi_topic));} }; +@[end for] }; diff --git a/msg/templates/uorb/msg.cpp.template b/msg/templates/uorb/msg.cpp.template new file mode 100644 index 0000000000..ff5afb297e --- /dev/null +++ b/msg/templates/uorb/msg.cpp.template @@ -0,0 +1,132 @@ +@############################################### +@# +@# PX4 ROS compatible message source code +@# generation for C++ +@# +@# EmPy template for generating .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 + +uorb_struct = '%s_s'%spec.short_name +uorb_pack_func = 'pack_%s'%spec.short_name +topic_name = spec.short_name + +type_map = { + 'int8': 'int8_t', + 'int16': 'int16_t', + 'int32': 'int32_t', + 'int64': 'int64_t', + 'uint8': 'uint8_t', + 'uint16': 'uint16_t', + 'uint32': 'uint32_t', + 'uint64': 'uint64_t', + 'float32': 'float', + 'float64': 'double', + 'bool': 'bool', + 'char': 'char', + 'fence_vertex': 'fence_vertex', + 'position_setpoint': 'position_setpoint', + 'esc_report': 'esc_report' +} + +msgtype_size_map = { + 'int8': 8, + 'int16': 16, + 'int32': 32, + 'int64': 64, + 'uint8': 8, + 'uint16': 16, + 'uint32': 32, + 'uint64': 64, + 'float32': 32, + 'float64': 64, + 'bool': 1, + 'char': 1, + 'fence_vertex': 8, + 'position_setpoint': 104, + 'esc_report': 36 +} + +def convert_type(spec_type): + bare_type = spec_type + if '/' in spec_type: + # removing prefix + bare_type = (spec_type.split('/'))[1] + + msg_type, is_array, array_length = genmsg.msgs.parse_type(bare_type) + c_type = type_map[msg_type] + if is_array: + return c_type + "[" + str(array_length) + "]" + return c_type + +def bare_name(msg_type): + bare = msg_type + if '/' in msg_type: + # removing prefix + bare = (msg_type.split('/'))[1] + # removing suffix + return bare.split('[')[0] + +def sizeof_field_type(field): + return msgtype_size_map[bare_name(field.type)] + +sorted_fields = sorted(spec.parsed_fields(), key = sizeof_field_type, reverse=True) +topic_fields = ["%s %s" % (convert_type(field.type), field.name) for field in sorted_fields] +}@ + +#include +#include +#include + +@# join all msg files in one line e.g: "float[3] position;float[3] velocity;bool armed" +const char *__orb_@(topic_name)_fields = "@( topic_name.upper() ):@( ";".join(topic_fields) );"; + +@[for multi_topic in topics]@ +ORB_DEFINE(@multi_topic, struct @uorb_struct, __orb_@(topic_name)_fields); +@[end for] diff --git a/msg/templates/uorb/msg.h.template b/msg/templates/uorb/msg.h.template index 78e1992e06..7fe48e593d 100644 --- a/msg/templates/uorb/msg.h.template +++ b/msg/templates/uorb/msg.h.template @@ -75,7 +75,6 @@ for field in spec.parsed_fields(): (package, name) = genmsg.names.package_resource_name(field.base_type) package = package or spec.package # convert '' to package print('#include '%(name)) - }@ @# Constants c style @@ -85,17 +84,12 @@ for field in spec.parsed_fields(): @[end for] #endif -/** - * @@addtogroup topics - * @@{ - */ - @############################## @# Main struct of message @############################## @{ - -type_map = {'int8': 'int8_t', +type_map = { + 'int8': 'int8_t', 'int16': 'int16_t', 'int32': 'int32_t', 'int64': 'int64_t', @@ -109,37 +103,77 @@ type_map = {'int8': 'int8_t', 'char': 'char', 'fence_vertex': 'fence_vertex', 'position_setpoint': 'position_setpoint', - 'esc_report': 'esc_report'} + 'esc_report': 'esc_report' +} + +msgtype_size_map = { + 'int8': 8, + 'int16': 16, + 'int32': 32, + 'int64': 64, + 'uint8': 8, + 'uint16': 16, + 'uint32': 32, + 'uint64': 64, + 'float32': 32, + 'float64': 64, + 'bool': 1, + 'char': 1, + 'fence_vertex': 8, + 'position_setpoint': 104, + 'esc_report': 36 +} + +def bare_name(msg_type): + bare = msg_type + if '/' in msg_type: + # removing prefix + bare = (msg_type.split('/'))[1] + # removing suffix + return bare.split('[')[0] + +def sizeof_field_type(field): + return msgtype_size_map[bare_name(field.type)] # Function to print a standard ros type def print_field_def(field): - type = field.type + type_name = field.type # detect embedded types - sl_pos = type.find('/') + sl_pos = type_name.find('/') type_appendix = '' type_prefix = '' if (sl_pos >= 0): - type = type[sl_pos + 1:] + type_name = type_name[sl_pos + 1:] type_prefix = 'struct ' type_appendix = '_s' # detect arrays - a_pos = type.find('[') + a_pos = type_name.find('[') array_size = '' if (a_pos >= 0): # field is array - array_size = type[a_pos:] - type = type[:a_pos] + array_size = type_name[a_pos:] + type_name = type_name[:a_pos] - if type in type_map: + if type_name in type_map: # need to add _t: int8 --> int8_t - type_px4 = type_map[type] + type_px4 = type_map[type_name] else: - raise Exception("Type {0} not supported, add to to template file!".format(type)) + raise Exception("Type {0} not supported, add to to template file!".format(type_name)) print('\t%s%s%s %s%s;'%(type_prefix, type_px4, type_appendix, field.name, array_size)) -} +def print_parsed_fields(): + # sort fields + sorted_fields = sorted(spec.parsed_fields(), key = sizeof_field_type, reverse=True) + # loop over all fields and print the type and name + for field in sorted_fields: + if (not field.is_header): + print_field_def(field) + +}@ + +// #pragma pack(push, 1) badly breaks alignment everywhere! #ifdef __cplusplus @#class @(uorb_struct) { struct __EXPORT @(uorb_struct) { @@ -147,31 +181,27 @@ struct __EXPORT @(uorb_struct) { #else struct @(uorb_struct) { #endif -@{ -# loop over all fields and print the type and name -for field in spec.parsed_fields(): - if (not field.is_header): - print_field_def(field) -}@ +@# timestamp at the beginning of each topic is required for logger + uint64_t timestamp; // required for logger +@print_parsed_fields() #ifdef __cplusplus @# Constants again c++-ified @{ for constant in spec.constants: - type = constant.type - if type in type_map: + type_name = constant.type + if type_name in type_map: # need to add _t: int8 --> int8_t - type_px4 = type_map[type] + type_px4 = type_map[type_name] else: - raise Exception("Type {0} not supported, add to to template file!".format(type)) + raise Exception("Type {0} not supported, add to to template file!".format(type_name)) print('\tstatic const %s %s = %s;'%(type_px4, constant.name, int(constant.val))) } #endif }; - -/** - * @@} - */ +//#pragma pack(pop) /* register this as object request broker structure */ -ORB_DECLARE(@(topic_name)); +@[for multi_topic in topics]@ +ORB_DECLARE(@multi_topic); +@[end for] diff --git a/msg/templates/uorb/uORBTopics.cpp.template b/msg/templates/uorb/uORBTopics.cpp.template new file mode 100644 index 0000000000..91a3a7e640 --- /dev/null +++ b/msg/templates/uorb/uORBTopics.cpp.template @@ -0,0 +1,70 @@ +@############################################### +@# +@# EmPy template for generating uORBTopics.cpp file +@# for logging purposes +@# +@############################################### +@# Start of Template +@# +@# Context: +@# - msgs (List) list of all msg files +@############################################### +/**************************************************************************** + * + * 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. + * + ****************************************************************************/ + +#include +#include +@{ +msgs_count = len(msgs) +msg_names = [mn.replace(".msg", "") for mn in msgs] +}@ +@[for msg_name in msg_names]@ +#include +@[end for] + +const size_t _uorb_topics_count = @(msgs_count); +const struct orb_metadata* _uorb_topics_list[_uorb_topics_count] = { +@[for idx, msg_name in enumerate(msg_names, 1)]@ + ORB_ID(@(msg_name))@[if idx != msgs_count],@[end if] +@[end for] +}; + +size_t orb_topics_count() +{ + return _uorb_topics_count; +} + +const struct orb_metadata **orb_get_topics() +{ + return _uorb_topics_list; +} diff --git a/msg/test_motor.msg b/msg/test_motor.msg index ec06e64fd6..2805fa64f5 100644 --- a/msg/test_motor.msg +++ b/msg/test_motor.msg @@ -1,5 +1,4 @@ uint8 NUM_MOTOR_OUTPUTS = 8 -uint64 timestamp # output timestamp in us since system boot uint32 motor_number # number of motor to spin float32 value # output power, range [0..1] diff --git a/msg/transponder_report.msg b/msg/transponder_report.msg index eac37d713f..c02fb8cc15 100644 --- a/msg/transponder_report.msg +++ b/msg/transponder_report.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Timestamp of this position report uint32 ICAO_address # ICAO address float64 lat # Latitude, expressed as degrees float64 lon # Longitude, expressed as degrees diff --git a/msg/vehicle_attitude.msg b/msg/vehicle_attitude.msg index 0ee90cd61d..2c64c32e13 100644 --- a/msg/vehicle_attitude.msg +++ b/msg/vehicle_attitude.msg @@ -1,5 +1,4 @@ # This is similar to the mavlink message ATTITUDE, but for onboard use */ -uint64 timestamp # in microseconds since system start # @warning roll, pitch and yaw have always to be valid, the rotation matrix and quaternion are optional float32 roll # Roll angle (rad, Tait-Bryan, NED) float32 pitch # Pitch angle (rad, Tait-Bryan, NED) diff --git a/msg/vehicle_attitude_setpoint.msg b/msg/vehicle_attitude_setpoint.msg index 6c12b225c8..2bbbe748fd 100644 --- a/msg/vehicle_attitude_setpoint.msg +++ b/msg/vehicle_attitude_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data float32 roll_body # body angle in NED frame float32 pitch_body # body angle in NED frame @@ -35,3 +34,6 @@ bool fw_control_yaw # control heading with rudder (used for auto takeoff on bool disable_mc_yaw_control # control yaw for mc (used for vtol weather-vane mode) bool apply_flaps + +# WAS vehicle_attitude_setpoint mc_virtual_attitude_setpoint fw_virtual_attitude_setpoint +# TOPICS vehicle_attitude_setpoint diff --git a/msg/vehicle_control_mode.msg b/msg/vehicle_control_mode.msg index 5ad1bbb9b2..32ec589061 100644 --- a/msg/vehicle_control_mode.msg +++ b/msg/vehicle_control_mode.msg @@ -1,5 +1,4 @@ -uint64 timestamp # in microseconds since system start # is set whenever the writing thread stores new data bool flag_armed diff --git a/msg/vehicle_global_position.msg b/msg/vehicle_global_position.msg index 8aa7917df0..39b815015a 100644 --- a/msg/vehicle_global_position.msg +++ b/msg/vehicle_global_position.msg @@ -4,7 +4,6 @@ # estimator, which will take more sources of information into account than just GPS, # e.g. control inputs of the vehicle in a Kalman-filter implementation. # -uint64 timestamp # Time of this estimate since system start, (microseconds) uint64 time_utc_usec # GPS UTC timestamp, (microseconds) float64 lat # Latitude, (degrees) float64 lon # Longitude, (degrees) diff --git a/msg/vehicle_land_detected.msg b/msg/vehicle_land_detected.msg index d886d31b05..e7f741b8bf 100644 --- a/msg/vehicle_land_detected.msg +++ b/msg/vehicle_land_detected.msg @@ -1,3 +1,2 @@ -uint64 timestamp # timestamp of the setpoint bool landed # true if vehicle is currently landed on the ground bool freefall # true if vehicle is currently in free-fall diff --git a/msg/vehicle_local_position.msg b/msg/vehicle_local_position.msg index 89c141c417..bf107056e2 100644 --- a/msg/vehicle_local_position.msg +++ b/msg/vehicle_local_position.msg @@ -1,6 +1,5 @@ # Fused local position in NED. -uint64 timestamp # Time of this estimate since system start, (microseconds) bool xy_valid # true if x and y are valid bool z_valid # true if z is valid bool v_xy_valid # true if vy and vy are valid diff --git a/msg/vehicle_local_position_setpoint.msg b/msg/vehicle_local_position_setpoint.msg index 927e9ab5ad..a5407519bb 100644 --- a/msg/vehicle_local_position_setpoint.msg +++ b/msg/vehicle_local_position_setpoint.msg @@ -1,6 +1,5 @@ # Local position setpoint in NED frame -uint64 timestamp # timestamp of the setpoint float32 x # in meters NED float32 y # in meters NED float32 z # in meters NED diff --git a/msg/vehicle_rates_setpoint.msg b/msg/vehicle_rates_setpoint.msg index 4fa09b563f..369b68270a 100644 --- a/msg/vehicle_rates_setpoint.msg +++ b/msg/vehicle_rates_setpoint.msg @@ -8,7 +8,6 @@ # ############################################################################################### -uint64 timestamp # in microseconds since system start float32 roll # body angular rates in NED frame float32 pitch # body angular rates in NED frame diff --git a/msg/vehicle_status.msg b/msg/vehicle_status.msg index 4e8ec96553..0444a577e1 100644 --- a/msg/vehicle_status.msg +++ b/msg/vehicle_status.msg @@ -41,7 +41,6 @@ uint8 RC_IN_MODE_GENERATED = 2 # state machine / state of vehicle. # Encodes the complete system state and is set by the commander app. -uint64 timestamp # in microseconds since system start, is set whenever the writing thread stores new data uint8 nav_state # set navigation state machine to specified value uint8 arming_state # current arming state diff --git a/msg/vtol_vehicle_status.msg b/msg/vtol_vehicle_status.msg index 27b804c437..5334e291ca 100644 --- a/msg/vtol_vehicle_status.msg +++ b/msg/vtol_vehicle_status.msg @@ -5,7 +5,6 @@ uint8 VEHICLE_VTOL_STATE_TRANSITION_TO_MC = 2 uint8 VEHICLE_VTOL_STATE_MC = 3 uint8 VEHICLE_VTOL_STATE_FW = 4 -uint64 timestamp # Microseconds since system boot bool vtol_in_rw_mode # true: vtol vehicle is in rotating wing mode bool vtol_in_trans_mode bool vtol_transition_failsafe # vtol in transition failsafe mode diff --git a/msg/wind_estimate.msg b/msg/wind_estimate.msg index fbd7b638b8..a61df3252a 100644 --- a/msg/wind_estimate.msg +++ b/msg/wind_estimate.msg @@ -1,4 +1,3 @@ -uint64 timestamp # Microseconds since system boot float32 windspeed_north # Wind component in north / X direction float32 windspeed_east # Wind component in east / Y direction float32 covariance_north # Uncertainty - set to zero (no uncertainty) if not estimated diff --git a/src/drivers/airspeed/airspeed.cpp b/src/drivers/airspeed/airspeed.cpp index 771e209489..0f4ffd1671 100644 --- a/src/drivers/airspeed/airspeed.cpp +++ b/src/drivers/airspeed/airspeed.cpp @@ -375,12 +375,11 @@ Airspeed::update_status() { if (_sensor_ok != _last_published_sensor_ok) { /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - _sensor_ok, - subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = _sensor_ok; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE; if (_subsys_pub != nullptr) { orb_publish(ORB_ID(subsystem_info), _subsys_pub, &info); diff --git a/src/drivers/ardrone_interface/ardrone_interface.c b/src/drivers/ardrone_interface/ardrone_interface.c index 8ad0ee7168..f76f0bc639 100644 --- a/src/drivers/ardrone_interface/ardrone_interface.c +++ b/src/drivers/ardrone_interface/ardrone_interface.c @@ -55,10 +55,6 @@ #include #include #include -#include -#include -#include -#include #include #include diff --git a/src/drivers/mb12xx/mb12xx.cpp b/src/drivers/mb12xx/mb12xx.cpp index 9a6fa36d79..56886a99eb 100644 --- a/src/drivers/mb12xx/mb12xx.cpp +++ b/src/drivers/mb12xx/mb12xx.cpp @@ -616,12 +616,12 @@ MB12XX::start() work_queue(HPWORK, &_work, (worker_t)&MB12XX::cycle_trampoline, this, 5); /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - true, - subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = true; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER; + static orb_advert_t pub = nullptr; if (pub != nullptr) { diff --git a/src/drivers/mkblctrl/mkblctrl.cpp b/src/drivers/mkblctrl/mkblctrl.cpp index fd0ac59551..3e53e32d47 100644 --- a/src/drivers/mkblctrl/mkblctrl.cpp +++ b/src/drivers/mkblctrl/mkblctrl.cpp @@ -75,7 +75,6 @@ #include #include -#include #include #include #include diff --git a/src/drivers/pwm_out_sim/pwm_out_sim.cpp b/src/drivers/pwm_out_sim/pwm_out_sim.cpp index 457e85bb91..20f9618c98 100644 --- a/src/drivers/pwm_out_sim/pwm_out_sim.cpp +++ b/src/drivers/pwm_out_sim/pwm_out_sim.cpp @@ -77,10 +77,6 @@ #include #include -#include -#include -#include -#include #include #include diff --git a/src/drivers/px4flow/px4flow.cpp b/src/drivers/px4flow/px4flow.cpp index 13f69a3213..095d70e38b 100644 --- a/src/drivers/px4flow/px4flow.cpp +++ b/src/drivers/px4flow/px4flow.cpp @@ -592,12 +592,12 @@ PX4FLOW::start() work_queue(HPWORK, &_work, (worker_t)&PX4FLOW::cycle_trampoline, this, 1); /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - true, - subsystem_info_s::SUBSYSTEM_TYPE_OPTICALFLOW - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = true; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_OPTICALFLOW; + static orb_advert_t pub = nullptr; if (pub != nullptr) { diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 4c39f3b7c4..d74765f6a1 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -79,10 +79,6 @@ #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/drivers/px4io/px4io.cpp b/src/drivers/px4io/px4io.cpp index 000d04e491..a1e1525514 100644 --- a/src/drivers/px4io/px4io.cpp +++ b/src/drivers/px4io/px4io.cpp @@ -77,10 +77,6 @@ #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/drivers/roboclaw/RoboClaw.cpp b/src/drivers/roboclaw/RoboClaw.cpp index c1f4a01960..d3eda8609e 100644 --- a/src/drivers/roboclaw/RoboClaw.cpp +++ b/src/drivers/roboclaw/RoboClaw.cpp @@ -54,7 +54,6 @@ #include #include -#include #include #include diff --git a/src/drivers/snapdragon_rc_pwm/snapdragon_rc_pwm.cpp b/src/drivers/snapdragon_rc_pwm/snapdragon_rc_pwm.cpp index 438151ae4e..ce86147904 100644 --- a/src/drivers/snapdragon_rc_pwm/snapdragon_rc_pwm.cpp +++ b/src/drivers/snapdragon_rc_pwm/snapdragon_rc_pwm.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include diff --git a/src/drivers/srf02/srf02.cpp b/src/drivers/srf02/srf02.cpp index f585acb6a6..b5600e2a73 100644 --- a/src/drivers/srf02/srf02.cpp +++ b/src/drivers/srf02/srf02.cpp @@ -618,12 +618,12 @@ SRF02::start() work_queue(HPWORK, &_work, (worker_t)&SRF02::cycle_trampoline, this, 5); /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - true, - subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = true; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER; + static orb_advert_t pub = nullptr; if (pub != nullptr) { diff --git a/src/drivers/trone/trone.cpp b/src/drivers/trone/trone.cpp index 3ec40c624d..aea4bc9449 100644 --- a/src/drivers/trone/trone.cpp +++ b/src/drivers/trone/trone.cpp @@ -628,12 +628,12 @@ TRONE::start() work_queue(HPWORK, &_work, (worker_t)&TRONE::cycle_trampoline, this, 1); /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - true, - subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = true; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_RANGEFINDER; + static orb_advert_t pub = nullptr; if (pub != nullptr) { diff --git a/src/examples/fixedwing_control/main.c b/src/examples/fixedwing_control/main.c index 3d6aa88269..f8a9de39ce 100644 --- a/src/examples/fixedwing_control/main.c +++ b/src/examples/fixedwing_control/main.c @@ -61,10 +61,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/examples/hwtest/hwtest.c b/src/examples/hwtest/hwtest.c index 97a525a8e9..b1b1b465f9 100644 --- a/src/examples/hwtest/hwtest.c +++ b/src/examples/hwtest/hwtest.c @@ -47,10 +47,6 @@ #include #include #include -#include -#include -#include -#include #include __EXPORT int ex_hwtest_main(int argc, char *argv[]); diff --git a/src/examples/rover_steering_control/main.cpp b/src/examples/rover_steering_control/main.cpp index 7a227c2366..563d6b0cca 100644 --- a/src/examples/rover_steering_control/main.cpp +++ b/src/examples/rover_steering_control/main.cpp @@ -58,10 +58,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/lib/controllib/uorb/blocks.hpp b/src/lib/controllib/uorb/blocks.hpp index 7766b67f6b..42aae92284 100644 --- a/src/lib/controllib/uorb/blocks.hpp +++ b/src/lib/controllib/uorb/blocks.hpp @@ -47,10 +47,6 @@ #include #include #include -#include -#include -#include -#include #include #include diff --git a/src/modules/bottle_drop/bottle_drop.cpp b/src/modules/bottle_drop/bottle_drop.cpp index 97e4b178e6..8cd4ed66eb 100644 --- a/src/modules/bottle_drop/bottle_drop.cpp +++ b/src/modules/bottle_drop/bottle_drop.cpp @@ -57,10 +57,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 0d96672654..ba304dd229 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -81,10 +81,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index 653d471e75..16d1376b38 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -62,8 +62,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/modules/mavlink/mavlink_parameters.cpp b/src/modules/mavlink/mavlink_parameters.cpp index b24d0464fb..50fc0429be 100644 --- a/src/modules/mavlink/mavlink_parameters.cpp +++ b/src/modules/mavlink/mavlink_parameters.cpp @@ -47,8 +47,6 @@ #include "mavlink_parameters.h" #include "mavlink_main.h" -ORB_DEFINE(uavcan_parameter_request, struct uavcan_parameter_request_s); -ORB_DEFINE(uavcan_parameter_value, struct uavcan_parameter_value_s); #define HASH_PARAM "_HASH_CHECK" MavlinkParametersManager::MavlinkParametersManager(Mavlink *mavlink) : MavlinkStream(mavlink), diff --git a/src/modules/mc_att_control/mc_att_control_main.cpp b/src/modules/mc_att_control/mc_att_control_main.cpp index 3ba1f4769e..c06259b74c 100644 --- a/src/modules/mc_att_control/mc_att_control_main.cpp +++ b/src/modules/mc_att_control/mc_att_control_main.cpp @@ -70,8 +70,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp index 114bdee530..1677a91d3c 100644 --- a/src/modules/position_estimator_inav/position_estimator_inav_main.cpp +++ b/src/modules/position_estimator_inav/position_estimator_inav_main.cpp @@ -52,10 +52,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index 5da029a608..0193d90600 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -78,10 +78,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index 16e5b9532d..5958399252 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -136,9 +136,6 @@ UT_array *param_values; /** array info for the modified parameters array */ const UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL}; -/** parameter update topic */ -ORB_DEFINE(parameter_update, struct parameter_update_s); - /** parameter update topic handle */ static orb_advert_t param_topic = NULL; diff --git a/src/modules/systemlib/param/param_shmem.c b/src/modules/systemlib/param/param_shmem.c index cefb67a888..5803b292bb 100644 --- a/src/modules/systemlib/param/param_shmem.c +++ b/src/modules/systemlib/param/param_shmem.c @@ -158,9 +158,6 @@ UT_array *param_values; /** array info for the modified parameters array */ const UT_icd param_icd = {sizeof(struct param_wbuf_s), NULL, NULL, NULL}; -/** parameter update topic */ -ORB_DEFINE(parameter_update, struct parameter_update_s); - /** parameter update topic handle */ static orb_advert_t param_topic = NULL; diff --git a/src/modules/uORB/CMakeLists.txt b/src/modules/uORB/CMakeLists.txt index d8f8c9bc2a..c8180c29f8 100644 --- a/src/modules/uORB/CMakeLists.txt +++ b/src/modules/uORB/CMakeLists.txt @@ -36,8 +36,9 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) +link_libraries(msg_gen) + set(SRCS - objects_common.cpp uORBUtils.cpp uORB.cpp uORBMain.cpp diff --git a/src/modules/uORB/Subscription.cpp b/src/modules/uORB/Subscription.cpp index 0106d81a41..64067967d1 100644 --- a/src/modules/uORB/Subscription.cpp +++ b/src/modules/uORB/Subscription.cpp @@ -144,6 +144,12 @@ void Subscription::update() SubscriptionBase::update((void *)(&_data)); } +template +bool Subscription::check_updated() +{ + return SubscriptionBase::updated(); +} + template const T &Subscription::get() { return _data; } diff --git a/src/modules/uORB/Subscription.hpp b/src/modules/uORB/Subscription.hpp index 1d547be842..7b55b4a2a0 100644 --- a/src/modules/uORB/Subscription.hpp +++ b/src/modules/uORB/Subscription.hpp @@ -185,6 +185,10 @@ public: */ void update(); + /** + * Create an update function that uses the embedded struct. + */ + bool check_updated(); /* * This function gets the T struct data * */ diff --git a/src/modules/uORB/objects_common.cpp b/src/modules/uORB/objects_common.cpp deleted file mode 100644 index fa381a15e3..0000000000 --- a/src/modules/uORB/objects_common.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/**************************************************************************** - * - * Copyright (c) 2012-2016 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. - * - ****************************************************************************/ - -/** - * @file objects_common.cpp - * - * Common object definitions without a better home. - */ - -/** - * @defgroup topics List of all uORB topics. - */ - -#include - -#include - -#include "topics/sensor_mag.h" -ORB_DEFINE(sensor_mag, struct sensor_mag_s); - -#include "topics/sensor_accel.h" -ORB_DEFINE(sensor_accel, struct sensor_accel_s); - -#include "topics/sensor_gyro.h" -ORB_DEFINE(sensor_gyro, struct sensor_gyro_s); - -#include "topics/sensor_baro.h" -ORB_DEFINE(sensor_baro, struct sensor_baro_s); - -#include "topics/output_pwm.h" -ORB_DEFINE(output_pwm, struct output_pwm_s); - -#include "topics/input_rc.h" -ORB_DEFINE(input_rc, struct input_rc_s); - -#include "topics/pwm_input.h" -ORB_DEFINE(pwm_input, struct pwm_input_s); - -#include "topics/vehicle_attitude.h" -ORB_DEFINE(vehicle_attitude, struct vehicle_attitude_s); - -#include "topics/control_state.h" -ORB_DEFINE(control_state, struct control_state_s); - -#include "topics/sensor_combined.h" -ORB_DEFINE(sensor_combined, struct sensor_combined_s); - -#include "topics/hil_sensor.h" -ORB_DEFINE(hil_sensor, struct hil_sensor_s); - -#include "topics/vehicle_gps_position.h" -ORB_DEFINE(vehicle_gps_position, struct vehicle_gps_position_s); - -#include "topics/vehicle_land_detected.h" -ORB_DEFINE(vehicle_land_detected, struct vehicle_land_detected_s); - -#include "topics/satellite_info.h" -ORB_DEFINE(satellite_info, struct satellite_info_s); - -#include "topics/home_position.h" -ORB_DEFINE(home_position, struct home_position_s); - -#include "topics/vehicle_status.h" -ORB_DEFINE(vehicle_status, struct vehicle_status_s); - -#include "topics/vtol_vehicle_status.h" -ORB_DEFINE(vtol_vehicle_status, struct vtol_vehicle_status_s); - -#include "topics/safety.h" -ORB_DEFINE(safety, struct safety_s); - -#include "topics/battery_status.h" -ORB_DEFINE(battery_status, struct battery_status_s); - -#include "topics/servorail_status.h" -ORB_DEFINE(servorail_status, struct servorail_status_s); - -#include "topics/system_power.h" -ORB_DEFINE(system_power, struct system_power_s); - -#include "topics/vehicle_global_position.h" -ORB_DEFINE(vehicle_global_position, struct vehicle_global_position_s); - -#include "topics/vehicle_local_position.h" -ORB_DEFINE(vehicle_local_position, struct vehicle_local_position_s); - -#include "topics/att_pos_mocap.h" -ORB_DEFINE(att_pos_mocap, struct att_pos_mocap_s); - -#include "topics/vehicle_rates_setpoint.h" -ORB_DEFINE(vehicle_rates_setpoint, struct vehicle_rates_setpoint_s); -#include "topics/mc_virtual_rates_setpoint.h" -ORB_DEFINE(mc_virtual_rates_setpoint, struct mc_virtual_rates_setpoint_s); -#include "topics/fw_virtual_rates_setpoint.h" -ORB_DEFINE(fw_virtual_rates_setpoint, struct fw_virtual_rates_setpoint_s); - -#include "topics/rc_channels.h" -ORB_DEFINE(rc_channels, struct rc_channels_s); - -#include "topics/vehicle_command.h" -ORB_DEFINE(vehicle_command, struct vehicle_command_s); - -#include "topics/vehicle_control_mode.h" -ORB_DEFINE(vehicle_control_mode, struct vehicle_control_mode_s); - -#include "topics/vehicle_local_position_setpoint.h" -ORB_DEFINE(vehicle_local_position_setpoint, struct vehicle_local_position_setpoint_s); - -#include "topics/position_setpoint_triplet.h" -ORB_DEFINE(position_setpoint_triplet, struct position_setpoint_triplet_s); - -#include "topics/vehicle_global_velocity_setpoint.h" -ORB_DEFINE(vehicle_global_velocity_setpoint, struct vehicle_global_velocity_setpoint_s); - -#include "topics/mission.h" -ORB_DEFINE(mission, struct mission_s); -// XXX onboard and offboard mission are still declared here until this is -// generator supported -#include -ORB_DEFINE(offboard_mission, struct mission_s); -ORB_DEFINE(onboard_mission, struct mission_s); - -#include "topics/mission_result.h" -ORB_DEFINE(mission_result, struct mission_result_s); - -#include "topics/geofence_result.h" -ORB_DEFINE(geofence_result, struct geofence_result_s); - -#include "topics/fence.h" -ORB_DEFINE(fence, struct fence_s); - -#include "topics/fence_vertex.h" -ORB_DEFINE(fence_vertex, struct fence_vertex_s); - -#include "topics/vehicle_attitude_setpoint.h" -ORB_DEFINE(vehicle_attitude_setpoint, struct vehicle_attitude_setpoint_s); - -#include "topics/mc_virtual_attitude_setpoint.h" -ORB_DEFINE(mc_virtual_attitude_setpoint, struct mc_virtual_attitude_setpoint_s); - -#include "topics/fw_virtual_attitude_setpoint.h" -ORB_DEFINE(fw_virtual_attitude_setpoint, struct fw_virtual_attitude_setpoint_s); - -#include "topics/manual_control_setpoint.h" -ORB_DEFINE(manual_control_setpoint, struct manual_control_setpoint_s); - -#include "topics/offboard_control_mode.h" -ORB_DEFINE(offboard_control_mode, struct offboard_control_mode_s); - -#include "topics/optical_flow.h" -ORB_DEFINE(optical_flow, struct optical_flow_s); - -#include "topics/filtered_bottom_flow.h" -ORB_DEFINE(filtered_bottom_flow, struct filtered_bottom_flow_s); - -#include "topics/airspeed.h" -ORB_DEFINE(airspeed, struct airspeed_s); - -#include "topics/differential_pressure.h" -ORB_DEFINE(differential_pressure, struct differential_pressure_s); - -#include "topics/subsystem_info.h" -ORB_DEFINE(subsystem_info, struct subsystem_info_s); - -/* actuator controls, as requested by controller */ -#include "topics/actuator_controls.h" -#include "topics/actuator_controls_0.h" -ORB_DEFINE(actuator_controls_0, struct actuator_controls_0_s); -#include "topics/actuator_controls_1.h" -ORB_DEFINE(actuator_controls_1, struct actuator_controls_1_s); -#include "topics/actuator_controls_2.h" -ORB_DEFINE(actuator_controls_2, struct actuator_controls_2_s); -#include "topics/actuator_controls_3.h" -ORB_DEFINE(actuator_controls_3, struct actuator_controls_3_s); -//Virtual control groups, used for VTOL operation -#include "topics/actuator_controls_virtual_mc.h" -ORB_DEFINE(actuator_controls_virtual_mc, struct actuator_controls_virtual_mc_s); -#include "topics/actuator_controls_virtual_fw.h" -ORB_DEFINE(actuator_controls_virtual_fw, struct actuator_controls_virtual_fw_s); - -#include "topics/actuator_armed.h" -ORB_DEFINE(actuator_armed, struct actuator_armed_s); - -#include "topics/actuator_outputs.h" -ORB_DEFINE(actuator_outputs, struct actuator_outputs_s); - -#include "topics/actuator_direct.h" -ORB_DEFINE(actuator_direct, struct actuator_direct_s); - -#include "topics/multirotor_motor_limits.h" -ORB_DEFINE(multirotor_motor_limits, struct multirotor_motor_limits_s); - -#include "topics/telemetry_status.h" -ORB_DEFINE(telemetry_status, struct telemetry_status_s); - -#include "topics/test_motor.h" -ORB_DEFINE(test_motor, struct test_motor_s); - -#include "topics/debug_key_value.h" -ORB_DEFINE(debug_key_value, struct debug_key_value_s); - -#include "topics/fw_pos_ctrl_status.h" -ORB_DEFINE(fw_pos_ctrl_status, struct fw_pos_ctrl_status_s); - -#include "topics/esc_status.h" -ORB_DEFINE(esc_status, struct esc_status_s); - -#include "topics/esc_report.h" -ORB_DEFINE(esc_report, struct esc_report_s); - -#include "topics/encoders.h" -ORB_DEFINE(encoders, struct encoders_s); - -#include "topics/estimator_status.h" -ORB_DEFINE(estimator_status, struct estimator_status_s); - -#include "topics/vision_position_estimate.h" -ORB_DEFINE(vision_position_estimate, struct vision_position_estimate_s); - -#include "topics/vehicle_force_setpoint.h" -ORB_DEFINE(vehicle_force_setpoint, struct vehicle_force_setpoint_s); - -#include "topics/tecs_status.h" -ORB_DEFINE(tecs_status, struct tecs_status_s); - -#include "topics/wind_estimate.h" -ORB_DEFINE(wind_estimate, struct wind_estimate_s); - -#include "topics/rc_parameter_map.h" -ORB_DEFINE(rc_parameter_map, struct rc_parameter_map_s); - -#include "topics/time_offset.h" -ORB_DEFINE(time_offset, struct time_offset_s); - -#include "topics/mc_att_ctrl_status.h" -ORB_DEFINE(mc_att_ctrl_status, struct mc_att_ctrl_status_s); - -#include "topics/distance_sensor.h" -ORB_DEFINE(distance_sensor, struct distance_sensor_s); - -#include "topics/camera_trigger.h" -ORB_DEFINE(camera_trigger, struct camera_trigger_s); - -#include "topics/vehicle_command_ack.h" -ORB_DEFINE(vehicle_command_ack, struct vehicle_command_ack_s); - -#include "topics/ekf2_innovations.h" -ORB_DEFINE(ekf2_innovations, struct ekf2_innovations_s); - -#include "topics/ekf2_replay.h" -ORB_DEFINE(ekf2_replay, struct ekf2_replay_s); - -#include "topics/qshell_req.h" -ORB_DEFINE(qshell_req, struct qshell_req_s); - -#include "topics/mavlink_log.h" -ORB_DEFINE(mavlink_log, struct mavlink_log_s); - -#include "topics/follow_target.h" -ORB_DEFINE(follow_target, struct follow_target_s); - -#include "topics/commander_state.h" -ORB_DEFINE(commander_state, struct commander_state_s); - -#include "topics/transponder_report.h" -ORB_DEFINE(transponder_report, struct transponder_report_s); - -#include "topics/gps_inject_data.h" -ORB_DEFINE(gps_inject_data, struct gps_inject_data_s); - -#include "topics/adc_report.h" -ORB_DEFINE(adc_report, struct adc_report_s); - -#include "topics/cpuload.h" -ORB_DEFINE(cpuload, struct cpuload_s); diff --git a/src/modules/uORB/uORB.h b/src/modules/uORB/uORB.h index 807da7b75b..d1027d3b0e 100644 --- a/src/modules/uORB/uORB.h +++ b/src/modules/uORB/uORB.h @@ -52,6 +52,7 @@ struct orb_metadata { const char *o_name; /**< unique object name */ const size_t o_size; /**< object size */ + const char *o_fields; /**< semicolon separated list of fields */ }; typedef const struct orb_metadata *orb_id_t; @@ -110,11 +111,13 @@ enum ORB_PRIO { * * @param _name The name of the topic. * @param _struct The structure the topic provides. + * @param _fields All fields in a semicolon separated list e.g: "float[3] position;bool armed" */ -#define ORB_DEFINE(_name, _struct) \ +#define ORB_DEFINE(_name, _struct, _fields) \ const struct orb_metadata __orb_##_name = { \ #_name, \ - sizeof(_struct) \ + sizeof(_struct), \ + _fields \ }; struct hack __BEGIN_DECLS diff --git a/src/modules/uORB/uORBTopics.h b/src/modules/uORB/uORBTopics.h new file mode 100644 index 0000000000..f7c3a3c865 --- /dev/null +++ b/src/modules/uORB/uORBTopics.h @@ -0,0 +1,50 @@ +/**************************************************************************** + * + * Copyright (c) 2012-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. + * + ****************************************************************************/ + +#ifndef MODULES_UORB_UORBTOPICS_H_ +#define MODULES_UORB_UORBTOPICS_H_ + +#include + +/* + * Returns count of all declared topics. + * It is equal to size of array from orb_get_topics() + */ +extern size_t orb_topics_count() __EXPORT; + +/* + * Returns array of topics metadata + */ +extern const struct orb_metadata **orb_get_topics() __EXPORT; + +#endif /* MODULES_UORB_UORBTOPICS_H_ */ diff --git a/src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp b/src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp index 5722b164b3..032b25a544 100644 --- a/src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp +++ b/src/modules/uORB/uORB_tests/uORBTest_UnitTest.hpp @@ -41,23 +41,26 @@ struct orb_test { int val; hrt_abstime time; }; -ORB_DEFINE(orb_test, struct orb_test); -ORB_DEFINE(orb_multitest, struct orb_test); +ORB_DEFINE(orb_test, struct orb_test, "ORB_TEST:int val;hrt_abstime time;"); +ORB_DEFINE(orb_multitest, struct orb_test, "ORB_MULTITEST:int val;hrt_abstime time;"); + struct orb_test_medium { int val; hrt_abstime time; char junk[64]; }; -ORB_DEFINE(orb_test_medium, struct orb_test_medium); -ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium); +ORB_DEFINE(orb_test_medium, struct orb_test_medium, "ORB_TEST_MEDIUM:int val;hrt_abstime time;char[64] junk;"); +ORB_DEFINE(orb_test_medium_multi, struct orb_test_medium, + "ORB_TEST_MEDIUM_MULTI:int val;hrt_abstime time;char[64] junk;"); + struct orb_test_large { int val; hrt_abstime time; char junk[512]; }; -ORB_DEFINE(orb_test_large, struct orb_test_large); +ORB_DEFINE(orb_test_large, struct orb_test_large, "ORB_TEST_LARGE:int val;hrt_abstime time;char[512] junk;"); namespace uORBTest diff --git a/src/modules/vtol_att_control/vtol_att_control_main.h b/src/modules/vtol_att_control/vtol_att_control_main.h index cf072af71d..e2a63993d7 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.h +++ b/src/modules/vtol_att_control/vtol_att_control_main.h @@ -69,8 +69,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/platforms/posix/drivers/airspeedsim/airspeedsim.cpp b/src/platforms/posix/drivers/airspeedsim/airspeedsim.cpp index 58f6aa9929..25bc4672fb 100644 --- a/src/platforms/posix/drivers/airspeedsim/airspeedsim.cpp +++ b/src/platforms/posix/drivers/airspeedsim/airspeedsim.cpp @@ -371,12 +371,11 @@ AirspeedSim::update_status() { if (_sensor_ok != _last_published_sensor_ok) { /* notify about state change */ - struct subsystem_info_s info = { - true, - true, - _sensor_ok, - subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE - }; + struct subsystem_info_s info = {}; + info.present = true; + info.enabled = true; + info.ok = _sensor_ok; + info.subsystem_type = subsystem_info_s::SUBSYSTEM_TYPE_DIFFPRESSURE; if (_subsys_pub != nullptr) { orb_publish(ORB_ID(subsystem_info), _subsys_pub, &info); diff --git a/src/platforms/px4_includes.h b/src/platforms/px4_includes.h index a38b1e7cb3..434bd5e78b 100644 --- a/src/platforms/px4_includes.h +++ b/src/platforms/px4_includes.h @@ -53,8 +53,6 @@ #include #include #include -#include -#include #include #include #include @@ -82,10 +80,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -117,10 +111,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include @@ -148,10 +138,6 @@ #include #include #include -#include -#include -#include -#include #include #include #include diff --git a/src/systemcmds/esc_calib/esc_calib.c b/src/systemcmds/esc_calib/esc_calib.c index 86939ff686..161fe7923b 100644 --- a/src/systemcmds/esc_calib/esc_calib.c +++ b/src/systemcmds/esc_calib/esc_calib.c @@ -60,10 +60,6 @@ #include "drivers/drv_pwm_output.h" #include -#include -#include -#include -#include static void usage(const char *reason); __EXPORT int esc_calib_main(int argc, char *argv[]); diff --git a/unittests/uorb_unittests/uORBCommunicator_gtests.cpp b/unittests/uorb_unittests/uORBCommunicator_gtests.cpp index 1ea12b7a96..35822f016f 100644 --- a/unittests/uorb_unittests/uORBCommunicator_gtests.cpp +++ b/unittests/uorb_unittests/uORBCommunicator_gtests.cpp @@ -206,7 +206,7 @@ namespace uORB_test ASSERT_EQ( c._send_messageCount, 0 ); //step 1. - ORB_DEFINE( topicA_sndmsg, struct orb_topic_A ); + ORB_DEFINE( topicA_sndmsg, struct orb_topic_A, "TOPICA_SNDMSG:int16_t val;" ); _topicA.val = 1; _pub_ptr = orb_advertise(ORB_ID(topicA_sndmsg ), &_topicA ); ASSERT_TRUE( ( _pub_ptr != nullptr ) ) << "Failed to advertize uORB Topic topicA_sndmsg: errno: " << errno; diff --git a/unittests/uorb_unittests/uORBGtestTopics.hpp b/unittests/uorb_unittests/uORBGtestTopics.hpp index 0616afe83e..0cea8d55fc 100644 --- a/unittests/uorb_unittests/uORBGtestTopics.hpp +++ b/unittests/uorb_unittests/uORBGtestTopics.hpp @@ -48,12 +48,11 @@ namespace uORB_test int16_t val; }; + ORB_DEFINE( topicA, struct orb_topic_A, "TOPICA:int16 val;" ); + ORB_DEFINE( topicB, struct orb_topic_B, "TOPICB:int16 val;" ); - ORB_DEFINE( topicA, struct orb_topic_A ); - ORB_DEFINE( topicB, struct orb_topic_B ); - - ORB_DEFINE( topicA_clone, struct orb_topic_A ); - ORB_DEFINE( topicB_clone, struct orb_topic_B ); + ORB_DEFINE( topicA_clone, struct orb_topic_A, "TOPICA_CLONE:int16 val;" ); + ORB_DEFINE( topicB_clone, struct orb_topic_B, "TOPICB_CLONE:int16 val;" ); } #endif // _UnitTest_uORBTopics_hpp_