diff --git a/msg/templates/urtps/msg.idl.template b/msg/templates/urtps/msg.idl.template
index 57536f362921ac67062af3b982a5737cf8294168..df3833c33679c2d7152f65f18e5653b131487bf8 100644
--- a/msg/templates/urtps/msg.idl.template
+++ b/msg/templates/urtps/msg.idl.template
@@ -41,6 +41,7 @@ import gencpp
 from px_generate_uorb_topic_helper import *  # this is in Tools/
 
 builtin_types = set()
+array_types = set()
 }@
 @#################################################
 @# Searching for serialize function per each field
@@ -70,11 +71,9 @@ def get_idl_type_name(field_type):
 def add_msg_field(field):
     if (not field.is_header):
         if field.is_array:
-            print("    " + str(get_idl_type_name(field.base_type)) +
-                  ' ' + field.name + '[' + str(field.array_len) + '];')
+            print('    {0}__{1}_array_{2} {3}_;'.format(spec.short_name, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
         else:
-            print("    " + str(get_idl_type_name(field.type)) +
-                  ' ' + field.name + ';')
+            print('    {0} {1}_;'.format(str(get_idl_type_name(field.type)), field.name))
 
 
 def add_msg_fields():
@@ -82,31 +81,41 @@ def add_msg_fields():
         add_msg_field(field)
 
 
+def add_array_typedefs():
+    for field in spec.parsed_fields():
+        if not field.is_header and field.is_array:
+            base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
+            array_type = 'typedef {0} {1}__{2}_array_{3}[{4}];'.format(base_type, spec.short_name, get_idl_type_name(field.base_type).replace(" ", "_"), field.array_len, field.array_len)
+            if type not in array_types:
+                array_types.add(array_type)
+    for atype in array_types:
+        print(atype)
+
+
 def add_msg_constants():
     sorted_constants = sorted(spec.constants,
-                           key=sizeof_field_type, reverse=True)
+                       key=sizeof_field_type, reverse=True)
     for constant in sorted_constants:
-        constant_value = '%d' % constant.val
-        print("const " + get_idl_type_name(constant.type) + " " + constant.name + " = " + constant_value + ";")
+        print('const {0} {1}__{2} = {3};'.format(get_idl_type_name(constant.type), spec.short_name, constant.name, constant.val))
 
-}@
+}
 #ifndef __@(spec.short_name)__idl__
 #define __@(spec.short_name)__idl__
 
 @#############################
 @# Include dependency messages
 @#############################
-@[for line in get_include_directives(spec)]@
+@[for line in get_include_directives(spec)]
 @(line)
-@[end for]@
-
+@[end for]
 @# Constants
 @add_msg_constants()
-
-@[for type in builtin_types]@
+@# Built-in types
+@[for type in builtin_types]
 typedef @(type + '_') @(type);
-@[end for]@
-
+@[end for]
+@# Array types
+@add_array_typedefs()
 struct @(spec.short_name)_
 {
 @add_msg_fields()