Skip to content

Commit

Permalink
rosserial client variable typedefs (#254)
Browse files Browse the repository at this point in the history
* Add typedefs to generated messages

This brings rosserial message headers in line with
roscpp headers that provide a typedef for the message
variable member.

* Removing unused imports and variables.
  • Loading branch information
Mike O'Driscoll authored and mikepurvis committed Nov 2, 2016
1 parent 72b5637 commit 6460202
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions rosserial_client/src/rosserial_client/make_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@
import roslib
import roslib.srvs
import roslib.message
import rospkg
import rospy
import traceback

import os, sys, subprocess, re
import os, sys, re

# for copying files
import shutil
Expand Down Expand Up @@ -84,7 +82,7 @@ def make_initializer(self, f, trailer):
f.write(' %s(0)%s\n' % (self.name, trailer))

def make_declaration(self, f):
f.write(' %s %s;\n' % (self.type, self.name) )
f.write(' typedef %s _%s_type;\n _%s_type %s;\n' % (self.type, self.name, self.name, self.name) )

def serialize(self, f):
cn = self.name.replace("[","").replace("]","").split(".")[-1]
Expand Down Expand Up @@ -139,7 +137,7 @@ def make_initializer(self, f, trailer):
f.write(' %s(0)%s\n' % (self.name, trailer))

def make_declaration(self, f):
f.write(' float %s;\n' % self.name )
f.write(' typedef float _%s_type;\n _%s_type %s;\n' % (self.name, self.name, self.name) )

def serialize(self, f):
f.write(' offset += serializeAvrFloat64(outbuffer + offset, this->%s);\n' % self.name)
Expand All @@ -155,7 +153,7 @@ def make_initializer(self, f, trailer):
f.write(' %s("")%s\n' % (self.name, trailer))

def make_declaration(self, f):
f.write(' const char* %s;\n' % self.name)
f.write(' typedef const char* _%s_type;\n _%s_type %s;\n' % (self.name, self.name, self.name) )

def serialize(self, f):
cn = self.name.replace("[","").replace("]","")
Expand Down Expand Up @@ -190,7 +188,7 @@ def make_initializer(self, f, trailer):
f.write(' %s()%s\n' % (self.name, trailer))

def make_declaration(self, f):
f.write(' %s %s;\n' % (self.type, self.name))
f.write(' typedef %s _%s_type;\n _%s_type %s;\n' % (self.type, self.name, self.name, self.name) )

def serialize(self, f):
self.sec.serialize(f)
Expand All @@ -217,11 +215,11 @@ def make_initializer(self, f, trailer):
f.write(' %s()%s\n' % (self.name, trailer))

def make_declaration(self, f):
c = self.cls("*"+self.name, self.type, self.bytes)
if self.size == None:
f.write(' uint32_t %s_length;\n' % self.name)
f.write(' %s st_%s;\n' % (self.type, self.name)) # static instance for copy
f.write(' %s * %s;\n' % (self.type, self.name))
f.write(' typedef %s _%s_type;\n' % (self.type, self.name))
f.write(' _%s_type st_%s;\n' % (self.name, self.name)) # static instance for copy
f.write(' _%s_type * %s;\n' % (self.name, self.name))
else:
f.write(' %s %s[%d];\n' % (self.type, self.name, self.size))

Expand Down Expand Up @@ -511,7 +509,6 @@ def MakeLibrary(package, output_path, rospack):
messages.append( Message(f[0:-4], package, definition, md5sum) )

# find the services in this package
services = list()
if (os.path.exists(pkg_dir+"/srv/")):
if messages == list():
print('Exporting %s\n'%package)
Expand Down

0 comments on commit 6460202

Please sign in to comment.