generate_client_ros_lib.py
Go to the documentation of this file.
1 __usage__ = """
2 make_libraries generates the rosserial library files. It
3 is passed the output folder. This version does not copy a ros.h,
4 as that is provided by the test harnesses. For use only by the
5 rosserial_test CMake setup.
6 """
7 
8 import rospkg
10 from shutil import copytree
11 from os import path, sep, walk
12 import re
13 
14 ROS_TO_EMBEDDED_TYPES = {
15  'bool' : ('bool', 1, PrimitiveDataType, []),
16  'byte' : ('int8_t', 1, PrimitiveDataType, []),
17  'int8' : ('int8_t', 1, PrimitiveDataType, []),
18  'char' : ('uint8_t', 1, PrimitiveDataType, []),
19  'uint8' : ('uint8_t', 1, PrimitiveDataType, []),
20  'int16' : ('int16_t', 2, PrimitiveDataType, []),
21  'uint16' : ('uint16_t', 2, PrimitiveDataType, []),
22  'int32' : ('int32_t', 4, PrimitiveDataType, []),
23  'uint32' : ('uint32_t', 4, PrimitiveDataType, []),
24  'int64' : ('int64_t', 8, PrimitiveDataType, []),
25  'uint64' : ('uint64_t', 4, PrimitiveDataType, []),
26  'float32' : ('float', 4, PrimitiveDataType, []),
27  'float64' : ('double', 4, PrimitiveDataType, []),
28  'time' : ('ros::Time', 8, TimeDataType, ['ros/time']),
29  'duration': ('ros::Duration', 8, TimeDataType, ['ros/duration']),
30  'string' : ('char*', 0, StringDataType, []),
31  'Header' : ('std_msgs::Header', 0, MessageDataType, ['std_msgs/Header'])
32 }
33 
34 # need correct inputs
35 if (len(sys.argv) < 2):
36  print(__usage__)
37  exit()
38 
39 # output path
40 path = path.join(sys.argv[1], 'rosserial')
41 print("\nExporting to %s" % path)
42 
43 rospack = rospkg.RosPack()
44 rosserial_client_copy_files(rospack, path + sep)
45 rosserial_generate(rospack, path, ROS_TO_EMBEDDED_TYPES)
46 
47 # Rewrite includes to find headers in a subdirectory. This is important in the context of
48 # test nodes as we must distinguish the rosserial client headers from roscpp headers of
49 # the same name.
50 for dname, dirs, files in walk(path):
51  for fname in files:
52  fpath = os.path.join(dname, fname)
53  with open(fpath) as f:
54  s = f.read()
55  with open(fpath, "w") as f:
56  f.write(re.sub('^#include "([^"]+)"',
57  '#include "rosserial/\\1"',
58  s, flags=re.MULTILINE))
59 
60 
rosserial_client::make_library


rosserial_test
Author(s):
autogenerated on Wed Mar 2 2022 00:58:17