make_library.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 
18 import os
19 import shutil
20 import rospkg
21 import rosserial_client
23 
24 
25 def write_header(output_path, package, msg):
26  output_path = output_path + "/" + package
27  if not os.path.exists(output_path):
28  os.makedirs(output_path)
29  with open(output_path + "/" + msg.name + ".h", "w") as header:
30  msg.make_header(header)
31 
32 def make_message(rospack, package, message, dest):
33  path = rospack.get_path(package) + "/msg/" + message + ".msg"
34  with open(path) as f:
35  definition = f.readlines()
36  md5sum = roslib.message.get_message_class(package+'/'+message)._md5sum
37  write_header(dest, package, Message(message, package, definition, md5sum))
38 
39 def make_service(rospack, package, service, dest):
40  path = rospack.get_path(package) + "/srv/" + service + ".srv"
41  with open(path) as f:
42  definition = f.readlines()
43  md5req = roslib.message.get_service_class(package+'/'+service)._request_class._md5sum
44  md5res = roslib.message.get_service_class(package+'/'+service)._response_class._md5sum
45  write_header(dest, package, Service(service, package, definition, md5req, md5res ) )
46 
47 
48 ROS_TO_EMBEDDED_TYPES = {
49  'bool' : ('bool', 1, PrimitiveDataType, []),
50  'byte' : ('int8_t', 1, PrimitiveDataType, []),
51  'int8' : ('int8_t', 1, PrimitiveDataType, []),
52  'char' : ('uint8_t', 1, PrimitiveDataType, []),
53  'uint8' : ('uint8_t', 1, PrimitiveDataType, []),
54  'int16' : ('int16_t', 2, PrimitiveDataType, []),
55  'uint16' : ('uint16_t', 2, PrimitiveDataType, []),
56  'int32' : ('int32_t', 4, PrimitiveDataType, []),
57  'uint32' : ('uint32_t', 4, PrimitiveDataType, []),
58  'int64' : ('int64_t', 8, PrimitiveDataType, []),
59  'uint64' : ('uint64_t', 4, PrimitiveDataType, []),
60  'float32' : ('float', 4, PrimitiveDataType, []),
61  'float64' : ('double', 8, PrimitiveDataType, []),
62  'time' : ('ros::Time', 8, TimeDataType, ['ros/time']),
63  'duration': ('ros::Duration', 8, TimeDataType, ['ros/duration']),
64  'string' : ('char*', 0, StringDataType, []),
65  'Header' : ('std_msgs::Header', 0, MessageDataType, ['std_msgs/Header'])
66 }
67 
68 rospack = rospkg.RosPack()
69 rospack.list = lambda: []
70 rosserial_generate(rospack, "ros_lib", ROS_TO_EMBEDDED_TYPES)
71 
72 shutil.rmtree("ros_lib", True)
73 shutil.copytree(rospack.get_path("rosserial_embeddedlinux")+"/src/ros_lib", "ros_lib")
74 
75 rosserial_client_copy_files(rospack, "ros_lib/")
76 
77 make_message(rospack, "std_msgs", "Time", "ros_lib")
78 make_message(rospack, "std_msgs", "UInt8", "ros_lib")
79 make_service(rospack, "std_srvs", "Trigger", "ros_lib")
80 
81 MakeLibrary("rosserial_msgs", "ros_lib", rospack)
82 MakeLibrary("cob_hand_bridge", "ros_lib", rospack)
def make_message(rospack, package, message, dest)
Definition: make_library.py:32
def write_header(output_path, package, msg)
Definition: make_library.py:25
def make_service(rospack, package, service, dest)
Definition: make_library.py:39


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Tue Oct 20 2020 03:35:57