Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setLifetime method does not affect triangle_marker_ #72

Open
alfonsotecnalia opened this issue Mar 16, 2018 · 1 comment
Open

setLifetime method does not affect triangle_marker_ #72

alfonsotecnalia opened this issue Mar 16, 2018 · 1 comment

Comments

@alfonsotecnalia
Copy link

void RvizVisualTools::setLifetime(double lifetime)

triangle_marker_ is not included in this method so its lifetime is not affected. Now I do the trick calling loadRvizMarkers immediately afterwards.

@naisy
Copy link

naisy commented Jul 6, 2022

Not only triangle_marker_, but also line_list_marker_ and spheres_marker_ have the same problem.

I checked the differences in the appearance of the string _.lifetime in the code: src/rviz_visual_tools.cpp.
command:

cat src/rviz_visual_tools.cpp | grep "_.lifetime" | sort

result:

  arrow_marker_.lifetime = marker_lifetime_;
  arrow_marker_.lifetime = marker_lifetime_;
  block_marker_.lifetime = marker_lifetime_;
  block_marker_.lifetime = marker_lifetime_;
  cuboid_marker_.lifetime = marker_lifetime_;
  cuboid_marker_.lifetime = marker_lifetime_;
  cylinder_marker_.lifetime = marker_lifetime_;
  cylinder_marker_.lifetime = marker_lifetime_;
  line_list_marker_.lifetime = marker_lifetime_;
  line_strip_marker_.lifetime = marker_lifetime_;
  line_strip_marker_.lifetime = marker_lifetime_;
  mesh_marker_.lifetime = marker_lifetime_;
  mesh_marker_.lifetime = marker_lifetime_;
  sphere_marker_.lifetime = marker_lifetime_;
  sphere_marker_.lifetime = marker_lifetime_;
  spheres_marker_.lifetime = marker_lifetime_;
  text_marker_.lifetime = marker_lifetime_;
  text_marker_.lifetime = marker_lifetime_;
  triangle_marker_.lifetime = marker_lifetime_;

I am using the ros2 branch, so I modified it as follows and confirmed that visual_tools_->setLifetime(2.0); is valid in the demo code: src/rviz_visual_tools_demo.cpp.

before:

void RvizVisualTools::setLifetime(double lifetime)
{
  marker_lifetime_ = builtin_interfaces::msg::Duration();
  marker_lifetime_.sec = static_cast<int32_t>(floor(lifetime));
  marker_lifetime_.nanosec =
      static_cast<uint32_t>(std::round((lifetime - marker_lifetime_.sec) * 1e9));

  // Update cached markers
  arrow_marker_.lifetime = marker_lifetime_;
  cuboid_marker_.lifetime = marker_lifetime_;
  line_strip_marker_.lifetime = marker_lifetime_;
  sphere_marker_.lifetime = marker_lifetime_;
  block_marker_.lifetime = marker_lifetime_;
  mesh_marker_.lifetime = marker_lifetime_;
  cylinder_marker_.lifetime = marker_lifetime_;
  text_marker_.lifetime = marker_lifetime_;
}

after:

void RvizVisualTools::setLifetime(double lifetime)
{
  marker_lifetime_ = builtin_interfaces::msg::Duration();
  marker_lifetime_.sec = static_cast<int32_t>(floor(lifetime));
  marker_lifetime_.nanosec =
      static_cast<uint32_t>(std::round((lifetime - marker_lifetime_.sec) * 1e9));

  // Update cached markers
  arrow_marker_.lifetime = marker_lifetime_;
  cuboid_marker_.lifetime = marker_lifetime_;
  line_strip_marker_.lifetime = marker_lifetime_;
  sphere_marker_.lifetime = marker_lifetime_;
  block_marker_.lifetime = marker_lifetime_;
  mesh_marker_.lifetime = marker_lifetime_;
  cylinder_marker_.lifetime = marker_lifetime_;
  text_marker_.lifetime = marker_lifetime_;
  line_list_marker_.lifetime = marker_lifetime_;
  spheres_marker_.lifetime = marker_lifetime_;
  triangle_marker_.lifetime = marker_lifetime_;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants