00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 THIS_PACKAGE = "rosserial_arduino"
00037
00038 __usage__ = """
00039 make_libraries.py generates the Arduino rosserial library files. It
00040 requires the location of your Arduino sketchbook/libraries folder.
00041
00042 rosrun rosserial_arduino make_libraries.py <output_path>
00043 """
00044
00045 import rospkg
00046 import rosserial_client
00047 from rosserial_client.make_library import *
00048
00049
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' : ('float', 4, AVR_Float64DataType, []),
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
00073 if (len(sys.argv) < 2):
00074 print __usage__
00075 exit()
00076
00077
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
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
00090
00091 rosserial_generate(rospack, path+"/ros_lib", ROS_TO_EMBEDDED_TYPES)
00092