本文整理汇总了Python中visualization_msgs.msg.Marker.text方法的典型用法代码示例。如果您正苦于以下问题:Python Marker.text方法的具体用法?Python Marker.text怎么用?Python Marker.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类visualization_msgs.msg.Marker
的用法示例。
在下文中一共展示了Marker.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: publish_waypoint_markers
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def publish_waypoint_markers(self):
pub_waypoint_markers = rospy.Publisher('waypoint_markers', MarkerArray)
marker_array = MarkerArray()
for i in range(len(self.waypoints)):
waypoint = self.waypoints[i]
waypoint_marker = Marker()
waypoint_marker.id = i
waypoint_marker.header.frame_id = "/map"
waypoint_marker.header.stamp = rospy.Time.now()
if (waypoint.type == 'P'):
waypoint_marker.type = 5 # Line List
waypoint_marker.text = 'waypoint_%s_point' % i
waypoint_marker.color.r = 176.0
waypoint_marker.color.g = 224.0
waypoint_marker.color.b = 230.0
waypoint_marker.color.a = 0.5
waypoint_marker.scale.x = 0.5
c = waypoint.coordinate
waypoint_marker.points.append(Point(c.x, c.y, c.z))
waypoint_marker.points.append(Point(c.x, c.y, c.z + 3.0))
else:
waypoint_marker.type = 3 # Cylinder
waypoint_marker.text = 'waypoint_%s_cone' % i
waypoint_marker.color.r = 255.0
waypoint_marker.color.g = 69.0
waypoint_marker.color.b = 0.0
waypoint_marker.color.a = 1.0
waypoint_marker.scale.x = 0.3
waypoint_marker.scale.y = 0.3
waypoint_marker.scale.z = 0.5
waypoint_marker.pose.position = waypoint.coordinate
marker_array.markers.append(waypoint_marker)
if self.current_waypoint_idx != len(self.waypoints):
current_waypoint_marker = Marker()
current_waypoint_marker.id = 999
current_waypoint_marker.header.frame_id = "/map"
current_waypoint_marker.header.stamp = rospy.Time.now()
current_waypoint_marker.type = 2 # Sphere
current_waypoint_marker.text = 'current_waypoint'
current_waypoint_marker.color.r = 255.0
current_waypoint_marker.color.g = 0.0
current_waypoint_marker.color.b = 0.0
current_waypoint_marker.color.a = 1.0
current_waypoint_marker.scale.x = 0.3
current_waypoint_marker.scale.y = 0.3
current_waypoint_marker.scale.z = 0.3
current_waypoint = self.waypoints[self.current_waypoint_idx]
current_waypoint_marker.pose.position.x = current_waypoint.coordinate.x
current_waypoint_marker.pose.position.y = current_waypoint.coordinate.y
current_waypoint_marker.pose.position.z = 1.0
marker_array.markers.append(current_waypoint_marker)
pub_waypoint_markers.publish(marker_array)
示例2: create_line_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def create_line_marker(p1, p2, frame_id):
h = Header()
h.frame_id = frame_id #tie marker visualization to laser it comes from
h.stamp = rospy.Time.now() # Note you need to call rospy.init_node() before this will work
#create marker:person_marker, modify a red cylinder, last indefinitely
mark = Marker()
mark.header = h
mark.ns = "unit_vector"
mark.id = 0
mark.type = Marker.LINE_STRIP
mark.action = 0
mark.scale.x = 0.2
mark.color = color = ColorRGBA(0.2, 0.5, 0.7, 1.0)
mark.text = "unit_vector"
points = []
pt1 = Point(p1[0], p1[1], p1[2])
pt2 = Point(p2[0], p2[1], p2[2])
# print "Pt 1 ", pt1
# print "Pt 2 ", pt2
points.append(pt1)
points.append(pt2)
mark.points = points
return mark
示例3: pub_arrow
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def pub_arrow(self, pos1, pos2, color, mag_force):
marker = Marker()
marker.header.frame_id = self.frame
marker.header.stamp = rospy.Time.now()
marker.ns = "basic_shapes"
marker.id = 99999
marker.type = Marker.ARROW
marker.action = Marker.ADD
pt1 = Point()
pt2 = Point()
pt1.x = pos1[0,0]
pt1.y = pos1[1,0]
pt1.z = pos1[2,0]
pt2.x = pos2[0,0]
pt2.y = pos2[1,0]
pt2.z = pos2[2,0]
marker.points.append(pt1)
marker.points.append(pt2)
marker.scale.x = 0.05
marker.scale.y = 0.1
#marker.scale.z = scale[2]
marker.color.r = color[0]
marker.color.g = color[1]
marker.color.b = color[2]
marker.color.a = color[3]
marker.lifetime = rospy.Duration()
marker.text = mag_force
self.pub.publish(marker)
示例4: addFlag
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def addFlag():
# get the cooprations of turtlebot in map using tf
# listener = tf.TransformListener()
# listener.waitForTransform("/odom", "/base_link", rospy.Time(0), rospy.Duration(1))
# (position, rotation) = listener.lookupTransform("/odom", "/base_link", rospy.Time(0))
global poseX, poseY, poseZ
marker_pub = rospy.Publisher("warning_marker",Marker,queue_size=1)
shape = Marker.TEXT_VIEW_FACING
for i in range(5):
marker = Marker()
marker.header.frame_id = 'map'
marker.color.r, marker.color.b, marker.color.g = 1, 0, 0
marker.color.a = 1
marker.ns = "WarningFlag"
marker.id = 1024
marker.pose.position.x, marker.pose.position.y, marker.pose.position.z = poseX, poseY , poseZ+0.5#position[0], position[1]-0.7, 0
marker.scale.x, marker.scale.y, marker.scale.z = 0.01, 0.01, 0.2
marker.type = shape
marker.text = "WARNING"
marker.lifetime = rospy.Duration(5)
marker_pub.publish(marker)
rospy.sleep(1)
示例5: __setTextMarker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def __setTextMarker(self, id, waypoint, colors = [1,0,0,0]):
try:
marker = Marker()
marker.header.frame_id = '/map'
marker.header.stamp = rospy.Time.now()
marker.ns = 'patrol'
marker.id = id + len(self.__waypoints)
marker.type = marker.TEXT_VIEW_FACING
marker.action = marker.ADD
marker.text = str(id)
marker.scale.x = 0.2
marker.scale.y = 0.2
marker.scale.z = 0.2
marker.color.a = colors[0]
marker.color.r = colors[1]
marker.color.b = colors[2]
marker.color.g = colors[3]
marker.pose.orientation.w = 1.0
marker.pose.position.x = waypoint.target_pose.pose.position.x
marker.pose.position.y = waypoint.target_pose.pose.position.y
marker.pose.position.z = waypoint.target_pose.pose.position.z
return marker
except Exception as ex:
rospy.logwarn('PatrolNode.__setMarker- ', ex.message)
示例6: get_current_position_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def get_current_position_marker(self, link, offset=None, root="", scale=1, color=(0,1,0,1), idx=0):
(mesh, pose) = self.get_link_data(link)
marker = Marker()
if offset==None :
marker.pose = pose
else :
marker.pose = toMsg(fromMsg(offset)*fromMsg(pose))
marker.header.frame_id = root
marker.header.stamp = rospy.get_rostime()
marker.ns = self.robot_name
marker.mesh_resource = mesh
marker.type = Marker.MESH_RESOURCE
marker.action = Marker.MODIFY
marker.scale.x = scale
marker.scale.y = scale
marker.scale.z = scale
marker.color.r = color[0]
marker.color.g = color[1]
marker.color.b = color[2]
marker.color.a = color[3]
marker.text = link
marker.id = idx
marker.mesh_use_embedded_materials = True
return marker
示例7: pub_body
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def pub_body(self, pos, quat, scale, color, num, shape, text = ''):
marker = Marker()
marker.header.frame_id = self.frame
marker.header.stamp = rospy.Time.now()
marker.ns = "basic_shapes"
marker.id = num
marker.type = shape
marker.action = Marker.ADD
marker.pose.position.x = pos[0]
marker.pose.position.y = pos[1]
marker.pose.position.z = pos[2]
marker.pose.orientation.x = quat[0]
marker.pose.orientation.y = quat[1]
marker.pose.orientation.z = quat[2]
marker.pose.orientation.w = quat[3]
marker.scale.x = scale[0]
marker.scale.y = scale[1]
marker.scale.z = scale[2]
marker.color.r = color[0]
marker.color.g = color[1]
marker.color.b = color[2]
marker.color.a = color[3]
marker.lifetime = rospy.Duration()
marker.text = text
self.pub.publish(marker)
示例8: text_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def text_marker(marker_id, _point, txt):
#waypoints = list()
#waypoints.append(Pose(Point(2.680, 1.600, 0.000), 0.1))
#waypoints.append(Pose(Point(2.680, -1.600, 0.000), 0.1))
#waypoints.append(Pose(Point(-2.680, 1.600, 0.000), 0.1))
#waypoints.append(Pose(Point(-2.680, -1.600, 0.000), 0.1))
#set up markeri
marker = Marker()
marker_scale = 0.6
marker_lifetime = 0
marker_ns = 'point name'
marker_color= {'r':0.0, 'g':1.0, 'b':0.0, 'a':1.0}
marker.ns = marker_ns
marker.id = marker_id
# marker.type = Marker.SPHERE
marker.type = Marker.TEXT_VIEW_FACING
marker.action = Marker.ADD
marker.header.frame_id = '/map'
marker.lifetime = rospy.Duration(marker_lifetime)
marker.scale.x = marker_scale
marker.scale.y = marker_scale
marker.scale.z = marker_scale
marker.color.r = marker_color['r']
marker.color.g = marker_color['g']
marker.color.b = marker_color['b']
marker.color.a = marker_color['a']
marker.text = txt
marker.header.stamp = rospy.Time.now()
marker.pose.position.x = _point.x
marker.pose.position.y = _point.y
marker.pose.position.z = _point.z
print txt
return marker
示例9: publish_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def publish_marker(cls, x_cord, y_cord, mid):
new_marker = Marker(type = Marker.CUBE, action=Marker.ADD)
new_marker.header.frame_id = "/base_laser_front_link"
new_marker.header.stamp = rospy.Time.now()
new_marker.ns = "basic_shapes"
new_marker.id = mid
new_marker.pose.position.x = x_cord
new_marker.pose.position.y = y_cord
new_marker.pose.position.z = 0.0
#pointxyz
new_marker.pose.orientation.x = 0
new_marker.pose.orientation.y = 0
new_marker.pose.orientation.z = 0.0
new_marker.pose.orientation.w = 1
new_marker.scale.x = 0.005
new_marker.scale.y = 0.005
new_marker.scale.z = 0.005
if mid == 0:
new_marker.color.r = 1
elif mid == 5:
new_marker.color.g = 1
elif mid == 10:
new_marker.color.b = 1
new_marker.color.a = 1
new_marker.text = "marker"
new_marker.lifetime = rospy.Duration(1)
SmachGlobalData.pub_marker.publish(new_marker)
示例10: __publish_marker_for_object
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def __publish_marker_for_object(self, object, txt):
marker = Marker()
marker.header.frame_id = object.object.header.frame_id
marker.header.stamp = rospy.Time(0)
marker.ns = "scene_classifier_marker"
self.marker_id = self.marker_id + 1
marker.id = self.marker_id
marker.type = Marker.TEXT_VIEW_FACING
marker.action = Marker.ADD
marker.pose.position.x = object.c_centroid.x
marker.pose.position.y = object.c_centroid.y
marker.pose.position.z = object.c_centroid.z
marker.pose.orientation.x = 0.0
marker.pose.orientation.y = 0.0
marker.pose.orientation.z = 0.0
marker.pose.orientation.w = 1.0
marker.scale.x = 0.5
marker.scale.y = 0.1
marker.scale.z = 0.1
marker.color.a = 1.0
marker.color.r = 0.0
marker.color.g = 1.0
marker.color.b = 0.0
marker.text = txt
marker.lifetime = rospy.Duration.from_sec(10)
self.marker_publisher.publish(marker)
示例11: draw_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def draw_marker(
self,
ps,
id=None,
type=Marker.CUBE,
ns="default_ns",
rgba=(0, 1, 0, 1),
scale=(0.03, 0.03, 0.03),
text="",
duration=0,
):
"""
If markers aren't showing up, it's probably because the id's are being overwritten. Make sure to set
the ids and namespace.
"""
if id is None:
id = self.get_unused_id()
marker = Marker(type=type, action=Marker.ADD)
marker.ns = ns
marker.header = ps.header
marker.pose = ps.pose
marker.scale = gm.Vector3(*scale)
marker.color = stdm.ColorRGBA(*rgba)
marker.id = id
marker.text = text
marker.lifetime = rospy.Duration(duration)
self.pub.publish(marker)
self.ids.add(id)
return MarkerHandle(marker, self.pub)
示例12: get_vehicle_marker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def get_vehicle_marker(object, header, marker_id=0, is_player=False):
"""
Return a marker msg
:param object: carla agent object (pb2 object (vehicle, pedestrian or traffic light))
:param header: ros header (stamp/frame_id)
:param marker_id: a marker id (int32)
:param is_player: True if player else False (usefull to change marker color)
:return: a ros marker msg
"""
marker = Marker(header=header)
marker.color.a = 0.3
if is_player:
marker.color.g = 1
marker.color.r = 0
marker.color.b = 0
else:
marker.color.r = 1
marker.color.g = 0
marker.color.b = 0
marker.id = marker_id
marker.text = "id = {}".format(marker_id)
update_marker_pose(object, marker)
return marker
示例13: control_points_callback
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def control_points_callback(self, msg):
subdiv_points = msg
for i in range(self.subdivisions):
subdiv_points = self.subdivide(subdiv_points)
self.curve_pub.publish(subdiv_points)
marker = Marker()
marker.header.frame_id = "map"
marker.header.stamp = rospy.Time.now()
marker.ns = "subdivision"
marker.id = 0 # self.subdivisions
marker.action = Marker.ADD
marker.type = Marker.LINE_STRIP
marker.pose.orientation.w = 1.0
marker.scale.x = 0.05
marker.scale.y = 0.05
marker.scale.z = 0.05
marker.color.r = 1.0
marker.color.g = 1.0
marker.color.b = 1.0
marker.color.a = 1.0
marker.text = str(self.subdivisions)
for pt in subdiv_points.points:
gpt = Point()
gpt.x = pt.x
gpt.y = pt.y
marker.points.append(gpt)
marker.points.append(marker.points[0])
self.marker_pub.publish(marker)
示例14: make_label
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def make_label(text, position, id = 0 ,duration = 5.0, color=[1.0,1.0,1.0]):
""" Helper function for generating visualization markers.
Args:
text (str): Text string to be displayed.
position (list): List containing [x,y,z] positions
id (int): Integer identifying the label
duration (rospy.Duration): How long the label will be displayed for
color (list): List of label color floats from 0 to 1 [r,g,b]
Returns:
Marker: A text view marker which can be published to RViz
"""
marker = Marker()
marker.header.frame_id = '/world'
marker.id = id
marker.type = marker.TEXT_VIEW_FACING
marker.text = text
marker.action = marker.ADD
marker.scale.x = 0.05
marker.scale.y = 0.05
marker.scale.z = 0.05
marker.color.a = 1.0
marker.color.r = color[0]
marker.color.g = color[1]
marker.color.b = color[2]
marker.lifetime = rospy.Duration(duration)
marker.pose.orientation.w = 1.0
marker.pose.position.x = position[0]
marker.pose.position.y = position[1]
marker.pose.position.z = position[2]
return marker
示例15: poseStampedToLabeledSphereMarker
# 需要导入模块: from visualization_msgs.msg import Marker [as 别名]
# 或者: from visualization_msgs.msg.Marker import text [as 别名]
def poseStampedToLabeledSphereMarker(cls, psdata, label, fmt="{label} %Y-%m-%d %H:%M:%S", zoffset=0.05):
"[poseStamped, meta] -> sphereMarker"
ps, meta = psdata
res = []
h = Header()
h.stamp = rospy.Time.now()
h.frame_id = ps.header.frame_id
sphere = Marker(type=Marker.SPHERE,
action=Marker.ADD,
header=h,
id=cls.marker_id)
sphere.scale.x = 0.07
sphere.scale.y = 0.07
sphere.scale.z = 0.07
sphere.pose = ps.pose
sphere.color = ColorRGBA(1.0,0,0,1.0)
sphere.ns = "db_play"
sphere.lifetime = rospy.Time(3)
cls.marker_id += 1
res.append(sphere)
text = Marker(type=Marker.TEXT_VIEW_FACING,
action=Marker.ADD,
header=h,
id=cls.marker_id)
text.scale.z = 0.1
text.pose = deepcopy(ps.pose)
text.pose.position.z += zoffset
text.color = ColorRGBA(1.0,1.0,1.0,1.0)
text.text = meta["inserted_at"].strftime(fmt).format(label=label)
text.ns = "db_play_text"
text.lifetime = rospy.Time(300)
cls.marker_id += 1
res.append(text)
return res