├── CMakeLists.txt
├── README.md
├── connection
├── CMakeLists.txt
├── package.xml
└── scripts
│ ├── .idea
│ ├── misc.xml
│ ├── modules.xml
│ ├── scripts.iml
│ └── workspace.xml
│ ├── husky_sender.py
│ ├── husky_sender_new.py
│ ├── server.py
│ └── vo_sender.py
├── demo_launch
├── CMakeLists.txt
├── launch
│ └── sbox_demo_launch.launch
└── package.xml
├── husky_ws
├── husky_back.tar.gz
├── husky_change_file
│ ├── amcl_demo.launch
│ └── demodisplay_husky.urdf.xacro
├── maps
│ ├── cartographer_demo
│ │ ├── map.pgm
│ │ └── map.yaml
│ ├── demo_map
│ │ ├── map.pgm
│ │ └── map.yaml
│ ├── map.pgm
│ └── map.yaml
├── pose
│ ├── cartographer_demo
│ │ └── pose.txt
│ ├── demo_pose
│ │ ├── husky_demo_get_pose.py
│ │ └── pose.txt
│ ├── husky_demo_get_pose.py
│ └── pose.txt
└── test
│ ├── map.pgm
│ ├── map.yaml
│ └── pose.txt
├── pose_tf
├── CMakeLists.txt
├── package.xml
└── scripts
│ ├── manual-wp-2505.txt
│ ├── pose_loader.py
│ ├── talker.py
│ ├── waypoints-old.txt
│ └── waypoints.txt
├── vis_marker
├── CMakeLists.txt
├── package.xml
├── script
│ └── show_err_msg.py
└── src
│ ├── err_mark_show.cpp
│ ├── fake_path_show.cpp
│ ├── husky_err_calc.cpp
│ ├── husky_mark_show.cpp
│ ├── record_fake_points.cpp
│ └── vo_mark_show.cpp
└── vrpn2gmapping
├── CMakeLists.txt
├── package.xml
└── src
├── readAndPub.cpp
└── record.cpp
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | /opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 2D Autonomous Navigation with SensorBox (Velodyne + Husky Navigation Stack)
2 |
3 | I know that with such an amazing set of sensors, as is SensorBox, performing 2D navigation with the traditional Husky navigation stack is definetly not mind blowing. But as we had problems in figuring out the initial best strategy to achieve a robust 2D navigation with SensorBox, I want to write down my learnings on this post in order to help others who are facing my same difficulties.
4 |
5 | # SensorBox
6 |
7 | SensorBox is a set of sensors binded togheter in Shanghai Jiao Tong University and BeiDou Research Institute that aims at performing indoor autonomous navigation by fusing the information retrieved by each sensor (sensor fusion).
8 | SesorBox is composed of:
9 | - 1 embedded computer (Ubuntu 16.04 ROS Kinetic)
10 | - 1 Velodyne 3D LiDAR
11 | - 2 cameras
12 | - 1 IMU
13 |
14 | In this post we will focus on the traditional 2D navigation and we will hack Velodyne in order to make it working as it was a traditional 2D laser scanner (e.g RPLidar A3, Hokuyo etc).
15 |
16 | [](https://www.youtube.com/watch?v=JbJeOqDqstU)
17 |
18 | # STEPS
19 | Assuming we have ROS up and running, first we need to install all the Husky navigation stack on our embedded computer. While installing the ROS packages is quite straightforward
20 |
21 | ``` sudo apt-get install ros-kinetic-husky-navigation ros-kinetic-husky-bringup ros-kinetic-husky-control ros-kinetic-husky-viz ```
22 |
23 | we need to install also the husky-core service as [in this post in the wiki ROS](http://wiki.ros.org/husky_bringup/Tutorials/Install%20Husky%20Software%20%28Advanced%29) and the catch is that obviously you don't need to install all the Husky Ubuntu image from scratch but, as in the quoted tutorial, by creating and configuring properly the robot-wide setup file the husky-core service will work as a charm.
24 |
25 | Now the trick is to transform the 3D Lidar Velodyne in a normal 2D laser scanner - I know a big waste of data... but it works!! So as in [this post](https://github.com/MengGuo/Jackal_Velodyne_Duke/tree/master/navigation) we install ``` pointcloud_to_laserscan ``` package from this [repo](https://github.com/ros-perception/pointcloud_to_laserscan) and same as in Jackal_Velodyne_Duke github post we edit the launch file "sample_node.launch"
26 |
27 | ```
28 |
29 |
30 |
31 |
32 |
33 |
34 | transform_tolerance: 0.01
35 | min_height: 0.25
36 | max_height: 0.75
37 |
38 | angle_min: -3.1415
39 | angle_max: 3.1415
40 | angle_increment: 0.01
41 | scan_time: 0.1
42 | range_min: 0.9
43 | range_max: 130
44 | use_inf: true
45 | concurrency_level: 0
46 |
47 |
48 |
49 |
50 |
51 | ```
52 |
53 | while obviously adjusting the ROS topics (for me the topic /scan works perfectly on Rviz).
54 |
55 | Finally we adjust the transformation from Velodyne to BaseLink by adding a static transformation to our "sample_node.launch" file
56 |
57 | ``` ```
58 |
59 | and we are good to go!
60 |
61 | # RUN THE CODE
62 |
63 | When you start the robot make sure:
64 | - the ethernet connection is established with Velodyne (No Internet connection)
65 | - plug in the USB HUB in order to connect SensorBox to Husky and the Bluetooth dongle
66 | - unplug all other USB such as WIFI dongle etc (I have noticed that otherwise the computer becomes really slow)
67 |
68 | Making the map with Gmapping:
69 |
70 | ``` sudo service husky_core stop ```
71 |
72 | ``` sudo service husky_core start```
73 | (it's good to restart Husky drivers)
74 |
75 | ``` roslaunch velodyne_pointcloud VLP16_points.launch ```
76 |
77 | ``` roslaunch pointcloud_to_laserscan sample_node.launch ```
78 |
79 | ``` roslaunch husky_navigation gmapping_demo.launch ```
80 |
81 | ``` roslaunch husky_viz view_robot.launch ```
82 |
83 |
84 | Using AMCL, I have created a launch file to make it easier:
85 |
86 | ``` roslaunch demo_launch sbox_demo_launch.launch ```
87 |
88 | Have fun!
89 |
--------------------------------------------------------------------------------
/connection/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(connection)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | # add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | roscpp
12 | rospy
13 | std_msgs
14 | )
15 |
16 | ## System dependencies are found with CMake's conventions
17 | # find_package(Boost REQUIRED COMPONENTS system)
18 |
19 |
20 | ## Uncomment this if the package has a setup.py. This macro ensures
21 | ## modules and global scripts declared therein get installed
22 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
23 | # catkin_python_setup()
24 |
25 | ################################################
26 | ## Declare ROS messages, services and actions ##
27 | ################################################
28 |
29 | ## To declare and build messages, services or actions from within this
30 | ## package, follow these steps:
31 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
32 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
33 | ## * In the file package.xml:
34 | ## * add a build_depend tag for "message_generation"
35 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
36 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
37 | ## but can be declared for certainty nonetheless:
38 | ## * add a exec_depend tag for "message_runtime"
39 | ## * In this file (CMakeLists.txt):
40 | ## * add "message_generation" and every package in MSG_DEP_SET to
41 | ## find_package(catkin REQUIRED COMPONENTS ...)
42 | ## * add "message_runtime" and every package in MSG_DEP_SET to
43 | ## catkin_package(CATKIN_DEPENDS ...)
44 | ## * uncomment the add_*_files sections below as needed
45 | ## and list every .msg/.srv/.action file to be processed
46 | ## * uncomment the generate_messages entry below
47 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
48 |
49 | ## Generate messages in the 'msg' folder
50 | # add_message_files(
51 | # FILES
52 | # Message1.msg
53 | # Message2.msg
54 | # )
55 |
56 | ## Generate services in the 'srv' folder
57 | # add_service_files(
58 | # FILES
59 | # Service1.srv
60 | # Service2.srv
61 | # )
62 |
63 | ## Generate actions in the 'action' folder
64 | # add_action_files(
65 | # FILES
66 | # Action1.action
67 | # Action2.action
68 | # )
69 |
70 | ## Generate added messages and services with any dependencies listed here
71 | # generate_messages(
72 | # DEPENDENCIES
73 | # std_msgs
74 | # )
75 |
76 | ################################################
77 | ## Declare ROS dynamic reconfigure parameters ##
78 | ################################################
79 |
80 | ## To declare and build dynamic reconfigure parameters within this
81 | ## package, follow these steps:
82 | ## * In the file package.xml:
83 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
84 | ## * In this file (CMakeLists.txt):
85 | ## * add "dynamic_reconfigure" to
86 | ## find_package(catkin REQUIRED COMPONENTS ...)
87 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
88 | ## and list every .cfg file to be processed
89 |
90 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
91 | # generate_dynamic_reconfigure_options(
92 | # cfg/DynReconf1.cfg
93 | # cfg/DynReconf2.cfg
94 | # )
95 |
96 | ###################################
97 | ## catkin specific configuration ##
98 | ###################################
99 | ## The catkin_package macro generates cmake config files for your package
100 | ## Declare things to be passed to dependent projects
101 | ## INCLUDE_DIRS: uncomment this if your package contains header files
102 | ## LIBRARIES: libraries you create in this project that dependent projects also need
103 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
104 | ## DEPENDS: system dependencies of this project that dependent projects also need
105 | catkin_package(
106 | # INCLUDE_DIRS include
107 | # LIBRARIES connection
108 | # CATKIN_DEPENDS roscpp rospy std_msgs
109 | # DEPENDS system_lib
110 | )
111 |
112 | ###########
113 | ## Build ##
114 | ###########
115 |
116 | ## Specify additional locations of header files
117 | ## Your package locations should be listed before other locations
118 | include_directories(
119 | # include
120 | ${catkin_INCLUDE_DIRS}
121 | )
122 |
123 | ## Declare a C++ library
124 | # add_library(${PROJECT_NAME}
125 | # src/${PROJECT_NAME}/connection.cpp
126 | # )
127 |
128 | ## Add cmake target dependencies of the library
129 | ## as an example, code may need to be generated before libraries
130 | ## either from message generation or dynamic reconfigure
131 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
132 |
133 | ## Declare a C++ executable
134 | ## With catkin_make all packages are built within a single CMake context
135 | ## The recommended prefix ensures that target names across packages don't collide
136 | # add_executable(${PROJECT_NAME}_node src/connection_node.cpp)
137 |
138 | ## Rename C++ executable without prefix
139 | ## The above recommended prefix causes long target names, the following renames the
140 | ## target back to the shorter version for ease of user use
141 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
142 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
143 |
144 | ## Add cmake target dependencies of the executable
145 | ## same as for the library above
146 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
147 |
148 | ## Specify libraries to link a library or executable target against
149 | # target_link_libraries(${PROJECT_NAME}_node
150 | # ${catkin_LIBRARIES}
151 | # )
152 |
153 | #############
154 | ## Install ##
155 | #############
156 |
157 | # all install targets should use catkin DESTINATION variables
158 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
159 |
160 | ## Mark executable scripts (Python etc.) for installation
161 | ## in contrast to setup.py, you can choose the destination
162 | # install(PROGRAMS
163 | # scripts/my_python_script
164 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
165 | # )
166 |
167 | ## Mark executables and/or libraries for installation
168 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
169 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
170 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
171 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
172 | # )
173 |
174 | ## Mark cpp header files for installation
175 | # install(DIRECTORY include/${PROJECT_NAME}/
176 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
177 | # FILES_MATCHING PATTERN "*.h"
178 | # PATTERN ".svn" EXCLUDE
179 | # )
180 |
181 | ## Mark other files for installation (e.g. launch and bag files, etc.)
182 | # install(FILES
183 | # # myfile1
184 | # # myfile2
185 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
186 | # )
187 |
188 | #############
189 | ## Testing ##
190 | #############
191 |
192 | ## Add gtest based cpp test target and link libraries
193 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_connection.cpp)
194 | # if(TARGET ${PROJECT_NAME}-test)
195 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
196 | # endif()
197 |
198 | ## Add folders to be run by python nosetests
199 | # catkin_add_nosetests(test)
200 |
--------------------------------------------------------------------------------
/connection/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | connection
4 | 0.0.0
5 | The connection package
6 |
7 |
8 |
9 |
10 | wang
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | roscpp
53 | rospy
54 | std_msgs
55 | roscpp
56 | rospy
57 | std_msgs
58 | roscpp
59 | rospy
60 | std_msgs
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/connection/scripts/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/connection/scripts/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/connection/scripts/.idea/scripts.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/connection/scripts/.idea/workspace.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
112 |
113 |
114 |
115 | ADDR
116 | username
117 | clients
118 | chat
119 | true
120 | Deal
121 | chatwith
122 | tcpCliSock
123 | test
124 | data
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | 1544405005269
222 |
223 |
224 | 1544405005269
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
--------------------------------------------------------------------------------
/connection/scripts/husky_sender.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import socket
5 | import rospy
6 | import argparse
7 | from geometry_msgs.msg import PoseStamped
8 | from std_msgs.msg import Float32MultiArray
9 |
10 | parser = argparse.ArgumentParser()
11 | parser.add_argument("port", help="specify udp port")
12 | args = parser.parse_args()
13 |
14 |
15 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
16 | addr = ('192.168.70.100', int(args.port))
17 |
18 | def send(data):
19 | s.sendto(("husky," + str(data.data[:])).encode(), addr)
20 |
21 | def main():
22 | rospy.init_node("huksyerr_send2udp", anonymous=True)
23 | rospy.Subscriber("/err_calc", Float32MultiArray, send)
24 | rospy.spin()
25 |
26 |
27 | if __name__ == '__main__':
28 | main()
29 |
--------------------------------------------------------------------------------
/connection/scripts/husky_sender_new.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import socket
5 | import rospy
6 | import argparse
7 | from geometry_msgs.msg import PoseStamped
8 | from std_msgs.msg import Float32MultiArray
9 | from nav_msgs.msg import Path
10 | import tf2_ros
11 |
12 |
13 |
14 |
15 | class HuskySender(object):
16 | def __init__(self, ip, port):
17 | self.tfBuffer = tf2_ros.Buffer()
18 | listener = tf2_ros.TransformListener(self.tfBuffer)
19 | self.ip = ip
20 | self.port = port
21 | self.s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
22 | self.addr = (str(ip), int(port))
23 | rospy.Subscriber("/err_calc", Float32MultiArray, self.errSender)
24 | rospy.Subscriber("/move_base/DWAPlannerROS/global_plan", Path, self.pathSender)
25 |
26 | def errSender(self, data):
27 | self.s.sendto(("husky," + str(data.data[:])).encode(), self.addr)
28 |
29 | def pathSender(self, data):
30 | try:
31 | odom = self.tfBuffer.lookup_transform("world", "odom", rospy.Time())
32 | except (tf2_ros.LookupException, tf2_ros.ConnectivityException, tf2_ros.ExtrapolationException):
33 | return
34 | husky_path = []
35 | husky_path.append([odom.transform.translation.x, odom.transform.translation.y, odom.transform.translation.z,
36 | odom.transform.rotation.x, odom.transform.rotation.y, odom.transform.rotation.z, odom.transform.rotation.w])
37 | for pose in data.poses:
38 | husky_path.append([pose.pose.position.x, pose.pose.position.y, pose.pose.position.z,
39 | pose.pose.orientation.x, pose.pose.orientation.y, pose.pose.orientation.z, pose.pose.orientation.w])
40 |
41 | self.s.sendto(("path," + str(husky_path)).encode(), self.addr)
42 |
43 |
44 |
45 |
46 | if __name__ == '__main__':
47 | rospy.init_node("husky_sender", anonymous=True)
48 | huskySender = HuskySender("192.168.1.114", '60000')
49 | rospy.spin()
50 |
--------------------------------------------------------------------------------
/connection/scripts/server.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | import rospy
4 | import socket
5 | from std_msgs.msg import Float32MultiArray
6 | from nav_msgs.msg import Path
7 | import argparse
8 |
9 | parser = argparse.ArgumentParser()
10 | parser.add_argument("port", help="specify udp port")
11 | args = parser.parse_args()
12 |
13 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
14 | s.bind(("192.168.1.114", int(args.port)))
15 | print("UDP bound on port %s..." % args.port)
16 |
17 |
18 | def main():
19 | rospy.init_node("server", anonymous=True)
20 | vo_pub = rospy.Publisher("vo_err", Float32MultiArray, queue_size=1)
21 | husky_pub = rospy.Publisher("husky_err", Float32MultiArray, queue_size=1)
22 | while not rospy.is_shutdown():
23 | data, addr = s.recvfrom(1024)
24 | print("Receive from %s:%s" % addr)
25 | msg = Float32MultiArray()
26 | data = data.replace("(", "").replace(")", "").split(",")
27 | msg.data = list(map(float, data[1:]) )
28 | if data[0] == "vo":
29 | vo_pub.publish(msg)
30 | if data[0] == "husky":
31 | husky_pub.publish(msg)
32 |
33 | if __name__ == '__main__':
34 | main()
35 |
--------------------------------------------------------------------------------
/connection/scripts/vo_sender.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 |
4 | import socket
5 | import rospy
6 | import argparse
7 | from geometry_msgs.msg import PoseStamped
8 | from std_msgs.msg import Float32MultiArray
9 |
10 | parser = argparse.ArgumentParser()
11 | parser.add_argument("port", help="specify udp port")
12 | args = parser.parse_args()
13 |
14 |
15 | s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
16 | addr = ('192.168.1.114', int(args.port))
17 |
18 | def send(data):
19 | s.sendto(("vo," + str(data.data[:])).encode(), addr)
20 |
21 | def main():
22 | rospy.init_node("huksyerr_send2udp", anonymous=True)
23 | rospy.Subscriber("/vo_topic", Float32MultiArray, send)
24 | rospy.spin()
25 |
26 |
27 | if __name__ == '__main__':
28 | main()
29 |
--------------------------------------------------------------------------------
/demo_launch/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(demo_launch)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | # add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | roscpp
12 | rospy
13 | std_msgs
14 | )
15 |
16 | ## System dependencies are found with CMake's conventions
17 | # find_package(Boost REQUIRED COMPONENTS system)
18 |
19 |
20 | ## Uncomment this if the package has a setup.py. This macro ensures
21 | ## modules and global scripts declared therein get installed
22 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
23 | # catkin_python_setup()
24 |
25 | ################################################
26 | ## Declare ROS messages, services and actions ##
27 | ################################################
28 |
29 | ## To declare and build messages, services or actions from within this
30 | ## package, follow these steps:
31 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
32 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
33 | ## * In the file package.xml:
34 | ## * add a build_depend tag for "message_generation"
35 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
36 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
37 | ## but can be declared for certainty nonetheless:
38 | ## * add a exec_depend tag for "message_runtime"
39 | ## * In this file (CMakeLists.txt):
40 | ## * add "message_generation" and every package in MSG_DEP_SET to
41 | ## find_package(catkin REQUIRED COMPONENTS ...)
42 | ## * add "message_runtime" and every package in MSG_DEP_SET to
43 | ## catkin_package(CATKIN_DEPENDS ...)
44 | ## * uncomment the add_*_files sections below as needed
45 | ## and list every .msg/.srv/.action file to be processed
46 | ## * uncomment the generate_messages entry below
47 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
48 |
49 | ## Generate messages in the 'msg' folder
50 | # add_message_files(
51 | # FILES
52 | # Message1.msg
53 | # Message2.msg
54 | # )
55 |
56 | ## Generate services in the 'srv' folder
57 | # add_service_files(
58 | # FILES
59 | # Service1.srv
60 | # Service2.srv
61 | # )
62 |
63 | ## Generate actions in the 'action' folder
64 | # add_action_files(
65 | # FILES
66 | # Action1.action
67 | # Action2.action
68 | # )
69 |
70 | ## Generate added messages and services with any dependencies listed here
71 | # generate_messages(
72 | # DEPENDENCIES
73 | # std_msgs
74 | # )
75 |
76 | ################################################
77 | ## Declare ROS dynamic reconfigure parameters ##
78 | ################################################
79 |
80 | ## To declare and build dynamic reconfigure parameters within this
81 | ## package, follow these steps:
82 | ## * In the file package.xml:
83 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
84 | ## * In this file (CMakeLists.txt):
85 | ## * add "dynamic_reconfigure" to
86 | ## find_package(catkin REQUIRED COMPONENTS ...)
87 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
88 | ## and list every .cfg file to be processed
89 |
90 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
91 | # generate_dynamic_reconfigure_options(
92 | # cfg/DynReconf1.cfg
93 | # cfg/DynReconf2.cfg
94 | # )
95 |
96 | ###################################
97 | ## catkin specific configuration ##
98 | ###################################
99 | ## The catkin_package macro generates cmake config files for your package
100 | ## Declare things to be passed to dependent projects
101 | ## INCLUDE_DIRS: uncomment this if your package contains header files
102 | ## LIBRARIES: libraries you create in this project that dependent projects also need
103 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
104 | ## DEPENDS: system dependencies of this project that dependent projects also need
105 | catkin_package(
106 | # INCLUDE_DIRS include
107 | # LIBRARIES demo_launch
108 | # CATKIN_DEPENDS roscpp rospy std_msgs
109 | # DEPENDS system_lib
110 | )
111 |
112 | ###########
113 | ## Build ##
114 | ###########
115 |
116 | ## Specify additional locations of header files
117 | ## Your package locations should be listed before other locations
118 | include_directories(
119 | # include
120 | ${catkin_INCLUDE_DIRS}
121 | )
122 |
123 | ## Declare a C++ library
124 | # add_library(${PROJECT_NAME}
125 | # src/${PROJECT_NAME}/demo_launch.cpp
126 | # )
127 |
128 | ## Add cmake target dependencies of the library
129 | ## as an example, code may need to be generated before libraries
130 | ## either from message generation or dynamic reconfigure
131 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
132 |
133 | ## Declare a C++ executable
134 | ## With catkin_make all packages are built within a single CMake context
135 | ## The recommended prefix ensures that target names across packages don't collide
136 | # add_executable(${PROJECT_NAME}_node src/demo_launch_node.cpp)
137 |
138 | ## Rename C++ executable without prefix
139 | ## The above recommended prefix causes long target names, the following renames the
140 | ## target back to the shorter version for ease of user use
141 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
142 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
143 |
144 | ## Add cmake target dependencies of the executable
145 | ## same as for the library above
146 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
147 |
148 | ## Specify libraries to link a library or executable target against
149 | # target_link_libraries(${PROJECT_NAME}_node
150 | # ${catkin_LIBRARIES}
151 | # )
152 |
153 | #############
154 | ## Install ##
155 | #############
156 |
157 | # all install targets should use catkin DESTINATION variables
158 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
159 |
160 | ## Mark executable scripts (Python etc.) for installation
161 | ## in contrast to setup.py, you can choose the destination
162 | # install(PROGRAMS
163 | # scripts/my_python_script
164 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
165 | # )
166 |
167 | ## Mark executables and/or libraries for installation
168 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
169 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
170 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
171 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
172 | # )
173 |
174 | ## Mark cpp header files for installation
175 | # install(DIRECTORY include/${PROJECT_NAME}/
176 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
177 | # FILES_MATCHING PATTERN "*.h"
178 | # PATTERN ".svn" EXCLUDE
179 | # )
180 |
181 | ## Mark other files for installation (e.g. launch and bag files, etc.)
182 | # install(FILES
183 | # # myfile1
184 | # # myfile2
185 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
186 | # )
187 |
188 | #############
189 | ## Testing ##
190 | #############
191 |
192 | ## Add gtest based cpp test target and link libraries
193 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_demo_launch.cpp)
194 | # if(TARGET ${PROJECT_NAME}-test)
195 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
196 | # endif()
197 |
198 | ## Add folders to be run by python nosetests
199 | # catkin_add_nosetests(test)
200 |
--------------------------------------------------------------------------------
/demo_launch/launch/sbox_demo_launch.launch:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/demo_launch/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | demo_launch
4 | 0.0.0
5 | The demo_launch package
6 |
7 |
8 |
9 |
10 | bdi
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | roscpp
53 | rospy
54 | std_msgs
55 | roscpp
56 | rospy
57 | std_msgs
58 | roscpp
59 | rospy
60 | std_msgs
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/husky_ws/husky_back.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sgabello1/SensorBox/5766183a449e6428e2ed8807b3eb0800ef686cab/husky_ws/husky_back.tar.gz
--------------------------------------------------------------------------------
/husky_ws/husky_change_file/amcl_demo.launch:
--------------------------------------------------------------------------------
1 |
2 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/husky_ws/husky_change_file/demodisplay_husky.urdf.xacro:
--------------------------------------------------------------------------------
1 |
2 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | $(arg robot_namespace)
180 |
181 |
182 |
183 |
184 |
185 | $(arg robot_namespace)
186 | 50.0
187 | base_link
188 | imu/data
189 | 0.005 0.005 0.005
190 | 0.005 0.005 0.005
191 | 0.005 0.005 0.005
192 | 0.005 0.005 0.005
193 | 0.005
194 | 0.005
195 |
196 |
197 |
198 |
199 |
200 | $(arg robot_namespace)
201 | 40
202 | base_link
203 | base_link
204 | navsat/fix
205 | navsat/vel
206 | 49.9
207 | 8.9
208 | 0
209 | 0
210 | 0.0001 0.0001 0.0001
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
--------------------------------------------------------------------------------
/husky_ws/maps/cartographer_demo/map.pgm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sgabello1/SensorBox/5766183a449e6428e2ed8807b3eb0800ef686cab/husky_ws/maps/cartographer_demo/map.pgm
--------------------------------------------------------------------------------
/husky_ws/maps/cartographer_demo/map.yaml:
--------------------------------------------------------------------------------
1 | image: map.pgm
2 | resolution: 0.050000
3 | origin: [-24.982702, -10.684843, 0.000000]
4 | negate: 0
5 | occupied_thresh: 0.65
6 | free_thresh: 0.196
7 |
8 |
--------------------------------------------------------------------------------
/husky_ws/maps/demo_map/map.pgm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sgabello1/SensorBox/5766183a449e6428e2ed8807b3eb0800ef686cab/husky_ws/maps/demo_map/map.pgm
--------------------------------------------------------------------------------
/husky_ws/maps/demo_map/map.yaml:
--------------------------------------------------------------------------------
1 | image: map.pgm
2 | resolution: 0.050000
3 | origin: [-100.000000, -100.000000, 0.000000]
4 | negate: 0
5 | occupied_thresh: 0.65
6 | free_thresh: 0.196
7 |
8 |
--------------------------------------------------------------------------------
/husky_ws/maps/map.pgm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sgabello1/SensorBox/5766183a449e6428e2ed8807b3eb0800ef686cab/husky_ws/maps/map.pgm
--------------------------------------------------------------------------------
/husky_ws/maps/map.yaml:
--------------------------------------------------------------------------------
1 | image: map.pgm
2 | resolution: 0.050000
3 | origin: [-20.971763, -56.875969, 0.000000]
4 | negate: 0
5 | occupied_thresh: 0.65
6 | free_thresh: 0.196
7 |
8 |
--------------------------------------------------------------------------------
/husky_ws/pose/cartographer_demo/pose.txt:
--------------------------------------------------------------------------------
1 | 4.192395644775
2 | 7.280558411231
3 | 0.831071581010
4 | 0.000823118891
5 | 0.000660559636
6 | -1.565928086453
7 |
--------------------------------------------------------------------------------
/husky_ws/pose/demo_pose/husky_demo_get_pose.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | import rospy
3 | from geometry_msgs.msg import PoseStamped
4 |
5 | import os
6 | import argparse
7 | from tf.transformations import euler_from_quaternion, quaternion_from_euler
8 |
9 | pitch = yaw = roll = 0.0
10 |
11 |
12 | def extract():
13 |
14 | rospy.init_node('get_husky_pose', anonymous=True)
15 | rospy.Subscriber('vrpn_client_node/husky/pose', PoseStamped, callback)
16 | rospy.spin()
17 |
18 | def callback(Pose):
19 | n = 0
20 | f = open('./pose.txt', 'w')
21 | # f.write('timestamp,x,y,z,roll,pitch,yaw\n')
22 | x_list = []
23 | y_list = []
24 | z_list = []
25 | roll_list = []
26 | pitch_list = []
27 | yaw_list = []
28 | # for (topic, msg, ts) in bag.read_messages(topics='vrpn_client_node/husky/pose')):
29 | while (n < 500):
30 | orientation_list = [Pose.pose.orientation.x, Pose.pose.orientation.y, Pose.pose.orientation.z, Pose.pose.orientation.w]
31 | (roll, pitch, yaw) = euler_from_quaternion (orientation_list)
32 |
33 | x_list.append(Pose.pose.position.x)
34 | y_list.append(Pose.pose.position.y)
35 | z_list.append(Pose.pose.position.z)
36 |
37 | roll_list.append(roll)
38 | pitch_list.append(pitch)
39 | yaw_list.append(yaw)
40 |
41 | n += 1
42 | print(n)
43 |
44 | f.write('%.12f\n%.12f\n%.12f\n%.12f\n%.12f\n%.12f\n' %
45 | (
46 | sum(x_list)/len(x_list),
47 | sum(y_list)/len(y_list),
48 | sum(z_list)/len(z_list),
49 | sum(pitch_list)/len(pitch_list),
50 | sum(roll_list)/len(roll_list),
51 | sum(yaw_list)/len(yaw_list) - 1.57
52 |
53 | )
54 | )
55 |
56 | rospy.signal_shutdown("pose had write done!")
57 | print("pose had write done!")
58 |
59 | if __name__ == '__main__':
60 |
61 | extract()
62 |
--------------------------------------------------------------------------------
/husky_ws/pose/demo_pose/pose.txt:
--------------------------------------------------------------------------------
1 | 4.573798715043
2 | 7.781923319430
3 | 0.528850198224
4 | 0.011847702010
5 | -0.008401158187
6 | -1.601165249639
7 |
--------------------------------------------------------------------------------
/husky_ws/pose/husky_demo_get_pose.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python2
2 | import rospy
3 | from geometry_msgs.msg import PoseStamped
4 |
5 | import os
6 | import argparse
7 | from tf.transformations import euler_from_quaternion, quaternion_from_euler
8 |
9 | pitch = yaw = roll = 0.0
10 |
11 |
12 | def extract():
13 |
14 | rospy.init_node('get_husky_pose', anonymous=True)
15 | rospy.Subscriber('vrpn_client_node/husky/pose', PoseStamped, callback)
16 | rospy.spin()
17 |
18 | def callback(Pose):
19 | n = 0
20 | f = open('./pose.txt', 'w')
21 | # f.write('timestamp,x,y,z,roll,pitch,yaw\n')
22 | x_list = []
23 | y_list = []
24 | z_list = []
25 | roll_list = []
26 | pitch_list = []
27 | yaw_list = []
28 | # for (topic, msg, ts) in bag.read_messages(topics='vrpn_client_node/husky/pose')):
29 | while (n < 500):
30 | orientation_list = [Pose.pose.orientation.x, Pose.pose.orientation.y, Pose.pose.orientation.z, Pose.pose.orientation.w]
31 | (roll, pitch, yaw) = euler_from_quaternion (orientation_list)
32 |
33 | x_list.append(Pose.pose.position.x)
34 | y_list.append(Pose.pose.position.y)
35 | z_list.append(Pose.pose.position.z)
36 |
37 | roll_list.append(roll)
38 | pitch_list.append(pitch)
39 | yaw_list.append(yaw)
40 |
41 | n += 1
42 | print(n)
43 |
44 | f.write('%.12f\n%.12f\n%.12f\n%.12f\n%.12f\n%.12f\n' %
45 | (
46 | sum(x_list)/len(x_list),
47 | sum(y_list)/len(y_list),
48 | sum(z_list)/len(z_list),
49 | sum(pitch_list)/len(pitch_list),
50 | sum(roll_list)/len(roll_list),
51 | sum(yaw_list)/len(yaw_list) - 1.57
52 |
53 | )
54 | )
55 |
56 | rospy.signal_shutdown("pose had write done!")
57 | print("pose had write done!")
58 |
59 | if __name__ == '__main__':
60 |
61 | extract()
62 |
--------------------------------------------------------------------------------
/husky_ws/pose/pose.txt:
--------------------------------------------------------------------------------
1 | 3.373555597935
2 | 8.146227294461
3 | 0.807108307931
4 | 0.000939255174
5 | 0.000390930235
6 | -1.568111709590
7 |
--------------------------------------------------------------------------------
/husky_ws/test/map.pgm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/sgabello1/SensorBox/5766183a449e6428e2ed8807b3eb0800ef686cab/husky_ws/test/map.pgm
--------------------------------------------------------------------------------
/husky_ws/test/map.yaml:
--------------------------------------------------------------------------------
1 | image: map.pgm
2 | resolution: 0.050000
3 | origin: [-100.000000, -100.000000, 0.000000]
4 | negate: 0
5 | occupied_thresh: 0.65
6 | free_thresh: 0.196
7 |
8 |
--------------------------------------------------------------------------------
/husky_ws/test/pose.txt:
--------------------------------------------------------------------------------
1 | 3.593364490473
2 | -0.019040203472
3 | 0.758996176367
4 | 0.016306104256
5 | -0.000574792868
6 | -3.177483934125
7 |
--------------------------------------------------------------------------------
/pose_tf/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(pose_tf)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | # add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | geometry_msgs
12 | roscpp
13 | rospy
14 | std_msgs
15 | )
16 |
17 | ## System dependencies are found with CMake's conventions
18 | # find_package(Boost REQUIRED COMPONENTS system)
19 |
20 |
21 | ## Uncomment this if the package has a setup.py. This macro ensures
22 | ## modules and global scripts declared therein get installed
23 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
24 | # catkin_python_setup()
25 |
26 | ################################################
27 | ## Declare ROS messages, services and actions ##
28 | ################################################
29 |
30 | ## To declare and build messages, services or actions from within this
31 | ## package, follow these steps:
32 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
33 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
34 | ## * In the file package.xml:
35 | ## * add a build_depend tag for "message_generation"
36 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
37 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
38 | ## but can be declared for certainty nonetheless:
39 | ## * add a exec_depend tag for "message_runtime"
40 | ## * In this file (CMakeLists.txt):
41 | ## * add "message_generation" and every package in MSG_DEP_SET to
42 | ## find_package(catkin REQUIRED COMPONENTS ...)
43 | ## * add "message_runtime" and every package in MSG_DEP_SET to
44 | ## catkin_package(CATKIN_DEPENDS ...)
45 | ## * uncomment the add_*_files sections below as needed
46 | ## and list every .msg/.srv/.action file to be processed
47 | ## * uncomment the generate_messages entry below
48 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
49 |
50 | ## Generate messages in the 'msg' folder
51 | # add_message_files(
52 | # FILES
53 | # Message1.msg
54 | # Message2.msg
55 | # )
56 |
57 | ## Generate services in the 'srv' folder
58 | # add_service_files(
59 | # FILES
60 | # Service1.srv
61 | # Service2.srv
62 | # )
63 |
64 | ## Generate actions in the 'action' folder
65 | # add_action_files(
66 | # FILES
67 | # Action1.action
68 | # Action2.action
69 | # )
70 |
71 | ## Generate added messages and services with any dependencies listed here
72 | # generate_messages(
73 | # DEPENDENCIES
74 | # geometry_msgs# std_msgs
75 | # )
76 |
77 | ################################################
78 | ## Declare ROS dynamic reconfigure parameters ##
79 | ################################################
80 |
81 | ## To declare and build dynamic reconfigure parameters within this
82 | ## package, follow these steps:
83 | ## * In the file package.xml:
84 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
85 | ## * In this file (CMakeLists.txt):
86 | ## * add "dynamic_reconfigure" to
87 | ## find_package(catkin REQUIRED COMPONENTS ...)
88 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
89 | ## and list every .cfg file to be processed
90 |
91 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
92 | # generate_dynamic_reconfigure_options(
93 | # cfg/DynReconf1.cfg
94 | # cfg/DynReconf2.cfg
95 | # )
96 |
97 | ###################################
98 | ## catkin specific configuration ##
99 | ###################################
100 | ## The catkin_package macro generates cmake config files for your package
101 | ## Declare things to be passed to dependent projects
102 | ## INCLUDE_DIRS: uncomment this if your package contains header files
103 | ## LIBRARIES: libraries you create in this project that dependent projects also need
104 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
105 | ## DEPENDS: system dependencies of this project that dependent projects also need
106 | catkin_package(
107 | # INCLUDE_DIRS include
108 | # LIBRARIES pose_tf
109 | # CATKIN_DEPENDS geometry_msgs roscpp rospy std_msgs
110 | # DEPENDS system_lib
111 | )
112 |
113 | ###########
114 | ## Build ##
115 | ###########
116 |
117 | ## Specify additional locations of header files
118 | ## Your package locations should be listed before other locations
119 | include_directories(
120 | # include
121 | ${catkin_INCLUDE_DIRS}
122 | )
123 |
124 | ## Declare a C++ library
125 | # add_library(${PROJECT_NAME}
126 | # src/${PROJECT_NAME}/pose_tf.cpp
127 | # )
128 |
129 | ## Add cmake target dependencies of the library
130 | ## as an example, code may need to be generated before libraries
131 | ## either from message generation or dynamic reconfigure
132 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
133 |
134 | ## Declare a C++ executable
135 | ## With catkin_make all packages are built within a single CMake context
136 | ## The recommended prefix ensures that target names across packages don't collide
137 | # add_executable(${PROJECT_NAME}_node src/pose_tf_node.cpp)
138 |
139 | ## Rename C++ executable without prefix
140 | ## The above recommended prefix causes long target names, the following renames the
141 | ## target back to the shorter version for ease of user use
142 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
143 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
144 |
145 | ## Add cmake target dependencies of the executable
146 | ## same as for the library above
147 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
148 |
149 | ## Specify libraries to link a library or executable target against
150 | # target_link_libraries(${PROJECT_NAME}_node
151 | # ${catkin_LIBRARIES}
152 | # )
153 |
154 | #############
155 | ## Install ##
156 | #############
157 |
158 | # all install targets should use catkin DESTINATION variables
159 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
160 |
161 | ## Mark executable scripts (Python etc.) for installation
162 | ## in contrast to setup.py, you can choose the destination
163 | # install(PROGRAMS
164 | # scripts/my_python_script
165 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
166 | # )
167 |
168 | ## Mark executables and/or libraries for installation
169 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
170 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
171 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
172 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
173 | # )
174 |
175 | ## Mark cpp header files for installation
176 | # install(DIRECTORY include/${PROJECT_NAME}/
177 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
178 | # FILES_MATCHING PATTERN "*.h"
179 | # PATTERN ".svn" EXCLUDE
180 | # )
181 |
182 | ## Mark other files for installation (e.g. launch and bag files, etc.)
183 | # install(FILES
184 | # # myfile1
185 | # # myfile2
186 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
187 | # )
188 |
189 | #############
190 | ## Testing ##
191 | #############
192 |
193 | ## Add gtest based cpp test target and link libraries
194 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_pose_tf.cpp)
195 | # if(TARGET ${PROJECT_NAME}-test)
196 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
197 | # endif()
198 |
199 | ## Add folders to be run by python nosetests
200 | # catkin_add_nosetests(test)
201 |
--------------------------------------------------------------------------------
/pose_tf/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | pose_tf
4 | 0.0.0
5 | The pose_tf package
6 |
7 |
8 |
9 |
10 | gabriele
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | geometry_msgs
53 | roscpp
54 | rospy
55 | std_msgs
56 | geometry_msgs
57 | roscpp
58 | rospy
59 | std_msgs
60 | geometry_msgs
61 | roscpp
62 | rospy
63 | std_msgs
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/pose_tf/scripts/manual-wp-2505.txt:
--------------------------------------------------------------------------------
1 | goal position:
2 | x: 6.45013341991
3 | y: 7.45609351233
4 | z: 0.341357841999
5 | orientation:
6 | x: -0.00372010407558
7 | y: -0.0015018882385
8 | z: -0.640923373862
9 | w: -0.767594362291
10 |
11 | start position:
12 | x: 5.91510419937
13 | y: 2.39716929441
14 | z: 0.345269200883
15 | orientation:
16 | x: 0.00574111708413
17 | y: -0.0024935800828
18 | z: 0.964222467507
19 | w: 0.265020418999
20 |
21 |
--------------------------------------------------------------------------------
/pose_tf/scripts/pose_loader.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import roslib
3 | import rospy
4 | import tf2_ros
5 | import tf2_geometry_msgs
6 | from geometry_msgs.msg import PoseWithCovarianceStamped, PoseWithCovariance
7 | import math
8 | import time
9 |
10 | rospy.init_node('pose_tf')
11 | tfBuffer = tf2_ros.Buffer()
12 | listener = tf2_ros.TransformListener(tfBuffer)
13 | pose_tf = rospy.Publisher('/initialpose', PoseWithCovarianceStamped, queue_size=1, latch=True)
14 | trans = tfBuffer.lookup_transform('map', 'world',rospy.Time(0),rospy.Duration(1.0))
15 |
16 | text_file = open("waypoints.txt", "r")
17 | lines = text_file.readlines()
18 | wp = PoseWithCovariance()
19 | wp_transformed_st = PoseWithCovarianceStamped()
20 |
21 | for i in range(0,len(lines)):
22 | el = lines[i].split(',')
23 | wp.pose.position.x = float(el[0])
24 | wp.pose.position.y = float(el[1])
25 | wp.pose.position.z = float(el[2])
26 |
27 | wp.pose.orientation.x = float(el[3])
28 | wp.pose.orientation.y = float(el[4])
29 | wp.pose.orientation.z = float(el[5])
30 | wp.pose.orientation.w = float(el[6].split('\n')[0])
31 |
32 | wp_transformed = tf2_geometry_msgs.do_transform_pose(wp, trans)
33 | wp_transformed_st.pose.pose.position = wp_transformed.pose.position
34 | wp_transformed_st.pose.pose.orientation = wp_transformed.pose.orientation
35 | pose_tf.publish(wp_transformed_st)
36 | time.sleep(2)
37 | #print wp.pose.orientation.w #Debug
38 | print "WP " , i
39 |
40 | text_file.close()
41 |
--------------------------------------------------------------------------------
/pose_tf/scripts/talker.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | import roslib
3 | import rospy
4 | import tf2_ros
5 | import tf2_geometry_msgs
6 | from geometry_msgs.msg import PoseWithCovarianceStamped, PoseWithCovariance
7 | import math
8 | import time
9 |
10 |
11 | if __name__ == '__main__':
12 | rospy.init_node('pose_tf')
13 |
14 | tfBuffer = tf2_ros.Buffer()
15 | listener = tf2_ros.TransformListener(tfBuffer)
16 |
17 |
18 | pose_tf = rospy.Publisher('/initialpose', PoseWithCovarianceStamped, queue_size=1, latch=True)
19 | trans = tfBuffer.lookup_transform('map', 'world',rospy.Time(0),rospy.Duration(1.0))
20 | wp1 = PoseWithCovariance()
21 | ## WP2
22 |
23 |
24 | wp1.pose.position.x = -3.41388380381
25 | wp1.pose.position.y = -5.04600568964
26 | wp1.pose.position.z = 0.421817075425
27 |
28 | wp1.pose.orientation.x = -0.00346357583061
29 | wp1.pose.orientation.y = 0.00427715047416
30 | wp1.pose.orientation.z = 0.803023547028
31 | wp1.pose.orientation.w = -0.595921895588
32 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
33 |
34 | wp1_transformed_st = PoseWithCovarianceStamped()
35 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
36 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
37 |
38 | pose_tf.publish(wp1_transformed_st)
39 |
40 | time.sleep(2)
41 | print "wp 2"
42 |
43 | ## WP3
44 | wp1.pose.position.x = 1.30165610587
45 | wp1.pose.position.y = -1.55171769059
46 | wp1.pose.position.z = 0.399708028339
47 |
48 | wp1.pose.orientation.x = -0.00184794586291
49 | wp1.pose.orientation.y = -0.00630307605557
50 | wp1.pose.orientation.z = -0.373115837911
51 | wp1.pose.orientation.w = -0.927761517461
52 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
53 |
54 | wp1_transformed_st = PoseWithCovarianceStamped()
55 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
56 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
57 |
58 | pose_tf.publish(wp1_transformed_st)
59 |
60 | time.sleep(1)
61 | print "wp 3"
62 |
63 | ## WP4
64 | wp1.pose.position.x = 4.9280696055
65 | wp1.pose.position.y = 2.44382647284
66 | wp1.pose.position.z = 0.382309819649
67 |
68 | wp1.pose.orientation.x = -0.00528022570207
69 | wp1.pose.orientation.y = -0.00525134096999
70 | wp1.pose.orientation.z = -0.44961072356
71 | wp1.pose.orientation.w = -0.893193526051
72 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
73 |
74 | wp1_transformed_st = PoseWithCovarianceStamped()
75 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
76 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
77 |
78 | pose_tf.publish(wp1_transformed_st)
79 | time.sleep(1)
80 | print "wp 4"
81 |
82 | ## WP5
83 | wp1.pose.position.x = 6.9542160447
84 | wp1.pose.position.y = 7.47259858989
85 | wp1.pose.position.z = 0.36011276478
86 |
87 | wp1.pose.orientation.x = -0.000672673033611
88 | wp1.pose.orientation.y = -0.00533124213512
89 | wp1.pose.orientation.z = -0.585323444295
90 | wp1.pose.orientation.w = -0.810781978347
91 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
92 |
93 | wp1_transformed_st = PoseWithCovarianceStamped()
94 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
95 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
96 |
97 | pose_tf.publish(wp1_transformed_st)
98 | time.sleep(1)
99 | print "wp 5"
100 |
101 |
102 | ## WP6
103 | wp1.pose.position.x = 0.776374921509
104 | wp1.pose.position.y = 3.66423974718
105 | wp1.pose.position.z = 0.389573285844
106 |
107 | wp1.pose.orientation.x = 0.000283530799746
108 | wp1.pose.orientation.y = -0.00341586477001
109 | wp1.pose.orientation.z = -0.961037223533
110 | wp1.pose.orientation.w = 0.276394572148
111 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
112 |
113 | wp1_transformed_st = PoseWithCovarianceStamped()
114 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
115 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
116 |
117 | pose_tf.publish(wp1_transformed_st)
118 | time.sleep(1)
119 | print "wp 6"
120 |
121 | ## WP7
122 | wp1.pose.position.x = -0.132179206119
123 | wp1.pose.position.y = 6.05237869124
124 | wp1.pose.position.z = 0.386123696176
125 |
126 | wp1.pose.orientation.x = -0.00189409887785
127 | wp1.pose.orientation.y = -0.0067007693862
128 | wp1.pose.orientation.z = -0.97150126787
129 | wp1.pose.orientation.w = -0.236930474742
130 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
131 |
132 | wp1_transformed_st = PoseWithCovarianceStamped()
133 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
134 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
135 |
136 | pose_tf.publish(wp1_transformed_st)
137 | time.sleep(1)
138 | print "wp 7"
139 |
140 |
141 |
142 | ## WP8
143 | wp1.pose.position.x = -2.80205473105
144 | wp1.pose.position.y = 1.68235251603
145 | wp1.pose.position.z = 0.405481320111
146 |
147 | wp1.pose.orientation.x = 0.00676155918898
148 | wp1.pose.orientation.y = 0.000718424039614
149 | wp1.pose.orientation.z = -0.607098149908
150 | wp1.pose.orientation.w = 0.794597732245
151 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
152 |
153 | wp1_transformed_st = PoseWithCovarianceStamped()
154 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
155 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
156 |
157 | pose_tf.publish(wp1_transformed_st)
158 | time.sleep(5)
159 | print "wp 8"
160 |
161 |
162 | ## WP1
163 |
164 | wp1.pose.position.x = -1.95693401441
165 | wp1.pose.position.y = -1.87900204426
166 | wp1.pose.position.z = 0.405331625728
167 |
168 | wp1.pose.orientation.x = 0.000190102473902
169 | wp1.pose.orientation.y = 0.00258721671434
170 | wp1.pose.orientation.z = 0.727793822143
171 | wp1.pose.orientation.w = -0.685791071677
172 | wp1_transformed = tf2_geometry_msgs.do_transform_pose(wp1, trans)
173 |
174 | wp1_transformed_st = PoseWithCovarianceStamped()
175 | wp1_transformed_st.pose.pose.position = wp1_transformed.pose.position
176 | wp1_transformed_st.pose.pose.orientation = wp1_transformed.pose.orientation
177 |
178 | pose_tf.publish(wp1_transformed_st)
179 | time.sleep(1)
180 | print "wp 1"
181 |
182 |
--------------------------------------------------------------------------------
/pose_tf/scripts/waypoints-old.txt:
--------------------------------------------------------------------------------
1 | 3.44670044033,0.822950858839,0.357066167542,0.00871913080208,-0.00184221603754,0.999943740129,-0.00574397921145
2 |
3 |
4 |
--------------------------------------------------------------------------------
/pose_tf/scripts/waypoints.txt:
--------------------------------------------------------------------------------
1 | 6.45013341991,7.45609351233,0.341357841999,-0.00372010407558,-0.0015018882385,-0.640923373862,-0.767594362291
2 | 6.45013341991,7.45609351233,0.341357841999,-0.00372010407558,-0.0015018882385,-0.640923373862,-0.767594362291
3 |
--------------------------------------------------------------------------------
/vis_marker/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vis_marker)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | roscpp
12 | rospy
13 | std_msgs
14 | nav_msgs
15 | tf2_ros
16 | visualization_msgs
17 | geometry_msgs
18 | sensor_msgs
19 | cv_bridge
20 | image_transport
21 | )
22 |
23 | find_package(OpenCV REQUIRED)
24 |
25 | ## System dependencies are found with CMake's conventions
26 | # find_package(Boost REQUIRED COMPONENTS system)
27 |
28 |
29 | ## Uncomment this if the package has a setup.py. This macro ensures
30 | ## modules and global scripts declared therein get installed
31 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
32 | # catkin_python_setup()
33 |
34 | ################################################
35 | ## Declare ROS messages, services and actions ##
36 | ################################################
37 |
38 | ## To declare and build messages, services or actions from within this
39 | ## package, follow these steps:
40 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
41 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
42 | ## * In the file package.xml:
43 | ## * add a build_depend tag for "message_generation"
44 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
45 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
46 | ## but can be declared for certainty nonetheless:
47 | ## * add a exec_depend tag for "message_runtime"
48 | ## * In this file (CMakeLists.txt):
49 | ## * add "message_generation" and every package in MSG_DEP_SET to
50 | ## find_package(catkin REQUIRED COMPONENTS ...)
51 | ## * add "message_runtime" and every package in MSG_DEP_SET to
52 | ## catkin_package(CATKIN_DEPENDS ...)
53 | ## * uncomment the add_*_files sections below as needed
54 | ## and list every .msg/.srv/.action file to be processed
55 | ## * uncomment the generate_messages entry below
56 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
57 |
58 | ## Generate messages in the 'msg' folder
59 | # add_message_files(
60 | # FILES
61 | # Message1.msg
62 | # Message2.msg
63 | # )
64 |
65 | ## Generate services in the 'srv' folder
66 | # add_service_files(
67 | # FILES
68 | # Service1.srv
69 | # Service2.srv
70 | # )
71 |
72 | ## Generate actions in the 'action' folder
73 | # add_action_files(
74 | # FILES
75 | # Action1.action
76 | # Action2.action
77 | # )
78 |
79 | ## Generate added messages and services with any dependencies listed here
80 | # generate_messages(
81 | # DEPENDENCIES
82 | # std_msgs# visualization_msgs
83 | # )
84 |
85 | ################################################
86 | ## Declare ROS dynamic reconfigure parameters ##
87 | ################################################
88 |
89 | ## To declare and build dynamic reconfigure parameters within this
90 | ## package, follow these steps:
91 | ## * In the file package.xml:
92 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
93 | ## * In this file (CMakeLists.txt):
94 | ## * add "dynamic_reconfigure" to
95 | ## find_package(catkin REQUIRED COMPONENTS ...)
96 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
97 | ## and list every .cfg file to be processed
98 |
99 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
100 | # generate_dynamic_reconfigure_options(
101 | # cfg/DynReconf1.cfg
102 | # cfg/DynReconf2.cfg
103 | # )
104 |
105 | ###################################
106 | ## catkin specific configuration ##
107 | ###################################
108 | ## The catkin_package macro generates cmake config files for your package
109 | ## Declare things to be passed to dependent projects
110 | ## INCLUDE_DIRS: uncomment this if your package contains header files
111 | ## LIBRARIES: libraries you create in this project that dependent projects also need
112 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
113 | ## DEPENDS: system dependencies of this project that dependent projects also need
114 | catkin_package(
115 | # INCLUDE_DIRS include
116 | # LIBRARIES vis_marker
117 | # CATKIN_DEPENDS roscpp rospy std_msgs visualization_msgs
118 | # DEPENDS system_lib
119 | )
120 |
121 | ###########
122 | ## Build ##
123 | ###########
124 |
125 | ## Specify additional locations of header files
126 | ## Your package locations should be listed before other locations
127 | include_directories(
128 | include ${catkin_INCLUDE_DIRS}
129 | # include
130 | ${catkin_INCLUDE_DIRS}
131 | )
132 |
133 | ## Declare a C++ library
134 | # add_library(${PROJECT_NAME}
135 | # src/${PROJECT_NAME}/vis_marker.cpp
136 | # )
137 |
138 | ## Add cmake target dependencies of the library
139 | ## as an example, code may need to be generated before libraries
140 | ## either from message generation or dynamic reconfigure
141 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
142 |
143 | ## Declare a C++ executable
144 | ## With catkin_make all packages are built within a single CMake context
145 | ## The recommended prefix ensures that target names across packages don't collide
146 | # add_executable(${PROJECT_NAME}_node src/vis_marker_node.cpp)
147 |
148 | ## Rename C++ executable without prefix
149 | ## The above recommended prefix causes long target names, the following renames the
150 | ## target back to the shorter version for ease of user use
151 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
152 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
153 |
154 | ## Add cmake target dependencies of the executable
155 | ## same as for the library above
156 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
157 |
158 | ## Specify libraries to link a library or executable target against
159 | # target_link_libraries(${PROJECT_NAME}_node
160 | # ${catkin_LIBRARIES}
161 | # )
162 |
163 | #############
164 | ## Install ##
165 | #############
166 |
167 | # all install targets should use catkin DESTINATION variables
168 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
169 |
170 | ## Mark executable scripts (Python etc.) for installation
171 | ## in contrast to setup.py, you can choose the destination
172 | # install(PROGRAMS
173 | # scripts/my_python_script
174 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
175 | # )
176 |
177 | ## Mark executables and/or libraries for installation
178 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
179 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
180 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
181 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
182 | # )
183 |
184 | ## Mark cpp header files for installation
185 | # install(DIRECTORY include/${PROJECT_NAME}/
186 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
187 | # FILES_MATCHING PATTERN "*.h"
188 | # PATTERN ".svn" EXCLUDE
189 | # )
190 |
191 | ## Mark other files for installation (e.g. launch and bag files, etc.)
192 | # install(FILES
193 | # # myfile1
194 | # # myfile2
195 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
196 | # )
197 |
198 | #############
199 | ## Testing ##
200 | #############
201 |
202 | ## Add gtest based cpp test target and link libraries
203 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_vis_marker.cpp)
204 | # if(TARGET ${PROJECT_NAME}-test)
205 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
206 | # endif()
207 |
208 | ## Add folders to be run by python nosetests
209 | # catkin_add_nosetests(test)
210 |
211 |
212 | add_executable(err_mark_show
213 | src/err_mark_show.cpp
214 | )
215 | target_link_libraries(err_mark_show
216 | ${catkin_LIBRARIES}
217 | )
218 |
219 | add_executable(fake_path_show
220 | src/fake_path_show.cpp
221 | )
222 | target_link_libraries(fake_path_show
223 | ${catkin_LIBRARIES}
224 | )
225 |
226 | add_executable(record_fake_points
227 | src/record_fake_points.cpp)
228 | target_link_libraries(record_fake_points
229 | ${catkin_LIBRARIES}
230 | ${OpenCV_LIBS})
231 |
232 | add_executable(husky_mark_show
233 | src/husky_mark_show.cpp)
234 | target_link_libraries(husky_mark_show
235 | ${catkin_LIBRARIES})
236 |
237 |
238 | add_executable(vo_mark_show
239 | src/vo_mark_show.cpp)
240 | target_link_libraries(vo_mark_show
241 | ${catkin_LIBRARIES})
242 |
243 | add_executable(husky_err_calc
244 | src/husky_err_calc.cpp)
245 | target_link_libraries(husky_err_calc
246 | ${catkin_LIBRARIES})
--------------------------------------------------------------------------------
/vis_marker/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | vis_marker
4 | 0.0.0
5 | The vis_marker package
6 |
7 |
8 |
9 |
10 | wang
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | roscpp
53 | rospy
54 | std_msgs
55 | visualization_msgs
56 | roscpp
57 | rospy
58 | std_msgs
59 | visualization_msgs
60 | roscpp
61 | rospy
62 | std_msgs
63 | visualization_msgs
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/vis_marker/script/show_err_msg.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 |
4 | import sys
5 | import numpy as np
6 | import cv2
7 | from PIL import Image, ImageFont, ImageDraw
8 |
9 | import rospy
10 | from std_msgs.msg import Float32MultiArray
11 | from cv_bridge import CvBridge, CvBridgeError
12 | from sensor_msgs.msg import Image as sensorImg
13 |
14 |
15 |
16 | class ERRIMG:
17 | def __init__(self):
18 | self.bridge_ = CvBridge()
19 | self.errSub_ = rospy.Subscriber("/eval_show", Float32MultiArray, self.callback)
20 | self.husky_img_pub_ = rospy.Publisher("husky_img", sensorImg, queue_size=1)
21 | self.vo_img_pub_ = rospy.Publisher("vo_img", sensorImg, queue_size=1)
22 |
23 | def callback(self, msg):
24 | husky_img_title = "导航定位实时测试系统"
25 | slamtec_img_title = "视觉里程计实时测试系统"
26 | amcl_err = "实时定位误差: {0:.2f}".format(msg.data[0]) + " m"
27 | current_speed_x = "前进速度: {0:.2f}".format(msg.data[2]) + " m/s"
28 | current_speed_th = "转向速度: {0:.2f}".format(msg.data[3]) + " m/s"
29 |
30 | vo_title = "视觉定位实时测试系统"
31 | vo_err = "实时误差: {0:.2f}".format(msg.data[4]) + " m"
32 | vo_max_err = "最大误差: {0:.2f}".format(msg.data[5]) + " m"
33 | vo_min_err = "最小误差: {0:.2f}".format(msg.data[6]) + " m"
34 | vo_mean_err = "平均误差: {0:.2f}".format(msg.data[7]) + " m"
35 |
36 | husky_img = Image.new(mode="RGB", size=(300, 120))
37 | title_font = ImageFont.truetype('/home/sirius/.local/share/fonts/simsun.ttc', size=20)
38 | font = ImageFont.truetype('/home/sirius/.local/share/fonts/simsun.ttc', size=18)
39 | draw = ImageDraw.Draw(husky_img)
40 | draw.text((10, 5), unicode(husky_img_title, 'UTF-8'), font=title_font, fill=(255, 255, 255, 0))
41 | draw.text((10, 50), unicode(amcl_err, 'UTF-8'), font=font, fill=(0, 255, 255, 0))
42 | draw.text((10, 70), unicode(current_speed_x, 'UTF-8'), font=font, fill=(255, 255, 255, 0))
43 | draw.text((10, 90), unicode(current_speed_th, 'UTF-8'), font=font, fill=(255, 255, 255, 0))
44 | img = np.array(husky_img)
45 |
46 | vo_img = Image.new(mode="RGB", size=(300, 150))
47 | draw = ImageDraw.Draw(vo_img)
48 | draw.text((10, 5), unicode(vo_title, 'UTF-8'), font=title_font, fill=(255, 255, 255, 0))
49 | draw.text((10, 50), unicode(vo_err, 'UTF-8'), font=font, fill=(0, 255, 255, 0))
50 | draw.text((10, 70), unicode(vo_max_err, 'UTF-8'), font=font, fill=(255, 255, 255, 0))
51 | draw.text((10, 90), unicode(vo_min_err, 'UTF-8'), font=font, fill=(255, 255, 255, 0))
52 | draw.text((10, 110), unicode(vo_mean_err, 'UTF-8'), font=font, fill=(255, 255, 255, 0))
53 | img2 = np.array(vo_img)
54 |
55 | try :
56 | self.husky_img_pub_.publish(self.bridge_.cv2_to_imgmsg(img, 'bgr8'))
57 | self.vo_img_pub_.publish(self.bridge_.cv2_to_imgmsg(img2, 'bgr8'))
58 | except CvBridgeError as e:
59 | print e
60 |
61 |
62 | if __name__ == '__main__':
63 | rospy.init_node("err_msg_display", anonymous=True)
64 | errImg = ERRIMG()
65 | while not rospy.is_shutdown():
66 | rospy.spin()
67 | rospy.sleep(0.02)
68 |
--------------------------------------------------------------------------------
/vis_marker/src/err_mark_show.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-9-27.
3 | //
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | class ERR_MARK_SHOW
17 | {
18 | public:
19 | ERR_MARK_SHOW(ros::NodeHandle nh) : nh_(nh), husky_dist_(0), vo_max_err_(0.0), vo_min_err_(10000.0), vo_mean_err_(0.0)
20 | {
21 | tfBuffer_ = new tf2_ros::Buffer;
22 | tfListener_ = new tf2_ros::TransformListener(*tfBuffer_);
23 | slamTec_pub_ = nh_.advertise("slamtec_mark", 1);
24 | husky_pub_ = nh_.advertise("husky_mark", 1);
25 | vo_pub_ = nh_.advertise("vo_mark", 1);
26 | amcl_pub_ = nh_.advertise ("amcl_mark", 1);
27 |
28 | err_pub_ = nh_.advertise("eval_show", 2);
29 | odom_sub_ = nh_.subscribe("/odometry/filtered", 5, &ERR_MARK_SHOW::odomCb, this);
30 | lastHuskyPosition_.resize(2);
31 | lastSlamtecPosition_.resize(2);
32 | MarkInit();
33 | }
34 | void MarkInit()
35 | {
36 | slamtec.ns = "slamtec_body";
37 | slamtec.action = visualization_msgs::Marker::ADD;
38 | slamtec.type = visualization_msgs::Marker::CYLINDER;
39 | slamtec.scale.x = 0.6;
40 | slamtec.scale.y = 0.6;
41 | slamtec.scale.z = 0.6;
42 | slamtec.color.r = 1.0;
43 | slamtec.color.g = 1.0;
44 | slamtec.color.b = 1.0;
45 | slamtec.color.a = 1.0;
46 |
47 | slamtecRTSTraj_.ns = "slamtec_traj";
48 | slamtecRTSTraj_.action = visualization_msgs::Marker::ADD;
49 | slamtecRTSTraj_.type = visualization_msgs::Marker::LINE_STRIP;
50 | slamtecRTSTraj_.scale.x = 0.1;
51 | slamtecRTSTraj_.scale.y = 0.1;
52 | slamtecRTSTraj_.scale.z = 0.1;
53 | slamtecRTSTraj_.color.g = 0.3;
54 | slamtecRTSTraj_.color.a = 1.0;
55 |
56 | huskyRTSTraj_.ns = "husky_traj";
57 | huskyRTSTraj_.action = visualization_msgs::Marker::ADD;
58 | huskyRTSTraj_.type = visualization_msgs::Marker::LINE_STRIP;
59 | huskyRTSTraj_.scale.x = 0.1;
60 | huskyRTSTraj_.scale.y = 0.1;
61 | huskyRTSTraj_.scale.z = 0.1;
62 | huskyRTSTraj_.color.g = 0.3;
63 | huskyRTSTraj_.color.a = 1.0;
64 |
65 | voTraj_.ns = "vo";
66 | voTraj_.action = visualization_msgs::Marker::ADD;
67 | voTraj_.type = visualization_msgs::Marker::LINE_STRIP;
68 | voTraj_.scale.x = 0.05;
69 | voTraj_.scale.y = 0.05;
70 | voTraj_.scale.z = 0.05;
71 | voTraj_.color.b = 0.62;
72 | voTraj_.color.g = 0.28;
73 | voTraj_.color.r = 0.43;
74 | voTraj_.color.a = 1.0;
75 |
76 | amclTraj_.ns = "amcl";
77 | amclTraj_.action = visualization_msgs::Marker::ADD;
78 | amclTraj_.type = visualization_msgs::Marker::LINE_STRIP;
79 | amclTraj_.scale.x = 0.05;
80 | amclTraj_.scale.y = 0.05;
81 | amclTraj_.scale.z = 0.05;
82 | amclTraj_.color.r = 0.16;
83 | amclTraj_.color.g = 0.4;
84 | amclTraj_.color.b = 0.47;
85 | amclTraj_.color.a = 1.0;
86 | }
87 |
88 | void listenTF()
89 | {
90 | huskyRTSStamped_ = tfBuffer_->lookupTransform("world", "husky", ros::Time(0), ros::Duration(1.0));
91 | slamTecStamped_ = tfBuffer_->lookupTransform("world", "slamtec", ros::Time(0), ros::Duration(1.0));
92 | huskyStamped_ = tfBuffer_->lookupTransform("world", "base_link", ros::Time(0), ros::Duration(1.0));
93 | voStamped_ = tfBuffer_->lookupTransform("world", "vo", ros::Time(0), ros::Duration(1.0));
94 | pubSlamtec();
95 | pubSlamTecTraj();
96 | pubHuskyTraj();
97 | pubVoTraj();
98 | pubAmclTraj();
99 | calcDist();
100 | }
101 |
102 | void pubSlamtec()
103 | {
104 | slamtec.header.frame_id = "world";
105 | slamtec.header.stamp = ros::Time::now();
106 | // slamtec.pose.position.x = slamTecStamped_.transform.translation.x;
107 | // slamtec.pose.position.y = slamTecStamped_.transform.translation.y;
108 | // slamtec.pose.position.z = slamTecStamped_.transform.translation.z;
109 | slamtec.pose.position.x = voStamped_.transform.translation.x;
110 | slamtec.pose.position.y = voStamped_.transform.translation.y;
111 | slamtec.pose.position.z = voStamped_.transform.translation.z;
112 | slamtec.pose.orientation.w = 1.0;
113 | slamTec_pub_.publish(slamtec);
114 | }
115 |
116 | void pubSlamTecTraj()
117 | {
118 | slamtecRTSTraj_.header.frame_id = "world";
119 | slamtecRTSTraj_.header.stamp = ros::Time::now();
120 | geometry_msgs::Point p;
121 | p.x = slamTecStamped_.transform.translation.x;
122 | p.y = slamTecStamped_.transform.translation.y;
123 | p.z = slamTecStamped_.transform.translation.z;
124 | if (abs(p.x-lastSlamtecPosition_[0])>0.2 || abs(p.y-lastSlamtecPosition_[1])>0.2)
125 | return;
126 | slamtecRTSTraj_.points.push_back(p);
127 | if (slamtecRTSTraj_.points.size() > 900)
128 | slamtecRTSTraj_.points.erase(slamtecRTSTraj_.points.begin());
129 | slamTec_pub_.publish(slamtecRTSTraj_);
130 | }
131 |
132 | void pubHuskyTraj()
133 | {
134 | huskyRTSTraj_.header.frame_id = "world";
135 | huskyRTSTraj_.header.stamp = ros::Time::now();
136 | geometry_msgs::Point p;
137 | p.x = huskyRTSStamped_.transform.translation.x;
138 | p.y = huskyRTSStamped_.transform.translation.y;
139 | huskyRTSTraj_.points.push_back(p);
140 | if (huskyRTSTraj_.points.size() > 300)
141 | huskyRTSTraj_.points.erase(huskyRTSTraj_.points.begin());
142 | husky_pub_.publish(huskyRTSTraj_);
143 | }
144 |
145 | void pubVoTraj()
146 | {
147 | voTraj_.header.frame_id = "world";
148 | voTraj_.header.stamp = ros::Time::now();
149 | geometry_msgs::Point p;
150 | p.x = voStamped_.transform.translation.x;
151 | p.y = voStamped_.transform.translation.y;
152 | p.z = voStamped_.transform.translation.z;
153 | voTraj_.points.push_back(p);
154 | if (voTraj_.points.size() > 900)
155 | voTraj_.points.erase(voTraj_.points.begin());
156 | vo_pub_.publish(voTraj_);
157 | }
158 |
159 | void pubAmclTraj()
160 | {
161 | amclTraj_.header.frame_id = "world";
162 | amclTraj_.header.stamp = ros::Time::now();
163 | geometry_msgs::Point p;
164 | p.x = huskyStamped_.transform.translation.x;
165 | p.y = huskyStamped_.transform.translation.y;
166 | amclTraj_.points.push_back(p);
167 | if (amclTraj_.points.size() > 300)
168 | amclTraj_.points.erase(amclTraj_.points.begin());
169 | amcl_pub_.publish(amclTraj_);
170 | }
171 |
172 | void calcPubErr()
173 | {
174 | std_msgs::Float32MultiArray arr;
175 |
176 | float base_link_x = huskyStamped_.transform.translation.x;
177 | float base_link_y = huskyStamped_.transform.translation.y;
178 | float husky_RTS_x = huskyRTSStamped_.transform.translation.x;
179 | float husky_RTS_y = huskyRTSStamped_.transform.translation.y;
180 | husky_amcl_err_ = sqrt((base_link_x-husky_RTS_x)*(base_link_x-husky_RTS_x) + (base_link_y-husky_RTS_y)*(base_link_y-husky_RTS_y));
181 |
182 | float slamtec_x = slamTecStamped_.transform.translation.x;
183 | float slamtec_y = slamTecStamped_.transform.translation.y;
184 | float slamtec_z = slamTecStamped_.transform.translation.z;
185 |
186 | if(voStamped_.transform.translation.x==0 && voStamped_.transform.translation.y==0 && voStamped_.transform.translation.z==0)
187 | vo_err_ = -1;
188 | else
189 | {
190 | vo_err_ = sqrt(pow((slamtec_x-voStamped_.transform.translation.x), 2)+
191 | pow((slamtec_y- voStamped_.transform.translation.y), 2)+
192 | pow((slamtec_z - voStamped_.transform.translation.z), 2));
193 | }
194 | if (vo_err_ > vo_max_err_)
195 | vo_max_err_ = vo_err_;
196 | if (vo_err_ < vo_min_err_)
197 | vo_min_err_ = vo_err_;
198 |
199 | vo_mean_err_ = vo_mean_err_*vo_err_count_/(vo_err_count_+1) + vo_err_/(vo_err_count_ + 1);
200 | vo_err_count_++;
201 |
202 |
203 | arr.data.clear();
204 | arr.data.push_back(husky_amcl_err_);
205 | arr.data.push_back(husky_amcl_err_/husky_dist_);
206 | arr.data.push_back(husky_vx_);
207 | arr.data.push_back(husky_vth_);
208 | arr.data.push_back(vo_err_);
209 | arr.data.push_back(vo_max_err_);
210 | arr.data.push_back(vo_min_err_);
211 | arr.data.push_back(vo_mean_err_);
212 | err_pub_.publish(arr);
213 | }
214 |
215 | void odomCb(nav_msgs::Odometry msg)
216 | {
217 | husky_vx_ = msg.twist.twist.linear.x;
218 | husky_vth_ = msg.twist.twist.angular.z;
219 | }
220 |
221 | void calcDist()
222 | {
223 | // husky
224 | if(lastHuskyPosition_[0] ==0 || lastHuskyPosition_[1] ==0)
225 | {
226 | lastHuskyPosition_[0] = huskyRTSStamped_.transform.translation.x;
227 | lastHuskyPosition_[1] = huskyRTSStamped_.transform.translation.y;
228 | }
229 | husky_dist_ += sqrt(pow((huskyRTSStamped_.transform.translation.x - lastHuskyPosition_[0]), 2) + pow((huskyRTSStamped_.transform.translation.y - lastHuskyPosition_[1]), 2));
230 | lastHuskyPosition_[0] = huskyRTSStamped_.transform.translation.x;
231 | lastHuskyPosition_[1] = huskyRTSStamped_.transform.translation.y;
232 | lastSlamtecPosition_[0] = slamTecStamped_.transform.translation.x;
233 | lastSlamtecPosition_[1] = slamTecStamped_.transform.translation.y;
234 | }
235 |
236 | private:
237 | ros::NodeHandle nh_;
238 | ros::Publisher slamTec_pub_;
239 | ros::Publisher husky_pub_;
240 | // husky amdl publisher
241 | ros::Publisher amcl_pub_;
242 | ros::Publisher vo_pub_;
243 | ros::Publisher err_pub_;
244 | ros::Subscriber odom_sub_;
245 | tf2_ros::Buffer* tfBuffer_;
246 | tf2_ros::TransformListener* tfListener_;
247 |
248 | // husky amcl location
249 | geometry_msgs::TransformStamped huskyStamped_;
250 | // rts location
251 | geometry_msgs::TransformStamped slamTecStamped_;
252 | geometry_msgs::TransformStamped huskyRTSStamped_;
253 | // vo location
254 | geometry_msgs::TransformStamped voStamped_;
255 |
256 | std::vector lastSlamtecPosition_;
257 | std::vector lastHuskyPosition_;
258 | visualization_msgs::Marker slamtec;
259 | visualization_msgs::Marker slamtecRTSTraj_;
260 | visualization_msgs::Marker huskyRTSTraj_;
261 | visualization_msgs::Marker voTraj_;
262 | visualization_msgs::Marker amclTraj_;
263 |
264 | double husky_dist_;
265 |
266 | float husky_amcl_err_;
267 | float vo_err_;
268 | float vo_max_err_;
269 | float vo_min_err_;
270 | float vo_mean_err_;
271 | long int vo_err_count_;
272 | float husky_vx_;
273 | float husky_vth_;
274 | };
275 |
276 | int main(int argc, char** argv)
277 | {
278 | ros::init(argc, argv, "show");
279 | ros::NodeHandle nh;
280 | ERR_MARK_SHOW err_mark_show(nh);
281 | ros::Rate rate(10);
282 | while (ros::ok())
283 | {
284 | err_mark_show.listenTF();
285 | err_mark_show.calcPubErr();
286 | ros::spinOnce();
287 | rate.sleep();
288 | }
289 | }
290 |
--------------------------------------------------------------------------------
/vis_marker/src/fake_path_show.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-10-10.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 |
13 | int main(int argc, char** argv)
14 | {
15 | ros::init(argc, argv, "temp");
16 | ros::NodeHandle nh;
17 | std::ifstream in("/home/sirius/ws/husky_ws/slamtecPoints.txt");
18 | ros::Publisher fakepath_pub = nh.advertise("slam", 1);
19 |
20 | visualization_msgs::Marker slamtecPlanTraj;
21 | slamtecPlanTraj.header.frame_id = "world";
22 | slamtecPlanTraj.ns = "slamtec_plan";
23 | slamtecPlanTraj.action = visualization_msgs::Marker::ADD;
24 | slamtecPlanTraj.type = visualization_msgs::Marker::LINE_STRIP;
25 | slamtecPlanTraj.scale.x = 0.05;
26 | slamtecPlanTraj.scale.y = 0.05;
27 | slamtecPlanTraj.scale.z = 0.05;
28 | slamtecPlanTraj.color.r = 1.0;
29 | slamtecPlanTraj.color.g = 1.0;
30 | slamtecPlanTraj.color.a = 1.0;
31 |
32 | geometry_msgs::TransformStamped slamtecPoints;
33 | float x, y;
34 | while (
35 | in >> x &&
36 | in >> y
37 | )
38 | {
39 | geometry_msgs::Point p;
40 | p.x = x;
41 | p.y = y;
42 | slamtecPlanTraj.points.push_back(p);
43 | }
44 | in.close();
45 |
46 | ros::Rate rate(10.0);
47 | while(ros::ok())
48 | {
49 | fakepath_pub.publish(slamtecPlanTraj);
50 | rate.sleep();
51 | }
52 | }
--------------------------------------------------------------------------------
/vis_marker/src/husky_err_calc.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-12-12.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 | #include
15 |
16 |
17 | class ERR_MARK_SHOW
18 | {
19 | public:
20 | ERR_MARK_SHOW(ros::NodeHandle nh) : nh_(nh), husky_dist_(0)
21 | {
22 | tfBuffer_ = new tf2_ros::Buffer;
23 | tfListener_ = new tf2_ros::TransformListener(*tfBuffer_);
24 |
25 | err_pub_ = nh_.advertise("err_calc", 2);
26 | odom_sub_ = nh_.subscribe("/odometry/filtered", 5, &ERR_MARK_SHOW::odomCb, this);
27 |
28 | }
29 |
30 | void listenTF()
31 | {
32 | try {
33 | huskyRTSStamped_ = tfBuffer_->lookupTransform("world", "husky", ros::Time(0), ros::Duration(1.0));
34 | }
35 | catch (tf2::TransformException &ex)
36 | {
37 | ROS_WARN("%s", ex.what());
38 | return;
39 | }
40 | try {
41 | huskyStamped_ = tfBuffer_->lookupTransform("world", "base_link", ros::Time(0), ros::Duration(1.0));
42 | }
43 | catch (tf2::TransformException &ex)
44 | {
45 | ROS_WARN("%s", ex.what());
46 | return;
47 | }
48 | }
49 |
50 |
51 | void calcPubErr()
52 | {
53 | std_msgs::Float32MultiArray arr;
54 |
55 | float base_link_x = huskyStamped_.transform.translation.x;
56 | float base_link_y = huskyStamped_.transform.translation.y;
57 | float husky_RTS_x = huskyRTSStamped_.transform.translation.x;
58 | float husky_RTS_y = huskyRTSStamped_.transform.translation.y;
59 | husky_amcl_err_ = sqrt((base_link_x-husky_RTS_x)*(base_link_x-husky_RTS_x) + (base_link_y-husky_RTS_y)*(base_link_y-husky_RTS_y));
60 |
61 | arr.data.clear();
62 | arr.data.push_back(husky_amcl_err_);
63 | arr.data.push_back(husky_vx_);
64 | arr.data.push_back(husky_vth_);
65 | arr.data.push_back(huskyStamped_.transform.translation.x);
66 | arr.data.push_back(huskyStamped_.transform.translation.y);
67 | arr.data.push_back(huskyStamped_.transform.rotation.x);
68 | arr.data.push_back(huskyStamped_.transform.rotation.y);
69 | arr.data.push_back(huskyStamped_.transform.rotation.z);
70 | arr.data.push_back(huskyStamped_.transform.rotation.w);
71 | arr.data.push_back(huskyRTSStamped_.transform.translation.x);
72 | arr.data.push_back(huskyRTSStamped_.transform.translation.y);
73 | err_pub_.publish(arr);
74 | }
75 |
76 | void odomCb(nav_msgs::Odometry msg)
77 | {
78 | husky_vx_ = msg.twist.twist.linear.x;
79 | husky_vth_ = msg.twist.twist.angular.z;
80 | }
81 |
82 |
83 | private:
84 | ros::NodeHandle nh_;
85 | ros::Publisher err_pub_;
86 | ros::Subscriber odom_sub_;
87 | tf2_ros::Buffer* tfBuffer_;
88 | tf2_ros::TransformListener* tfListener_;
89 |
90 | // husky amcl location
91 | geometry_msgs::TransformStamped huskyStamped_;
92 | // rts location
93 | geometry_msgs::TransformStamped huskyRTSStamped_;
94 |
95 | std::vector lastHuskyPosition_;
96 |
97 | double husky_dist_;
98 |
99 | float husky_amcl_err_;
100 | float husky_vx_;
101 | float husky_vth_;
102 | };
103 |
104 | int main(int argc, char** argv)
105 | {
106 | ros::init(argc, argv, "husky_calc");
107 | ros::NodeHandle nh;
108 | ERR_MARK_SHOW err_mark_show(nh);
109 | ros::Rate rate(10);
110 | while (ros::ok())
111 | {
112 | err_mark_show.listenTF();
113 | err_mark_show.calcPubErr();
114 | ros::spinOnce();
115 | rate.sleep();
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/vis_marker/src/husky_mark_show.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-9-27.
3 | //
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | class ERR_MARK_SHOW
17 | {
18 | public:
19 | ERR_MARK_SHOW(ros::NodeHandle nh) : nh_(nh), husky_dist_(0)
20 | {
21 | husky_pub_ = nh_.advertise("husky_mark", 1);
22 | amcl_pub_ = nh_.advertise ("amcl_mark", 1);
23 | husky_err_sub_ = nh_.subscribe("/husky_err", 1, &ERR_MARK_SHOW::errCb, this);
24 |
25 | MarkInit();
26 | }
27 |
28 | void errCb(std_msgs::Float32MultiArray msg)
29 | {
30 | huskyStamped_.transform.translation.x = msg.data[3];
31 | huskyStamped_.transform.translation.y = msg.data[4];
32 | huskyStamped_.transform.rotation.x = msg.data[5];
33 | huskyStamped_.transform.rotation.y = msg.data[6];
34 | huskyStamped_.transform.rotation.z = msg.data[7];
35 | huskyStamped_.transform.rotation.w = msg.data[8];
36 | huskyRTSStamped_.transform.translation.x = msg.data[9];
37 | huskyRTSStamped_.transform.translation.y = msg.data[10];
38 | }
39 |
40 | void MarkInit()
41 | {
42 | husky.ns = "husky_body";
43 | husky.action = visualization_msgs::Marker::ADD;
44 | husky.type = visualization_msgs::Marker::CUBE;
45 | husky.scale.x = 0.6;
46 | husky.scale.y = 0.6;
47 | husky.scale.z = 0.6;
48 | husky.color.r = 0.97;
49 | husky.color.g = 0.8;
50 | husky.color.b = 0.0;
51 | husky.color.a = 1.0;
52 |
53 |
54 | huskyRTSTraj_.ns = "husky_traj";
55 | huskyRTSTraj_.action = visualization_msgs::Marker::ADD;
56 | huskyRTSTraj_.type = visualization_msgs::Marker::LINE_STRIP;
57 | huskyRTSTraj_.scale.x = 0.1;
58 | huskyRTSTraj_.scale.y = 0.1;
59 | huskyRTSTraj_.scale.z = 0.1;
60 | huskyRTSTraj_.color.g = 0.3;
61 | huskyRTSTraj_.color.a = 1.0;
62 |
63 |
64 | amclTraj_.ns = "amcl";
65 | amclTraj_.action = visualization_msgs::Marker::ADD;
66 | amclTraj_.type = visualization_msgs::Marker::LINE_STRIP;
67 | amclTraj_.scale.x = 0.05;
68 | amclTraj_.scale.y = 0.05;
69 | amclTraj_.scale.z = 0.05;
70 | amclTraj_.color.r = 0.16;
71 | amclTraj_.color.g = 0.4;
72 | amclTraj_.color.b = 0.47;
73 | amclTraj_.color.a = 1.0;
74 | }
75 |
76 | void pubHuskyMark()
77 | {
78 | pubHusky();
79 | pubHuskyTraj();
80 | pubAmclTraj();
81 | }
82 |
83 | void pubHusky()
84 | {
85 | husky.header.frame_id = "world";
86 | husky.header.stamp = ros::Time::now();
87 | husky.pose.position.x = huskyStamped_.transform.translation.x;
88 | husky.pose.position.y = huskyStamped_.transform.translation.y;
89 | husky.pose.position.z = huskyStamped_.transform.translation.z;
90 | husky.pose.orientation.x = huskyStamped_.transform.rotation.x;
91 | husky.pose.orientation.y = huskyStamped_.transform.rotation.y;
92 | husky.pose.orientation.z = huskyStamped_.transform.rotation.z;
93 | husky.pose.orientation.w = huskyStamped_.transform.rotation.w;
94 | husky_pub_.publish(husky);
95 | }
96 |
97 |
98 | void pubHuskyTraj()
99 | {
100 | huskyRTSTraj_.header.frame_id = "world";
101 | huskyRTSTraj_.header.stamp = ros::Time::now();
102 | geometry_msgs::Point p;
103 | p.x = huskyRTSStamped_.transform.translation.x;
104 | p.y = huskyRTSStamped_.transform.translation.y;
105 | huskyRTSTraj_.points.push_back(p);
106 | if (huskyRTSTraj_.points.size() > 300)
107 | huskyRTSTraj_.points.erase(huskyRTSTraj_.points.begin());
108 | husky_pub_.publish(huskyRTSTraj_);
109 | }
110 |
111 |
112 | void pubAmclTraj()
113 | {
114 | amclTraj_.header.frame_id = "world";
115 | amclTraj_.header.stamp = ros::Time::now();
116 | geometry_msgs::Point p;
117 | p.x = huskyStamped_.transform.translation.x;
118 | p.y = huskyStamped_.transform.translation.y;
119 | amclTraj_.points.push_back(p);
120 | if (amclTraj_.points.size() > 300)
121 | amclTraj_.points.erase(amclTraj_.points.begin());
122 | amcl_pub_.publish(amclTraj_);
123 | }
124 |
125 |
126 |
127 | private:
128 | ros::NodeHandle nh_;
129 | ros::Publisher husky_pub_;
130 | // husky amcl publisher
131 | ros::Publisher amcl_pub_;
132 | ros::Publisher err_pub_;
133 | ros::Subscriber husky_err_sub_;
134 |
135 | // husky amcl location
136 | geometry_msgs::TransformStamped huskyStamped_;
137 | // rts location
138 | geometry_msgs::TransformStamped huskyRTSStamped_;
139 | // vo location
140 |
141 | visualization_msgs::Marker husky;
142 | visualization_msgs::Marker huskyRTSTraj_;
143 | visualization_msgs::Marker amclTraj_;
144 |
145 | double husky_dist_;
146 | float husky_amcl_err_;
147 | float husky_vx_;
148 | float husky_vth_;
149 | };
150 |
151 | int main(int argc, char** argv)
152 | {
153 | ros::init(argc, argv, "husky_show");
154 | ros::NodeHandle nh;
155 | ERR_MARK_SHOW err_mark_show(nh);
156 | ros::Rate rate(10);
157 | while (ros::ok())
158 | {
159 | err_mark_show.pubHuskyMark();
160 | ros::spinOnce();
161 | rate.sleep();
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/vis_marker/src/record_fake_points.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-10-10.
3 | //
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | int main(int argc, char** argv)
11 | {
12 | ros::init(argc, argv, "record_fake_points");
13 | tf2_ros::Buffer tfBuffer;
14 | tf2_ros::TransformListener tfListener(tfBuffer);
15 | ros::Rate rate(10.0);
16 |
17 | std::ofstream out;
18 | out.open("slamtecPoints.txt", std::ios_base::binary);
19 |
20 | std::cout << std::cin.get() << std::endl;
21 | while (ros::ok())
22 | {
23 | geometry_msgs::TransformStamped slamtecPoints;
24 | slamtecPoints = tfBuffer.lookupTransform("world", "slamtec", ros::Time(0), ros::Duration(1.0));
25 | out << slamtecPoints.transform.translation.x << "\n";
26 | out << slamtecPoints.transform.translation.y << "\n";
27 | // out << slamtecPoints.transform.translation.z << "\n";
28 | std::cout << "record" << std::cin.get() << std::endl;
29 | }
30 | out.close();
31 | }
--------------------------------------------------------------------------------
/vis_marker/src/vo_mark_show.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Created by wang on 18-9-27.
3 | //
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 | #include
14 |
15 |
16 | class ERR_MARK_SHOW
17 | {
18 | public:
19 | ERR_MARK_SHOW(ros::NodeHandle nh) : nh_(nh)
20 | {
21 | slamTec_pub_ = nh_.advertise("slamtec_mark", 1);
22 | vo_pub_ = nh_.advertise("vo_mark", 1);
23 | vo_err_sub_ = nh_.subscribe("/vo_err", 1, &ERR_MARK_SHOW::errCb, this);
24 |
25 | lastSlamtecPosition_.resize(2);
26 | MarkInit();
27 | }
28 |
29 | void errCb(std_msgs::Float32MultiArray msg)
30 | {
31 | voStamped_.transform.translation.x = msg.data[4];
32 | voStamped_.transform.translation.y = msg.data[5];
33 | voStamped_.transform.translation.z = msg.data[6];
34 | slamTecStamped_.transform.translation.x = msg.data[7];
35 | slamTecStamped_.transform.translation.y = msg.data[8];
36 | slamTecStamped_.transform.translation.z = msg.data[9];
37 | }
38 |
39 | void MarkInit()
40 | {
41 | slamtec.ns = "slamtec_body";
42 | slamtec.action = visualization_msgs::Marker::ADD;
43 | slamtec.type = visualization_msgs::Marker::CYLINDER;
44 | slamtec.scale.x = 0.6;
45 | slamtec.scale.y = 0.6;
46 | slamtec.scale.z = 0.6;
47 | slamtec.color.r = 1.0;
48 | slamtec.color.g = 1.0;
49 | slamtec.color.b = 1.0;
50 | slamtec.color.a = 1.0;
51 |
52 | slamtecRTSTraj_.ns = "slamtec_traj";
53 | slamtecRTSTraj_.action = visualization_msgs::Marker::ADD;
54 | slamtecRTSTraj_.type = visualization_msgs::Marker::LINE_STRIP;
55 | slamtecRTSTraj_.scale.x = 0.1;
56 | slamtecRTSTraj_.scale.y = 0.1;
57 | slamtecRTSTraj_.scale.z = 0.1;
58 | slamtecRTSTraj_.color.g = 0.3;
59 | slamtecRTSTraj_.color.a = 1.0;
60 |
61 |
62 | voTraj_.ns = "vo";
63 | voTraj_.action = visualization_msgs::Marker::ADD;
64 | voTraj_.type = visualization_msgs::Marker::LINE_STRIP;
65 | voTraj_.scale.x = 0.05;
66 | voTraj_.scale.y = 0.05;
67 | voTraj_.scale.z = 0.05;
68 | voTraj_.color.b = 0.62;
69 | voTraj_.color.g = 0.28;
70 | voTraj_.color.r = 0.43;
71 | voTraj_.color.a = 1.0;
72 |
73 | }
74 |
75 | void pubVOMark()
76 | {
77 | pubSlamtec();
78 | pubSlamTecTraj();
79 | pubVoTraj();
80 | }
81 |
82 | void pubSlamtec()
83 | {
84 | slamtec.header.frame_id = "world";
85 | slamtec.header.stamp = ros::Time::now();
86 | // slamtec.pose.position.x = slamTecStamped_.transform.translation.x;
87 | // slamtec.pose.position.y = slamTecStamped_.transform.translation.y;
88 | // slamtec.pose.position.z = slamTecStamped_.transform.translation.z;
89 | slamtec.pose.position.x = voStamped_.transform.translation.x;
90 | slamtec.pose.position.y = voStamped_.transform.translation.y;
91 | slamtec.pose.position.z = voStamped_.transform.translation.z;
92 | slamtec.pose.orientation.w = 1.0;
93 | slamTec_pub_.publish(slamtec);
94 | }
95 |
96 | void pubSlamTecTraj()
97 | {
98 | slamtecRTSTraj_.header.frame_id = "world";
99 | slamtecRTSTraj_.header.stamp = ros::Time::now();
100 | geometry_msgs::Point p;
101 | p.x = slamTecStamped_.transform.translation.x;
102 | p.y = slamTecStamped_.transform.translation.y;
103 | p.z = slamTecStamped_.transform.translation.z;
104 | if (abs(p.x-lastSlamtecPosition_[0])>0.2 || abs(p.y-lastSlamtecPosition_[1])>0.2)
105 | return;
106 | lastSlamtecPosition_[0] = p.x;
107 | lastSlamtecPosition_[1] = p.y;
108 | slamtecRTSTraj_.points.push_back(p);
109 | if (slamtecRTSTraj_.points.size() > 900)
110 | slamtecRTSTraj_.points.erase(slamtecRTSTraj_.points.begin());
111 | slamTec_pub_.publish(slamtecRTSTraj_);
112 | }
113 |
114 |
115 | void pubVoTraj()
116 | {
117 | voTraj_.header.frame_id = "world";
118 | voTraj_.header.stamp = ros::Time::now();
119 | geometry_msgs::Point p;
120 | p.x = voStamped_.transform.translation.x;
121 | p.y = voStamped_.transform.translation.y;
122 | p.z = voStamped_.transform.translation.z;
123 | voTraj_.points.push_back(p);
124 | if (voTraj_.points.size() > 900)
125 | voTraj_.points.erase(voTraj_.points.begin());
126 | vo_pub_.publish(voTraj_);
127 | }
128 |
129 |
130 |
131 |
132 | private:
133 | ros::NodeHandle nh_;
134 | ros::Publisher slamTec_pub_;
135 | ros::Publisher vo_pub_;
136 | ros::Subscriber vo_err_sub_;
137 |
138 |
139 | // rts location
140 | geometry_msgs::TransformStamped slamTecStamped_;
141 | // vo location
142 | geometry_msgs::TransformStamped voStamped_;
143 |
144 | std::vector lastSlamtecPosition_;
145 | visualization_msgs::Marker slamtec;
146 | visualization_msgs::Marker slamtecRTSTraj_;
147 | visualization_msgs::Marker voTraj_;
148 |
149 | };
150 |
151 | int main(int argc, char** argv)
152 | {
153 | ros::init(argc, argv, "vo_show");
154 | ros::NodeHandle nh;
155 | ERR_MARK_SHOW err_mark_show(nh);
156 | ros::Rate rate(10);
157 | while (ros::ok())
158 | {
159 | err_mark_show.pubVOMark();
160 | ros::spinOnce();
161 | rate.sleep();
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/vrpn2gmapping/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.8.3)
2 | project(vrpn2gmapping)
3 |
4 | ## Compile as C++11, supported in ROS Kinetic and newer
5 | # add_compile_options(-std=c++11)
6 |
7 | ## Find catkin macros and libraries
8 | ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9 | ## is used, also find other catkin packages
10 | find_package(catkin REQUIRED COMPONENTS
11 | roscpp
12 | rospy
13 | geometry_msgs
14 | tf
15 | )
16 |
17 | ## System dependencies are found with CMake's conventions
18 | # find_package(Boost REQUIRED COMPONENTS system)
19 |
20 |
21 | ## Uncomment this if the package has a setup.py. This macro ensures
22 | ## modules and global scripts declared therein get installed
23 | ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
24 | # catkin_python_setup()
25 |
26 | ################################################
27 | ## Declare ROS messages, services and actions ##
28 | ################################################
29 |
30 | ## To declare and build messages, services or actions from within this
31 | ## package, follow these steps:
32 | ## * Let MSG_DEP_SET be the set of packages whose message types you use in
33 | ## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
34 | ## * In the file package.xml:
35 | ## * add a build_depend tag for "message_generation"
36 | ## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
37 | ## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
38 | ## but can be declared for certainty nonetheless:
39 | ## * add a exec_depend tag for "message_runtime"
40 | ## * In this file (CMakeLists.txt):
41 | ## * add "message_generation" and every package in MSG_DEP_SET to
42 | ## find_package(catkin REQUIRED COMPONENTS ...)
43 | ## * add "message_runtime" and every package in MSG_DEP_SET to
44 | ## catkin_package(CATKIN_DEPENDS ...)
45 | ## * uncomment the add_*_files sections below as needed
46 | ## and list every .msg/.srv/.action file to be processed
47 | ## * uncomment the generate_messages entry below
48 | ## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
49 |
50 | ## Generate messages in the 'msg' folder
51 | # add_message_files(
52 | # FILES
53 | # Message1.msg
54 | # Message2.msg
55 | # )
56 |
57 | ## Generate services in the 'srv' folder
58 | # add_service_files(
59 | # FILES
60 | # Service1.srv
61 | # Service2.srv
62 | # )
63 |
64 | ## Generate actions in the 'action' folder
65 | # add_action_files(
66 | # FILES
67 | # Action1.action
68 | # Action2.action
69 | # )
70 |
71 | ## Generate added messages and services with any dependencies listed here
72 | # generate_messages(
73 | # DEPENDENCIES
74 | # std_msgs # Or other packages containing msgs
75 | # )
76 |
77 | ################################################
78 | ## Declare ROS dynamic reconfigure parameters ##
79 | ################################################
80 |
81 | ## To declare and build dynamic reconfigure parameters within this
82 | ## package, follow these steps:
83 | ## * In the file package.xml:
84 | ## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
85 | ## * In this file (CMakeLists.txt):
86 | ## * add "dynamic_reconfigure" to
87 | ## find_package(catkin REQUIRED COMPONENTS ...)
88 | ## * uncomment the "generate_dynamic_reconfigure_options" section below
89 | ## and list every .cfg file to be processed
90 |
91 | ## Generate dynamic reconfigure parameters in the 'cfg' folder
92 | # generate_dynamic_reconfigure_options(
93 | # cfg/DynReconf1.cfg
94 | # cfg/DynReconf2.cfg
95 | # )
96 |
97 | ###################################
98 | ## catkin specific configuration ##
99 | ###################################
100 | ## The catkin_package macro generates cmake config files for your package
101 | ## Declare things to be passed to dependent projects
102 | ## INCLUDE_DIRS: uncomment this if your package contains header files
103 | ## LIBRARIES: libraries you create in this project that dependent projects also need
104 | ## CATKIN_DEPENDS: catkin_packages dependent projects also need
105 | ## DEPENDS: system dependencies of this project that dependent projects also need
106 | catkin_package(
107 | # INCLUDE_DIRS include
108 | # LIBRARIES vrpn2gmapping
109 | # CATKIN_DEPENDS roscpp rospy tf
110 | # DEPENDS system_lib
111 | )
112 |
113 | ###########
114 | ## Build ##
115 | ###########
116 |
117 | ## Specify additional locations of header files
118 | ## Your package locations should be listed before other locations
119 | include_directories(
120 | include ${catkin_INCLUDE_DIRS}
121 | # include
122 | ${catkin_INCLUDE_DIRS}
123 | )
124 |
125 | ## Declare a C++ library
126 | # add_library(${PROJECT_NAME}
127 | # src/${PROJECT_NAME}/vrpn2gmapping.cpp
128 | # )
129 |
130 | ## Add cmake target dependencies of the library
131 | ## as an example, code may need to be generated before libraries
132 | ## either from message generation or dynamic reconfigure
133 | # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
134 |
135 | ## Declare a C++ executable
136 | ## With catkin_make all packages are built within a single CMake context
137 | ## The recommended prefix ensures that target names across packages don't collide
138 | # add_executable(${PROJECT_NAME}_node src/vrpn2gmapping_node.cpp)
139 |
140 | ## Rename C++ executable without prefix
141 | ## The above recommended prefix causes long target names, the following renames the
142 | ## target back to the shorter version for ease of user use
143 | ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
144 | # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
145 |
146 | ## Add cmake target dependencies of the executable
147 | ## same as for the library above
148 | # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
149 |
150 | ## Specify libraries to link a library or executable target against
151 | # target_link_libraries(${PROJECT_NAME}_node
152 | # ${catkin_LIBRARIES}
153 | # )
154 |
155 | #############
156 | ## Install ##
157 | #############
158 |
159 | # all install targets should use catkin DESTINATION variables
160 | # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
161 |
162 | ## Mark executable scripts (Python etc.) for installation
163 | ## in contrast to setup.py, you can choose the destination
164 | # install(PROGRAMS
165 | # scripts/my_python_script
166 | # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
167 | # )
168 |
169 | ## Mark executables and/or libraries for installation
170 | # install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
171 | # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
172 | # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
173 | # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
174 | # )
175 |
176 | ## Mark cpp header files for installation
177 | # install(DIRECTORY include/${PROJECT_NAME}/
178 | # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
179 | # FILES_MATCHING PATTERN "*.h"
180 | # PATTERN ".svn" EXCLUDE
181 | # )
182 |
183 | ## Mark other files for installation (e.g. launch and bag files, etc.)
184 | # install(FILES
185 | # # myfile1
186 | # # myfile2
187 | # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
188 | # )
189 |
190 | #############
191 | ## Testing ##
192 | #############
193 |
194 | ## Add gtest based cpp test target and link libraries
195 | # catkin_add_gtest(${PROJECT_NAME}-test test/test_vrpn2gmapping.cpp)
196 | # if(TARGET ${PROJECT_NAME}-test)
197 | # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
198 | # endif()
199 |
200 | ## Add folders to be run by python nosetests
201 | # catkin_add_nosetests(test)
202 |
203 | add_executable(record
204 | src/record.cpp
205 | )
206 | add_dependencies(record ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
207 | target_link_libraries(record
208 | ${catkin_LIBRARIES}
209 | )
210 |
211 | add_executable(readAndPub
212 | src/readAndPub.cpp
213 | )
214 | add_dependencies(readAndPub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
215 | target_link_libraries(readAndPub
216 | ${catkin_LIBRARIES}
217 | )
--------------------------------------------------------------------------------
/vrpn2gmapping/package.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | vrpn2gmapping
4 | 0.0.0
5 | The vrpn2gmapping package
6 |
7 |
8 |
9 |
10 | bdi
11 |
12 |
13 |
14 |
15 |
16 | TODO
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | catkin
52 | roscpp
53 | rospy
54 | tf
55 | roscpp
56 | rospy
57 | tf
58 | roscpp
59 | rospy
60 | tf
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/vrpn2gmapping/src/readAndPub.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | int main(int argc, char** argv)
10 | {
11 | ros::init(argc, argv, "readAndPub");
12 | ros::NodeHandle nh;
13 |
14 | std::ifstream reader;
15 | reader.open("/home/husky/husky_demo_ws/src/husky_ws/pose/pose.txt");
16 | double t_x, t_y, t_z, o_roll, o_pitch, o_yaw;
17 | reader >> t_x;
18 | reader >> t_y;
19 | reader >> t_z;
20 | reader >> o_roll;
21 | reader >> o_pitch;
22 | reader >> o_yaw;
23 | // std::cout << t_x << "," << t_y << "," << t_z << "," << o_roll << ","<< o_pitch << "," << o_yaw << std::endl;
24 |
25 |
26 |
27 | static tf2_ros::StaticTransformBroadcaster br;
28 | geometry_msgs::TransformStamped transformStamped;
29 | transformStamped.header.stamp = ros::Time::now();
30 | transformStamped.header.frame_id = "world";
31 | transformStamped.child_frame_id = "map";
32 | transformStamped.transform.translation.x = t_x;
33 | transformStamped.transform.translation.y = t_y;
34 | transformStamped.transform.translation.z = 0;
35 | tf2::Quaternion q;
36 | q.setRPY(0, 0, o_yaw);
37 | transformStamped.transform.rotation.x = q[0];
38 | transformStamped.transform.rotation.y = q[1];
39 | transformStamped.transform.rotation.z = q[2];
40 | transformStamped.transform.rotation.w = q[3];
41 |
42 |
43 | br.sendTransform(transformStamped);
44 | ros::spin();
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/vrpn2gmapping/src/record.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 |
9 | int main(int argc, char** argv)
10 | {
11 | ros::init(argc, argv, "record");
12 | ros::NodeHandle nh;
13 |
14 | tf2_ros::Buffer tfBuffer;
15 | tf2_ros::TransformListener listener(tfBuffer);
16 | ros::Rate rate(10.0);
17 | geometry_msgs::TransformStamped transformStamped;
18 |
19 | std::ofstream write;
20 | write.open("pose.txt");
21 |
22 | int loop_counter = 0;
23 | double t_x, t_y, t_z, o_roll, o_pitch, o_yaw = 0;
24 | while (loop_counter<10)
25 | {
26 | try
27 | {
28 | transformStamped = tfBuffer.lookupTransform("world", "husky", ros::Time(0), ros::Duration(0.5));
29 | }
30 | catch (tf2::TransformException &ex)
31 | {
32 | ROS_WARN("%s", ex.what());
33 | ros::Duration(1.0).sleep();
34 | continue;
35 | }
36 | rate.sleep();
37 |
38 | t_x += transformStamped.transform.translation.x;
39 | t_y += transformStamped.transform.translation.y;
40 |
41 | double ox = transformStamped.transform.rotation.x;
42 | double oy = transformStamped.transform.rotation.y;
43 | double oz = transformStamped.transform.rotation.z;
44 | double ow = transformStamped.transform.rotation.w;
45 | tf::Quaternion q(ox, oy, oz, ow);
46 | tf::Matrix3x3 m(q);
47 | double roll, pitch, yaw;
48 | m.getRPY(roll, pitch, yaw);
49 | o_yaw += yaw;
50 |
51 | loop_counter++;
52 | }
53 |
54 | t_x /= 10;
55 | t_y /= 10;
56 | t_z /= 10;
57 | o_yaw /= 10;
58 | write << t_x << "\n" << t_y << "\n" << 0 << "\n" << 0 << "\n" << 0 << "\n" << o_yaw << std::endl;
59 |
60 |
61 | }
--------------------------------------------------------------------------------