ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

Take a look at https://github.com/lucasw/bgfx_ros/blob/master/scripts/make_marker.py , it generates a complete sphere into an rviz Marker triangle list but you could add an angle offset to theta or phi and instead of multiplying by pi or 2*pi a smaller number will result in only a subsection of a sphere being covered by points:

def sphere_point(radius, theta, phi):
    pt = Point()
    sp = math.sin(phi)
    cp = math.cos(phi)
    pt.x = radius * cp * math.cos(theta)
    pt.y = radius * cp * math.sin(theta)
    pt.z = radius * sp
    return pt

...
radius = rospy.get_param("~radius", 2.0)
num_lat = 20
num_long = 20
for i in range(num_lat):
    phi1 = float(i) / float(num_lat) * math.pi - math.pi / 2.0
    for j in range(num_long):
        theta1 = float(j) / float(num_long) * 2.0 * math.pi

        ...

        p11 = sphere_point(radius, theta1, phi1)
        ...