You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Add a simple box visual for the button
visualization_msgs::msg::Marker box_marker;
box_marker.type = visualization_msgs::msg::Marker::CUBE;
box_marker.scale.x = 0.5;
box_marker.scale.y = 0.5;
box_marker.scale.z = 0.5;
box_marker.color.r = 0.0f;
box_marker.color.g = 1.0f;
box_marker.color.b = 0.0f;
box_marker.color.a = 1.0f;
// Add a control for interaction
visualization_msgs::msg::InteractiveMarkerControl button_control;
button_control.name = "button_control"; // Ensure the control name is unique and relevant
button_control.interaction_mode = visualization_msgs::msg::InteractiveMarkerControl::BUTTON;
button_control.always_visible = true;
// Create a marker for the box
button_control.markers.push_back(box_marker); // Add the box marker to the control
int_marker.controls.push_back(button_control); // Add the control to the interactive marker
server_->insert(int_marker, std::bind(&BasicControlsNode::processBoxClick, this, std::placeholders::_1)); // Callback function processBoxClick is assigned using server_->setCallback
RCLCPP_DEBUG(get_logger(), "Callback bound to marker: %s", int_marker.name.c_str());
server_->applyChanges();
RCLCPP_DEBUG(get_logger(), "Marker '%s' inserted and changes applied to InteractiveMarkerServer.", int_marker.name.c_str());
I am using ros2 rolling and RViz version 14.3.3 (ROS 2). When i click on CUBE marker callback is not working.
This is my code:
void BasicControlsNode::createBoxMarker(const tf2::Vector3 &position)
{
visualization_msgs::msg::InteractiveMarker int_marker;
int_marker.header.frame_id = "base_link";
int_marker.header.stamp = this->get_clock()->now();
int_marker.name = "box_marker_" + std::to_string(position.x()) + "_" + std::to_string(position.y());
int_marker.description = "Interactive Box Marker";
int_marker.scale = 1.0;
int_marker.pose.position.x = position.x();
int_marker.pose.position.y = position.y();
int_marker.pose.position.z = position.z();
}
/// dfk//
void BasicControlsNode::processBoxClick(const visualization_msgs::msg::InteractiveMarkerFeedback::ConstSharedPtr &feedback)
{
RCLCPP_DEBUG(get_logger(), "Received feedback: %s with event type: %d", feedback->marker_name.c_str(), feedback->event_type);
}
The text was updated successfully, but these errors were encountered: