Skip to content

Commit 7263863

Browse files
pablogs9Acuadros95
andauthored
Apply suggestions from code review
Co-authored-by: Antonio Cuadros <49162117+Acuadros95@users.noreply.github.com>
1 parent 58aa5c2 commit 7263863

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

  • _docs/tutorials/advanced/handling_type_memory

_docs/tutorials/advanced/handling_type_memory/index.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ permalink: /docs/tutorials/advanced/handling_type_memory/
55

66
This page aims to explain how to handle messages and types memory in micro-ROS.
77

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.
99

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:
1111
- Basic type
1212
- Array type
1313
- Sequence type
@@ -31,7 +31,7 @@ In this example:
3131
- the member `header` is an **compound type member** because it refers to complex type described in the same or other ROS 2 package.
3232
- the member `name` is an **string type member** and should be understood as a `char[]` (sequence type member).
3333

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:
3535

3636
```c
3737
typedef struct mypackage__msg__MyType
@@ -94,9 +94,9 @@ for(int32_t i = 0; i < 3; i++){
9494

9595
## Compound types in micro-ROS
9696

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.
9898

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:
100100

101101
```c
102102
typedef struct std_msgs__msg__Header
@@ -116,7 +116,7 @@ typedef struct builtin_interfaces__msg__Time
116116
} builtin_interfaces__msg__Time;
117117
```
118118

119-
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`:
120120

121121
```c
122122
mypackage__msg__MyType mymsg;
@@ -137,7 +137,7 @@ mymsg.stamp.nanosec = 20;
137137
138138
## Sequences of compound types
139139
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:
141141
142142
```
143143
# MyComplexType.msg
@@ -161,7 +161,7 @@ typedef struct mypackage__msg__MyComplexType
161161
} mypackage__msg__MyComplexType;
162162
```
163163

164-
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:
165165

166166
```c
167167
mypackage__msg__MyComplexType mymsg;
@@ -191,4 +191,3 @@ for(int32_t i = 0; i < 3; i++){
191191
mymsg.multiheaders.size++;
192192
}
193193
```
194-

0 commit comments

Comments
 (0)