Skip to content

Commit d66f3b1

Browse files
authored
Merge pull request #33 from mROS-base/v0.4.0
bump v0.4.0 with newer embeddedRTPS
2 parents f24aeb7 + 07e38bc commit d66f3b1

File tree

7 files changed

+87
-41
lines changed

7 files changed

+87
-41
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__/

CMakeLists.txt

+26-24
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
11
# Copyright (c) 2021 smorita_emb
22
# SPDX-License-Identifier: Apache-2.0
33

4+
cmake_minimum_required(VERSION 3.16.3)
5+
6+
project(mros2)
7+
48
target_include_directories(mros2
59
BEFORE INTERFACE
6-
embeddedRTPS/thirdparty/Micro-CDR/include
7-
embeddedRTPS/include
8-
include
9-
mros2_msgs
10+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/include
11+
${PROJECT_SOURCE_DIR}/embeddedRTPS/include
12+
${PROJECT_SOURCE_DIR}/include
13+
${PROJECT_SOURCE_DIR}/mros2_msgs
1014
)
1115

1216
target_sources(mros2
1317
INTERFACE
14-
src/mros2.cpp
15-
embeddedRTPS/src/communication/UdpDriver.cpp
16-
embeddedRTPS/src/messages/MessageTypes.cpp
17-
embeddedRTPS/src/messages/MessageReceiver.cpp
18-
embeddedRTPS/src/discovery/TopicData.cpp
19-
embeddedRTPS/src/discovery/ParticipantProxyData.cpp
20-
embeddedRTPS/src/discovery/SEDPAgent.cpp
21-
embeddedRTPS/src/discovery/SPDPAgent.cpp
22-
embeddedRTPS/src/storages/HistoryCache.cpp
23-
embeddedRTPS/src/storages/SimpleHistoryCache.cpp
24-
embeddedRTPS/src/storages/PBufWrapper.cpp
25-
embeddedRTPS/src/ThreadPool.cpp
26-
embeddedRTPS/src/entities/Participant.cpp
27-
embeddedRTPS/src/entities/Domain.cpp
28-
embeddedRTPS/src/entities/StatelessReader.cpp
29-
embeddedRTPS/thirdparty/Micro-CDR/src/c/common.c
30-
embeddedRTPS/thirdparty/Micro-CDR/src/c/types/basic.c
31-
embeddedRTPS/thirdparty/Micro-CDR/src/c/types/string.c
32-
embeddedRTPS/thirdparty/Micro-CDR/src/c/types/sequence.c
33-
embeddedRTPS/thirdparty/Micro-CDR/src/c/types/array.c
18+
${PROJECT_SOURCE_DIR}/src/mros2.cpp
19+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/communication/UdpDriver.cpp
20+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/messages/MessageTypes.cpp
21+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/messages/MessageReceiver.cpp
22+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/TopicData.cpp
23+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/ParticipantProxyData.cpp
24+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/SEDPAgent.cpp
25+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/discovery/SPDPAgent.cpp
26+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/storages/PBufWrapper.cpp
27+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/ThreadPool.cpp
28+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/Participant.cpp
29+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/Domain.cpp
30+
${PROJECT_SOURCE_DIR}/embeddedRTPS/src/entities/StatelessReader.cpp
31+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/common.c
32+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/basic.c
33+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/string.c
34+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/sequence.c
35+
${PROJECT_SOURCE_DIR}/embeddedRTPS/thirdparty/Micro-CDR/src/c/types/array.c
3436
)

README.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ This repository maintains the communication layer of mROS 2, that mainly offers
1010
## Features
1111

1212
- **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.
13+
- mros2 currently uses [embeddedRTPS @ 1410a87](https://github.com/mROS-base/embeddedRTPS/tree/1410a8776660244249a84031ffa78c9bdaa45e19) as it is.
1314
- **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++.
14-
- **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.
15+
- **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.
1516

1617
## Functionalities and limitations
1718

@@ -21,7 +22,8 @@ Here are functionalities that mROS 2 offers for you, and current limitations (a.
2122
- [Built-in-types](https://docs.ros.org/en/foxy/Concepts/About-ROS-Interfaces.html#field-types) except for `wstring` (UTF-16)
2223
- Please check [mros2-asp3-f767zi#exapmle-applications](https://github.com/mROS-base/mros2-asp3-f767zi#example-applications) for more details.
2324
- `array` types are not supported
24-
- Custom message is not supported (but ongoing work)
25+
- Some custom message types (e.g., Twist, Pose)
26+
- We think variable-length types and types exceeding one packet cannot be handled, probably due to the limitation of lwIP.
2527
- Service, Actions, and Parameters are not supported
2628
- Please let us know if you want to use them as soon as possible. We can consider of raising the priority of these supports.
2729

@@ -31,14 +33,15 @@ Since this repository itself only maintains the communication layer of mROS 2, w
3133
Please see each repository to learn how to use it.
3234

3335

34-
| name | kernel | board |
35-
|:---|:---|:---|
36-
| [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) |
37-
| [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)) |
36+
| name | kernel | board | support status |
37+
|:---|:---|:---|:---|
38+
| [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)) |
39+
| [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 |
40+
| [mros2-posix](https://github.com/mROS-base/mros2-posix) | POSIX (pthread) | any machine that runs Linux | partly maintained |
3841

3942
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.
4043

4144
## License
4245

4346
The source code of this repository itself is published under [Apache License 2.0](https://github.com/mROS-base/mros2/blob/main/LICENSE).
44-
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.
47+
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.

embeddedRTPS

Submodule embeddedRTPS updated 62 files

include/mros2/freertos_conversion.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Conversion of FreeRTOS's definitions/types/functions in embeddedRTPS
3+
*
4+
* Copyright (c) 2022 mROS-base
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef RTPS_CONVERSION_H
20+
#define RTPS_CONVERSION_H
21+
22+
#ifdef __cplusplus
23+
extern "C" {
24+
#endif
25+
#include <stdint.h>
26+
typedef uint32_t TickType_t;
27+
#define configTICK_RATE_HZ ((TickType_t)1000)
28+
29+
#ifndef pdMS_TO_TICKS
30+
#define pdMS_TO_TICKS(xTimeInMs) ((TickType_t)(((TickType_t)(xTimeInMs) * (TickType_t)configTICK_RATE_HZ) / (TickType_t)1000))
31+
#endif
32+
33+
#define xTaskGetTickCount osKernelGetTickCount
34+
#define vTaskDelay osDelay
35+
36+
void sys_msleep(unsigned int ms);
37+
#ifdef __cplusplus
38+
}
39+
#endif
40+
41+
#endif /* RTPS_CONVERSION_H */

include/mros2_user_config.h renamed to include/mros2_config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
extern "C" {
66
#endif
77

8-
extern int mros2_get_submsg_count(void);
8+
#define SUB_MSG_COUNT 10
99

1010
#ifdef __cplusplus
1111
}

src/mros2.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include "mros2.h"
2-
#include "mros2_user_config.h"
32

43
#include <rtps/rtps.h>
54

65
#ifdef __MBED__
76
#include "mbed.h"
87
#else /* __MBED__ */
8+
#include "mros2_config.h"
99
#include "cmsis_os.h"
1010
#endif /* __MBED__ */
1111

@@ -61,13 +61,13 @@ void init(int argc, char * argv[])
6161
buf[3] = 0;
6262

6363
#ifdef __MBED__
64-
mros2_init_thread = new Thread(osPriorityAboveNormal, 2000, nullptr, "mROS2Thread");
64+
mros2_init_thread = new Thread(osPriorityAboveNormal, 5000, nullptr, "mROS2Thread");
6565
mros2_init_thread->start(callback(mros2_init, (void *)NULL));
6666
#else /* __MBED__ */
6767
osThreadAttr_t attributes;
6868

6969
attributes.name = "mROS2Thread",
70-
attributes.stack_size = 1000,
70+
attributes.stack_size = 5000,
7171
attributes.priority = (osPriority_t)24,
7272

7373
osThreadNew(mros2_init, NULL, (const osThreadAttr_t*)&attributes);
@@ -86,13 +86,11 @@ void mros2_init(void *args)
8686
MROS2_DEBUG("[MROS2LIB] Initilizing lwIP complete");
8787
#endif /* __MBED__ */
8888

89-
int sub_msg_count;
9089
static rtps::Domain domain;
9190
domain_ptr = &domain;
9291

9392
#ifndef __MBED__
94-
sub_msg_count = mros2_get_submsg_count();
95-
subscriber_msg_queue_id = osMessageQueueNew(sub_msg_count, SUB_MSG_SIZE, NULL);
93+
subscriber_msg_queue_id = osMessageQueueNew(SUB_MSG_COUNT, SUB_MSG_SIZE, NULL);
9694
if (subscriber_msg_queue_id == NULL) {
9795
MROS2_ERROR("[MROS2LIB] ERROR: mROS2 init failed");
9896
return;
@@ -209,15 +207,16 @@ Subscriber Node::create_subscription(std::string topic_name, int qos, void(*fp)(
209207
/* Register callback to ensure that a subscriber is matched to the reader before receiving messages */
210208
part_ptr->registerOnNewPublisherMatchedCallback(subMatch, &pubMatched);
211209

212-
MROS2_DEBUG("[MROS2LIB] create_subscription complete. data memory address=0x%x", data_p);
210+
MROS2_DEBUG("[MROS2LIB] create_subscription complete.");
213211
return sub;
214212
}
215213

216214
template <class T>
217215
void Subscriber::callback_handler(void *callee, const rtps::ReaderCacheChange &cacheChange)
218216
{
219217
T msg;
220-
msg.copyFromBuf(&cacheChange.data[4]);
218+
const uint8_t *cacheData = cacheChange.getData();
219+
msg.copyFromBuf(&cacheData[4]);
221220

222221
SubscribeDataType *sub = (SubscribeDataType *)callee;
223222
void (*fp)(intptr_t) = sub->cb_fp;

0 commit comments

Comments
 (0)