make_libraries.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 #####################################################################
4 # Software License Agreement (BSD License)
5 #
6 # Copyright (c) 2013, Willow Garage, Inc.
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 #
13 # * Redistributions of source code must retain the above copyright
14 # notice, this list of conditions and the following disclaimer.
15 # * Redistributions in binary form must reproduce the above
16 # copyright notice, this list of conditions and the following
17 # disclaimer in the documentation and/or other materials provided
18 # with the distribution.
19 # * Neither the name of Willow Garage, Inc. nor the names of its
20 # contributors may be used to endorse or promote products derived
21 # from this software without specific prior written permission.
22 #
23 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 # POSSIBILITY OF SUCH DAMAGE.
35 
36 THIS_PACKAGE = "rosserial_vex_v5"
37 
38 __usage__ = """
39 make_libraries.py generates the VEX Robot Brain rosserial library files. It requires the location of the include directory of a PROS kernel.
40 
41 rosrun rosserial_vex_v5 make_libraries.py <pros_include_dir>
42 """
43 
44 import rospkg
45 import rosserial_client
47 
48 # for copying files
49 import shutil
50 
51 ROS_TO_EMBEDDED_TYPES = {
52  'bool' : ('bool', 1, PrimitiveDataType, []),
53  'byte' : ('int8_t', 1, PrimitiveDataType, []),
54  'int8' : ('int8_t', 1, PrimitiveDataType, []),
55  'char' : ('uint8_t', 1, PrimitiveDataType, []),
56  'uint8' : ('uint8_t', 1, PrimitiveDataType, []),
57  'int16' : ('int16_t', 2, PrimitiveDataType, []),
58  'uint16' : ('uint16_t', 2, PrimitiveDataType, []),
59  'int32' : ('int32_t', 4, PrimitiveDataType, []),
60  'uint32' : ('uint32_t', 4, PrimitiveDataType, []),
61  'int64' : ('int64_t', 8, PrimitiveDataType, []),
62  'uint64' : ('uint64_t', 8, PrimitiveDataType, []),
63  'float32' : ('float', 4, PrimitiveDataType, []),
64  'float64' : ('float', 4, AVR_Float64DataType, []),
65  'time' : ('ros::Time', 8, TimeDataType, ['ros/time']),
66  'duration': ('ros::Duration', 8, TimeDataType, ['ros/duration']),
67  'string' : ('char*', 0, StringDataType, []),
68  'Header' : ('std_msgs::Header', 0, MessageDataType, ['std_msgs/Header'])
69 }
70 
71 # need correct inputs
72 if (len(sys.argv) < 2):
73  print __usage__
74  exit()
75 
76 # get output path
77 path = sys.argv[1]
78 if path[-1] == "/":
79  path = path[0:-1]
80 print "\nExporting to %s" % path
81 
82 rospack = rospkg.RosPack()
83 
84 # copy ros_lib stuff in
85 rosserial_vex_v5_dir = rospack.get_path(THIS_PACKAGE)
86 shutil.copytree(rosserial_vex_v5_dir+"/src/ros_lib", path+"/ros_lib")
87 rosserial_client_copy_files(rospack, path+"/ros_lib/")
88 
89 # generate messages
90 rosserial_generate(rospack, path+"/ros_lib", ROS_TO_EMBEDDED_TYPES)
91 


rosserial_vex_v5
Author(s): Cannon
autogenerated on Fri Jun 7 2019 22:03:08