utils.py
Go to the documentation of this file.
1 
2 import yaml
3 import rospy
4 import move_base_msgs.msg as move_base_msgs
5 import geometry_msgs.msg as geometry_msgs
6 import visualization_msgs.msg as viz_msgs
7 import std_msgs.msg as std_msgs
8 
9 id_count = 1
10 
11 def get_waypoints(filename):
12  with open(filename, 'r') as f:
13  data = yaml.load(f)
14 
15  return data['waypoints']
16 
18  pose = geometry_msgs.Pose()
19 
20  pose.position.x = p['pose']['position']['x']
21  pose.position.y = p['pose']['position']['y']
22  pose.position.z = p['pose']['position']['z']
23  pose.orientation.x = p['pose']['orientation']['x']
24  pose.orientation.y = p['pose']['orientation']['y']
25  pose.orientation.z = p['pose']['orientation']['z']
26  pose.orientation.w = p['pose']['orientation']['w']
27  return pose
28 
30  target = geometry_msgs.PoseStamped()
31  target.header.frame_id = p['frame_id']
32  target.header.stamp = rospy.Time.now()
33  target.pose = create_geo_pose(p)
34  goal = move_base_msgs.MoveBaseGoal(target)
35  return goal
36 
37 def create_viz_markers(waypoints):
38  marray= viz_msgs.MarkerArray()
39  for w in waypoints:
40  m_arrow = create_arrow(w)
41  m_text = create_text(w)
42  marray.markers.append(m_arrow)
43  marray.markers.append(m_text)
44  return marray
45 
47  global id_count
48  m = viz_msgs.Marker()
49  m.header.frame_id = w['frame_id']
50  m.ns = w['name']
51  m.id = id_count
52  m.action = viz_msgs.Marker.ADD
53  m.pose = create_geo_pose(w)
54  m.scale = geometry_msgs.Vector3(1.0,0.3,0.3)
55  m.color = std_msgs.ColorRGBA(0.0,1.0,0.0,1.0)
56 
57  id_count = id_count + 1
58  return m
59 
60 def create_arrow(w):
61  m = create_marker(w)
62  m.type = viz_msgs.Marker.ARROW
63  m.color = std_msgs.ColorRGBA(0.0,1.0,0.0,1.0)
64  return m
65 
66 def create_text(w):
67  m = create_marker(w)
68  m.type = viz_msgs.Marker.TEXT_VIEW_FACING
69  m.pose.position.z = 2.5
70  m.text = w['name']
71  return m
def create_text(w)
Definition: utils.py:66
def get_waypoints(filename)
Definition: utils.py:11
def create_move_base_goal(p)
Definition: utils.py:29
def create_viz_markers(waypoints)
Definition: utils.py:37
def create_arrow(w)
Definition: utils.py:60
def create_marker(w)
Definition: utils.py:46
def create_geo_pose(p)
Definition: utils.py:17


waypoint_touring
Author(s):
autogenerated on Mon Jun 10 2019 15:49:18