0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[rviz] 点の描画

Last updated at Posted at 2021-11-10

rviz上に点を描画するだけのプログラム

pub_point.py

import rospy
from visualization_msgs.msg import Marker

rospy.init_node("marker_pub")

pub = rospy.Publisher("sphere_pub", Marker, queue_size = 10)
rate = rospy.Rate(25)

w=0

while not rospy.is_shutdown():
    marker_data = Marker()
    marker_data.header.frame_id = "map"
    marker_data.header.stamp = rospy.Time.now()

    marker_data.ns = "basic_shapes"
    marker_data.id = 0

    marker_data.action = Marker.ADD

    marker_data.pose.position.x = 0.0
    marker_data.pose.position.y = 0.0
    marker_data.pose.position.z = 0.0

    marker_data.color.r = 1.0
    marker_data.color.g = 0.0
    marker_data.color.b = 0.0
    marker_data.color.a = 1.0

    marker_data.scale.x = 0.3
    marker_data.scale.y = 0.3
    marker_data.scale.z = 0.3

    marker_data.lifetime = rospy.Duration()

    marker_data.type = 2

    pub.publish(marker_data)

    rate.sleep()

rvizで表示すると以下のようになります

Screenshot from 2021-11-11 04-02-04.png

(参考)https://www.robotech-note.com/entry/2018/04/15/221524

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?