You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This page aims to explain how to handle messages and types memory in micro-ROS.
7
7
8
-
First of all, since the micro-ROS user is in a embedded C99 environment, it is important to be aware of what messages and ROS 2 types are being used in order to handle memory correctly.
8
+
First of all, since the micro-ROS user is in an embedded C99 environment, it is important to be aware of what messages and ROS 2 types are being used in order to handle memory correctly.
9
9
10
-
By watching the `.msg` or `.srv` of the types used in a micro-ROS application, you can determine if your type's members are a:
10
+
By watching the `.msg` or `.srv` of the types used in a micro-ROS application, you can determine the type of each member. Currently, the following types are supported:
11
11
- Basic type
12
12
- Array type
13
13
- Sequence type
@@ -31,7 +31,7 @@ In this example:
31
31
- the member `header` is an **compound type member** because it refers to complex type described in the same or other ROS 2 package.
32
32
- the member `name` is an **string type member** and should be understood as a `char[]` (sequence type member).
33
33
34
-
When dealing with the **micro-ROS typesupport** the application coder need to take into account how this message is going to be handled in the C99 API of micro-ROS. In general, the micro-ROS typesupport will create a C99 representation of this type with this struct:
34
+
When dealing with the **micro-ROS typesupport** the developer needs to take into account how this message is going to be handled in the C99 API of micro-ROS. In general, the micro-ROS typesupport will create a C99 struct representation of the message:
35
35
36
36
```c
37
37
typedefstruct mypackage__msg__MyType
@@ -94,9 +94,9 @@ for(int32_t i = 0; i < 3; i++){
94
94
95
95
## Compound types in micro-ROS
96
96
97
-
When dealing with a type that uses a compound type, the user should recursively inspect the types in order to determine how to handle the each internal member.
97
+
When dealing with a compound type, the user should recursively inspect the types in order to determine how to handle each internal member.
98
98
99
-
For example in the `MyType.msg` example, when we inspect the `header` member, it looks like:
99
+
For example in the `MyType.msg` example, the `header` member has the following structure:
So for example in order to init the `header` member of `MyType.msg`, an user should do:
119
+
To initialize the `header` member of `MyType.msg`:
120
120
121
121
```c
122
122
mypackage__msg__MyType mymsg;
@@ -137,7 +137,7 @@ mymsg.stamp.nanosec = 20;
137
137
138
138
## Sequences of compound types
139
139
140
-
User should take into account that **sequence type member** of **compound type member** are also valid ROS 2 type. For example, let's modify the previous example:
140
+
Users should take into account that **sequence type member** of **compound type member** are also valid ROS 2 type. For example, let's modify the previous example:
Notice that `multiheaders` is a **sequence type member**, so it should be handled properly, but also it is a **compound type member**so it should be handled recursively. For example:
164
+
Notice that `multiheaders` is a **sequence type member**, so it should be handled properly, but also it is a **compound type member**which needs to be handled recursively, initializing its own members. For example:
165
165
166
166
```c
167
167
mypackage__msg__MyComplexType mymsg;
@@ -191,4 +191,3 @@ for(int32_t i = 0; i < 3; i++){
0 commit comments