From 6416cc66d7e630973c3ba81a676a7557abcb53b5 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 4 Oct 2022 12:43:37 +0900 Subject: [PATCH 01/14] track the update of EmbeddedRTPS to 1410a87 This commit point is used in embeddedRTPS-STM32 https://github.com/embedded-software-laboratory/embeddedRTPS-STM32/tree/master/stm32/Middlewares/Third_Party https://github.com/embedded-software-laboratory/embeddedRTPS/tree/1410a8776660244249a84031ffa78c9bdaa45e19 --- embeddedRTPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embeddedRTPS b/embeddedRTPS index 501987d..1410a87 160000 --- a/embeddedRTPS +++ b/embeddedRTPS @@ -1 +1 @@ -Subproject commit 501987d23540b4aeed7cb9703db36e58d976c10b +Subproject commit 1410a8776660244249a84031ffa78c9bdaa45e19 From 1b4e93484d8b00b5e2d8e2fa31b67d0478b5ab15 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 4 Oct 2022 14:07:48 +0900 Subject: [PATCH 02/14] remove deprecated files in the latest embeddedRTPS --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60b132e..23a947a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,6 @@ target_sources(mros2 embeddedRTPS/src/discovery/ParticipantProxyData.cpp embeddedRTPS/src/discovery/SEDPAgent.cpp embeddedRTPS/src/discovery/SPDPAgent.cpp - embeddedRTPS/src/storages/HistoryCache.cpp - embeddedRTPS/src/storages/SimpleHistoryCache.cpp embeddedRTPS/src/storages/PBufWrapper.cpp embeddedRTPS/src/ThreadPool.cpp embeddedRTPS/src/entities/Participant.cpp From 78c0b92bb236ffb60c367ecd40f6c6e0d362e972 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 4 Oct 2022 19:04:16 +0900 Subject: [PATCH 03/14] ertps: move member var `data` to `public:` --- embeddedRTPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embeddedRTPS b/embeddedRTPS index 1410a87..1bbf054 160000 --- a/embeddedRTPS +++ b/embeddedRTPS @@ -1 +1 @@ -Subproject commit 1410a8776660244249a84031ffa78c9bdaa45e19 +Subproject commit 1bbf054b3022c80c4b9eeaa9e389f852bb16b1d6 From 7bee03fe260a7ae393ce787a91a3f373d688a06a Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 4 Oct 2022 19:04:44 +0900 Subject: [PATCH 04/14] enlarge stack size to main thread --- src/mros2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mros2.cpp b/src/mros2.cpp index a2c8014..06541dc 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -67,7 +67,7 @@ void init(int argc, char * argv[]) osThreadAttr_t attributes; attributes.name = "mROS2Thread", - attributes.stack_size = 1000, + attributes.stack_size = 5000, attributes.priority = (osPriority_t)24, osThreadNew(mros2_init, NULL, (const osThreadAttr_t*)&attributes); From ccb33b30024ce619346c4640620e5432465f0917 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Wed, 5 Oct 2022 11:01:19 +0900 Subject: [PATCH 05/14] rebase include/rtps/entities/Reader.h to the original https://github.com/mROS-base/mros2/commit/78c0b92bb236ffb60c367ecd40f6c6e0d362e972 https://github.com/mROS-base/embeddedRTPS/compare/1410a8776660244249a84031ffa78c9bdaa45e19...1bbf054b3022c80c4b9eeaa9e389f852bb16b1d6#diff-b258a5cba0f124209d753ab838fec9babe15c7fa3aac75a49ef3a5e592fe592f --- embeddedRTPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embeddedRTPS b/embeddedRTPS index 1bbf054..1410a87 160000 --- a/embeddedRTPS +++ b/embeddedRTPS @@ -1 +1 @@ -Subproject commit 1bbf054b3022c80c4b9eeaa9e389f852bb16b1d6 +Subproject commit 1410a8776660244249a84031ffa78c9bdaa45e19 From b92b69f0c9a2ab3324b17f37581aebeff97149cf Mon Sep 17 00:00:00 2001 From: takasehideki Date: Wed, 5 Oct 2022 11:02:43 +0900 Subject: [PATCH 06/14] use ReaderCacheChange.getData() for msg.copyFromBuf() --- src/mros2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mros2.cpp b/src/mros2.cpp index 06541dc..d67a2d6 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -217,7 +217,8 @@ template void Subscriber::callback_handler(void *callee, const rtps::ReaderCacheChange &cacheChange) { T msg; - msg.copyFromBuf(&cacheChange.data[4]); + const uint8_t *cacheData = cacheChange.getData(); + msg.copyFromBuf(&cacheData[4]); SubscribeDataType *sub = (SubscribeDataType *)callee; void (*fp)(intptr_t) = sub->cb_fp; From 42751df136ce216970e46a6303e984d3e7af267f Mon Sep 17 00:00:00 2001 From: takasehideki Date: Thu, 6 Oct 2022 18:27:39 +0900 Subject: [PATCH 07/14] enlarge stack size to main thread --- src/mros2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mros2.cpp b/src/mros2.cpp index d67a2d6..4848daf 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -61,7 +61,7 @@ void init(int argc, char * argv[]) buf[3] = 0; #ifdef __MBED__ - mros2_init_thread = new Thread(osPriorityAboveNormal, 2000, nullptr, "mROS2Thread"); + mros2_init_thread = new Thread(osPriorityAboveNormal, 5000, nullptr, "mROS2Thread"); mros2_init_thread->start(callback(mros2_init, (void *)NULL)); #else /* __MBED__ */ osThreadAttr_t attributes; From 4dbd863f0a2d2210a2ffdd4e9400638272c41214 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Mon, 17 Oct 2022 16:56:45 +0900 Subject: [PATCH 08/14] modify path to absolute --- CMakeLists.txt | 48 ++++++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23a947a..408fbb1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,32 +1,36 @@ # Copyright (c) 2021 smorita_emb # SPDX-License-Identifier: Apache-2.0 +cmake_minimum_required(VERSION 3.16.3) + +project(mros2) + target_include_directories(mros2 BEFORE INTERFACE - embeddedRTPS/thirdparty/Micro-CDR/include - embeddedRTPS/include - include - mros2_msgs + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/include + ${PROJECT_SOURCE_DIR}/embeddedRTPS/include + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_SOURCE_DIR}/mros2_msgs ) target_sources(mros2 INTERFACE - src/mros2.cpp - embeddedRTPS/src/communication/UdpDriver.cpp - embeddedRTPS/src/messages/MessageTypes.cpp - embeddedRTPS/src/messages/MessageReceiver.cpp - embeddedRTPS/src/discovery/TopicData.cpp - embeddedRTPS/src/discovery/ParticipantProxyData.cpp - embeddedRTPS/src/discovery/SEDPAgent.cpp - embeddedRTPS/src/discovery/SPDPAgent.cpp - embeddedRTPS/src/storages/PBufWrapper.cpp - embeddedRTPS/src/ThreadPool.cpp - embeddedRTPS/src/entities/Participant.cpp - embeddedRTPS/src/entities/Domain.cpp - embeddedRTPS/src/entities/StatelessReader.cpp - embeddedRTPS/thirdparty/Micro-CDR/src/c/common.c - embeddedRTPS/thirdparty/Micro-CDR/src/c/types/basic.c - embeddedRTPS/thirdparty/Micro-CDR/src/c/types/string.c - embeddedRTPS/thirdparty/Micro-CDR/src/c/types/sequence.c - embeddedRTPS/thirdparty/Micro-CDR/src/c/types/array.c + ${PROJECT_SOURCE_DIR}/src/mros2.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/communication/UdpDriver.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/messages/MessageTypes.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/messages/MessageReceiver.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/TopicData.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/ParticipantProxyData.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/SEDPAgent.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/SPDPAgent.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/storages/PBufWrapper.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/ThreadPool.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/Participant.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/Domain.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/StatelessReader.cpp + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/common.c + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/basic.c + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/string.c + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/sequence.c + ${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/array.c ) \ No newline at end of file From 96a2615e6e9b904bcc7577bdb1632fc77ad8c004 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Mon, 17 Oct 2022 17:00:13 +0900 Subject: [PATCH 09/14] move declaration of sub_msg_count out of `__MBED__` because Mbed doesn't use this variable --- src/mros2.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mros2.cpp b/src/mros2.cpp index 4848daf..a4cf172 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -86,12 +86,11 @@ void mros2_init(void *args) MROS2_DEBUG("[MROS2LIB] Initilizing lwIP complete"); #endif /* __MBED__ */ - int sub_msg_count; static rtps::Domain domain; domain_ptr = &domain; #ifndef __MBED__ - sub_msg_count = mros2_get_submsg_count(); + int sub_msg_count = mros2_get_submsg_count(); subscriber_msg_queue_id = osMessageQueueNew(sub_msg_count, SUB_MSG_SIZE, NULL); if (subscriber_msg_queue_id == NULL) { MROS2_ERROR("[MROS2LIB] ERROR: mROS2 init failed"); From e3935451221ec3f7bb27cf960985d54a656e1a76 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Mon, 17 Oct 2022 18:05:05 +0900 Subject: [PATCH 10/14] add FreeRTOS conversion definition by moving from mros2-mbed --- include/mros2/freertos_conversion.h | 41 +++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/mros2/freertos_conversion.h diff --git a/include/mros2/freertos_conversion.h b/include/mros2/freertos_conversion.h new file mode 100644 index 0000000..93bc348 --- /dev/null +++ b/include/mros2/freertos_conversion.h @@ -0,0 +1,41 @@ +/* + * Conversion of FreeRTOS's definitions/types/functions in embeddedRTPS + * + * Copyright (c) 2022 mROS-base + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef RTPS_CONVERSION_H +#define RTPS_CONVERSION_H + +#ifdef __cplusplus +extern "C" { +#endif +#include +typedef uint32_t TickType_t; +#define configTICK_RATE_HZ ((TickType_t)1000) + +#ifndef pdMS_TO_TICKS +#define pdMS_TO_TICKS(xTimeInMs) ((TickType_t)(((TickType_t)(xTimeInMs) * (TickType_t)configTICK_RATE_HZ) / (TickType_t)1000)) +#endif + +#define xTaskGetTickCount osKernelGetTickCount +#define vTaskDelay osDelay + +void sys_msleep(unsigned int ms); +#ifdef __cplusplus +} +#endif + +#endif /* RTPS_CONVERSION_H */ \ No newline at end of file From 8df6a67a3951f248898283efcca02f9a866b7047 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Mon, 17 Oct 2022 19:19:54 +0900 Subject: [PATCH 11/14] simplify definition of SUB_MSG_COUNT and move to mros2 repo --- include/{mros2_user_config.h => mros2_config.h} | 2 +- src/mros2.cpp | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) rename include/{mros2_user_config.h => mros2_config.h} (75%) diff --git a/include/mros2_user_config.h b/include/mros2_config.h similarity index 75% rename from include/mros2_user_config.h rename to include/mros2_config.h index 114d0c5..ea6cff3 100644 --- a/include/mros2_user_config.h +++ b/include/mros2_config.h @@ -5,7 +5,7 @@ extern "C" { #endif -extern int mros2_get_submsg_count(void); +#define SUB_MSG_COUNT 10 #ifdef __cplusplus } diff --git a/src/mros2.cpp b/src/mros2.cpp index a4cf172..0fbf1ff 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -1,11 +1,11 @@ #include "mros2.h" -#include "mros2_user_config.h" #include #ifdef __MBED__ #include "mbed.h" #else /* __MBED__ */ +#include "mros2_config.h" #include "cmsis_os.h" #endif /* __MBED__ */ @@ -90,8 +90,7 @@ void mros2_init(void *args) domain_ptr = &domain; #ifndef __MBED__ - int sub_msg_count = mros2_get_submsg_count(); - subscriber_msg_queue_id = osMessageQueueNew(sub_msg_count, SUB_MSG_SIZE, NULL); + subscriber_msg_queue_id = osMessageQueueNew(SUB_MSG_COUNT, SUB_MSG_SIZE, NULL); if (subscriber_msg_queue_id == NULL) { MROS2_ERROR("[MROS2LIB] ERROR: mROS2 init failed"); return; From 231940660a314aa2147be702aec9d248faaf8f82 Mon Sep 17 00:00:00 2001 From: takasehideki Date: Mon, 17 Oct 2022 19:42:23 +0900 Subject: [PATCH 12/14] remove unnecessory info (allocated memory address) from debug message --- src/mros2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mros2.cpp b/src/mros2.cpp index 0fbf1ff..b81b264 100644 --- a/src/mros2.cpp +++ b/src/mros2.cpp @@ -207,7 +207,7 @@ Subscriber Node::create_subscription(std::string topic_name, int qos, void(*fp)( /* Register callback to ensure that a subscriber is matched to the reader before receiving messages */ part_ptr->registerOnNewPublisherMatchedCallback(subMatch, &pubMatched); - MROS2_DEBUG("[MROS2LIB] create_subscription complete. data memory address=0x%x", data_p); + MROS2_DEBUG("[MROS2LIB] create_subscription complete."); return sub; } From 01a3cb135be68b2afc7d64aa9725dde163413f2f Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 18 Oct 2022 13:43:49 +0900 Subject: [PATCH 13/14] add mros2-posix as the supported target --- README.md | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f22a539..2261cc8 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,9 @@ This repository maintains the communication layer of mROS 2, that mainly offers ## Features - **Agent-less**: a node on mROS 2 autonomously discovers communication nodes on the host with the feature of [embeddedRTPS](https://github.com/mROS-base/embeddedRTPS). It means no agent/bridge is required for pub/sub communication from the embedded devices. + - mros2 currently uses [embeddedRTPS @ 1410a87](https://github.com/mROS-base/embeddedRTPS/tree/1410a8776660244249a84031ffa78c9bdaa45e19) as it is. - **Lightweight**: mROS 2 APIs are implemented by C++ to be operated on the embedded devices. All software stacks are also implemented only in C/C++. -- **Real-time**: mROS 2 employs the real-time kernel (e.g., [TOPPERS kernel](https://www.toppers.jp/en/project.html)) as the runtime platform in order to enhance the real-time capability. +- **Real-time**: mROS 2 employs the real-time kernel (e.g., [TOPPERS kernel](https://www.toppers.jp/en/project.html), [Mbed OS](https://os.mbed.com/mbed-os/)) as the runtime platform in order to enhance the real-time capability. ## Functionalities and limitations @@ -21,7 +22,8 @@ Here are functionalities that mROS 2 offers for you, and current limitations (a. - [Built-in-types](https://docs.ros.org/en/foxy/Concepts/About-ROS-Interfaces.html#field-types) except for `wstring` (UTF-16) - Please check [mros2-asp3-f767zi#exapmle-applications](https://github.com/mROS-base/mros2-asp3-f767zi#example-applications) for more details. - `array` types are not supported - - Custom message is not supported (but ongoing work) + - Some custom message types (e.g., Twist, Pose) + - We think variable-length types and types exceeding one packet cannot be handled, probably due to the limitation of lwIP. - Service, Actions, and Parameters are not supported - Please let us know if you want to use them as soon as possible. We can consider of raising the priority of these supports. @@ -31,14 +33,15 @@ Since this repository itself only maintains the communication layer of mROS 2, w Please see each repository to learn how to use it. -| name | kernel | board | -|:---|:---|:---| -| [mros2-asp3-f767zi](https://github.com/mROS-base/mros2-asp3-f767zi) | [TOPPERS/ASP3](https://www.toppers.jp/en/project.html) | [STM32 NUCLEO-F767ZI](https://www.st.com/en/evaluation-tools/nucleo-f767zi.html) | -| [mros2-mbed](https://github.com/mROS-base/mros2-mbed) | [Mbed OS 6](https://github.com/ARMmbed/mbed-os) | Mbed enabled boards having an Ethernet port (See [detail](https://github.com/mROS-base/mros2-mbed#supported-environment)) | +| name | kernel | board | support status | +|:---|:---|:---|:---| +| [mros2-asp3-f767zi](https://github.com/mROS-base/mros2-asp3-f767zi) | [TOPPERS/ASP3](https://www.toppers.jp/en/project.html) | [STM32 NUCLEO-F767ZI](https://www.st.com/en/evaluation-tools/nucleo-f767zi.html) | currently supported up to v0.3.2 (see [status](https://github.com/mROS-base/mros2-asp3-f767zi/issues/74)) | +| [mros2-mbed](https://github.com/mROS-base/mros2-mbed) | [Mbed OS 6](https://github.com/ARMmbed/mbed-os) | Mbed enabled boards having an Ethernet port (See [detail](https://github.com/mROS-base/mros2-mbed#supported-environment)) | well maintained and easy to try | +| [mros2-posix](https://github.com/mROS-base/mros2-posix) | POSIX (pthread) | any machine that runs Linux | partly maintained | Please let us know if you have a request for a support of board/kernel, or if you could implement this layer on another platform. ## License The source code of this repository itself is published under [Apache License 2.0](https://github.com/mROS-base/mros2/blob/main/LICENSE). -Please note that this repository contains [embeddedRTPS and its third party libraries](https://github.com/mROS-base/embeddedRTPS#third-party-libraries) as the submodule, and also check their Licenses. \ No newline at end of file +Please note that this repository contains [embeddedRTPS and its third party libraries](https://github.com/mROS-base/embeddedRTPS#third-party-libraries) as the submodule, and also check their Licenses. From 07e38bcedfb0917b16700c5526697a470fbd589d Mon Sep 17 00:00:00 2001 From: takasehideki Date: Tue, 18 Oct 2022 14:20:01 +0900 Subject: [PATCH 14/14] add gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba0430d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/ \ No newline at end of file