make_library.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
00004 #
00005 # Licensed under the Apache License, Version 2.0 (the "License");
00006 # you may not use this file except in compliance with the License.
00007 # You may obtain a copy of the License at
00008 #
00009 #   http://www.apache.org/licenses/LICENSE-2.0
00010 #
00011 # Unless required by applicable law or agreed to in writing, software
00012 # distributed under the License is distributed on an "AS IS" BASIS,
00013 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014 # See the License for the specific language governing permissions and
00015 # limitations under the License.
00016 
00017 
00018 import os
00019 import shutil
00020 import rospkg
00021 import rosserial_client
00022 from rosserial_client.make_library import *
00023 
00024 
00025 def write_header(output_path, package, msg):
00026     output_path = output_path + "/" + package
00027     if not os.path.exists(output_path):
00028         os.makedirs(output_path)
00029     with open(output_path + "/" + msg.name + ".h", "w") as header:
00030         msg.make_header(header)
00031 
00032 def make_message(rospack, package, message, dest):
00033     path = rospack.get_path(package) + "/msg/" + message + ".msg"
00034     with open(path) as f:
00035         definition = f.readlines()
00036     md5sum = roslib.message.get_message_class(package+'/'+message)._md5sum
00037     write_header(dest, package, Message(message, package, definition, md5sum))
00038 
00039 def make_service(rospack, package, service, dest):
00040     path = rospack.get_path(package) + "/srv/" + service + ".srv"
00041     with open(path) as f:
00042         definition = f.readlines()
00043     md5req = roslib.message.get_service_class(package+'/'+service)._request_class._md5sum
00044     md5res = roslib.message.get_service_class(package+'/'+service)._response_class._md5sum
00045     write_header(dest, package, Service(service, package, definition, md5req, md5res ) )
00046 
00047 
00048 ROS_TO_EMBEDDED_TYPES = {
00049     'bool'    :   ('bool',              1, PrimitiveDataType, []),
00050     'byte'    :   ('int8_t',            1, PrimitiveDataType, []),
00051     'int8'    :   ('int8_t',            1, PrimitiveDataType, []),
00052     'char'    :   ('uint8_t',           1, PrimitiveDataType, []),
00053     'uint8'   :   ('uint8_t',           1, PrimitiveDataType, []),
00054     'int16'   :   ('int16_t',           2, PrimitiveDataType, []),
00055     'uint16'  :   ('uint16_t',          2, PrimitiveDataType, []),
00056     'int32'   :   ('int32_t',           4, PrimitiveDataType, []),
00057     'uint32'  :   ('uint32_t',          4, PrimitiveDataType, []),
00058     'int64'   :   ('int64_t',           8, PrimitiveDataType, []),
00059     'uint64'  :   ('uint64_t',          4, PrimitiveDataType, []),
00060     'float32' :   ('float',             4, PrimitiveDataType, []),
00061     'float64' :   ('double',            8, PrimitiveDataType, []),
00062     'time'    :   ('ros::Time',         8, TimeDataType, ['ros/time']),
00063     'duration':   ('ros::Duration',     8, TimeDataType, ['ros/duration']),
00064     'string'  :   ('char*',             0, StringDataType, []),
00065     'Header'  :   ('std_msgs::Header',  0, MessageDataType, ['std_msgs/Header'])
00066 }
00067 
00068 rospack = rospkg.RosPack()
00069 rospack.list = lambda: []
00070 rosserial_generate(rospack, "ros_lib", ROS_TO_EMBEDDED_TYPES)
00071 
00072 shutil.rmtree("ros_lib", True)
00073 shutil.copytree(rospack.get_path("rosserial_embeddedlinux")+"/src/ros_lib", "ros_lib")
00074 
00075 rosserial_client_copy_files(rospack, "ros_lib/")
00076 
00077 make_message(rospack, "std_msgs", "Time", "ros_lib")
00078 make_message(rospack, "std_msgs", "UInt8", "ros_lib")
00079 make_service(rospack, "std_srvs", "Trigger", "ros_lib")
00080 
00081 MakeLibrary("rosserial_msgs", "ros_lib", rospack)
00082 MakeLibrary("cob_hand_bridge", "ros_lib", rospack)


cob_hand_bridge
Author(s): Mathias Lüdtke
autogenerated on Thu Jun 6 2019 20:43:57