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

cant see markers in rviz2

asked 2022-10-19 05:11:36 -0600

bodka gravatar image

Hi all. I am using ros2 foxy. I am trying to publish a marker to rviz, but it does not visualize it.

the marker code:

   visualization_msgs::msg::Marker marker;
   marker.id = 0;
   marker.header.frame_id = "base_link";
   marker.frame_locked = true;
   marker.header.stamp = this->get_clock()->now();
   marker.ns = "visual_box";

        marker.type = visualization_msgs::msg::Marker::CUBE;
        marker.action =visualization_msgs::msg::Marker::ADD;
        marker.pose=object_pos; 

        marker.scale.x = object_size.x/100.0f;
        marker.scale.y = object_size.y/100.0f;
        marker.scale.z = (object_size.z)/100.0f;
        marker.color.a = alpa; // Don't forget to set the alpha!

        marker.color.r = rand()%100/100.0f;
        marker.color.g = rand()%100/100.0f;
        marker.color.b = rand()%100/100.0f;

        this->box_marker_pub->publish(marker);

the msg is getting publish, if i echo it from the terminal i get:

picko@picko-koby:~/pickommerce_ws$ ros2 topic echo /packing_algorithm/visual_boxing
header:
  stamp:
    sec: 1666173251
    nanosec: 528962951
  frame_id: base_link
ns: visual_box
id: 0
type: 1
action: 0
pose:
  position:
    x: 0.555
    y: 0.555
    z: 0.5449999928474427
  orientation:
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
scale:
  x: 1.1100000143051147
  y: 1.1100000143051147
  z: 1.1100000143051147
color:
  r: 0.8299999833106995
  g: 0.8600000143051147
  b: 0.7699999809265137
  a: 0.5
lifetime:
  sec: 0
  nanosec: 0
frame_locked: true
points: []
colors: []
text: ''
mesh_resource: ''
mesh_use_embedded_materials: false
---

the fix frame in rviz set to base_link. any idea?

edit retag flag offensive close merge delete

Comments

@bodka the convention on this site is to not close questions unless there is a problem with it e.g. it is off-topic or an exact duplicate question. Instead, if an answer successfully helped you solve your problem, you should click on the "check mark" symbol in the gray circle on the left side of the answer. The icon will turn green to indicate which answer you selected.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-10-20 08:38:19 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-20 01:38:20 -0600

bodka gravatar image

i find the solution. the problem was that my node was killed to close to the publish. the solution is to add sleep at the node class distractor or at the end of the main.

rclcpp::sleep_for(std::chrono::seconds(1));

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-10-19 05:11:36 -0600

Seen: 732 times

Last updated: Oct 20 '22