make_libraries.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 #####################################################################
00004 # Software License Agreement (BSD License)
00005 #
00006 # Copyright (c) 2013, Willow Garage, Inc.
00007 # All rights reserved.
00008 #
00009 # Redistribution and use in source and binary forms, with or without
00010 # modification, are permitted provided that the following conditions
00011 # are met:
00012 #
00013 #  * Redistributions of source code must retain the above copyright
00014 #    notice, this list of conditions and the following disclaimer.
00015 #  * Redistributions in binary form must reproduce the above
00016 #    copyright notice, this list of conditions and the following
00017 #    disclaimer in the documentation and/or other materials provided
00018 #    with the distribution.
00019 #  * Neither the name of Willow Garage, Inc. nor the names of its
00020 #    contributors may be used to endorse or promote products derived
00021 #    from this software without specific prior written permission.
00022 #
00023 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00024 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00025 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00026 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00027 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00028 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00029 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00030 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00031 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00032 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00033 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00034 # POSSIBILITY OF SUCH DAMAGE.
00035 
00036 THIS_PACKAGE = "rosserial_embeddedlinux"
00037 
00038 __usage__ = """
00039 make_libraries.py generates the rosserial library files.  It
00040 requires the location of your project folder.
00041 
00042 rosrun rosserial_embeddedlinux make_libraries.py <output_path>
00043 """
00044 
00045 import rospkg
00046 import rosserial_client
00047 from rosserial_client.make_library import *
00048 
00049 # for copying files
00050 import shutil
00051 
00052 ROS_TO_EMBEDDED_TYPES = {
00053     'bool'    :   ('bool',              1, PrimitiveDataType, []),
00054     'byte'    :   ('int8_t',            1, PrimitiveDataType, []),
00055     'int8'    :   ('int8_t',            1, PrimitiveDataType, []),
00056     'char'    :   ('uint8_t',           1, PrimitiveDataType, []),
00057     'uint8'   :   ('uint8_t',           1, PrimitiveDataType, []),
00058     'int16'   :   ('int16_t',           2, PrimitiveDataType, []),
00059     'uint16'  :   ('uint16_t',          2, PrimitiveDataType, []),
00060     'int32'   :   ('int32_t',           4, PrimitiveDataType, []),
00061     'uint32'  :   ('uint32_t',          4, PrimitiveDataType, []),
00062     'int64'   :   ('int64_t',           8, PrimitiveDataType, []),
00063     'uint64'  :   ('uint64_t',          4, PrimitiveDataType, []),
00064     'float32' :   ('float',             4, PrimitiveDataType, []),
00065     'float64' :   ('double',            8, PrimitiveDataType, []),
00066     'time'    :   ('ros::Time',         8, TimeDataType, ['ros/time']),
00067     'duration':   ('ros::Duration',     8, TimeDataType, ['ros/duration']),
00068     'string'  :   ('char*',             0, StringDataType, []),
00069     'Header'  :   ('std_msgs::Header',  0, MessageDataType, ['std_msgs/Header'])
00070 }
00071 
00072 # need correct inputs
00073 if (len(sys.argv) < 2):
00074     print __usage__
00075     exit()
00076 
00077 # get output path
00078 path = sys.argv[1]
00079 if path[-1] == "/":
00080     path = path[0:-1]
00081 print "\nExporting to %s" % path
00082 
00083 rospack = rospkg.RosPack()
00084 
00085 # copy ros_lib stuff in
00086 rosserial_arduino_dir = rospack.get_path(THIS_PACKAGE)
00087 shutil.copytree(rosserial_arduino_dir+"/src/ros_lib", path+"/ros_lib")
00088 rosserial_client_copy_files(rospack, path+"/ros_lib/")
00089 shutil.copytree(rosserial_arduino_dir+"/src/examples", path+"/examples")
00090 
00091 # generate messages
00092 rosserial_generate(rospack, path+"/ros_lib", ROS_TO_EMBEDDED_TYPES)
00093 


rosserial_embeddedlinux
Author(s): Paul Bouchier
autogenerated on Thu Jun 6 2019 19:56:29