Interactive markers from within rviz tool
Hello ros community.
I have been writing a tool for rviz and ran into the problem, that all the tutorials for Interactive markers suggest that I use separate rosnode (a server). If I do so, user will have to add InteractiveMarkerDisplay manually as well as running separate rosnode. However, I would like the tool be fully self-dependant. So I tried drawing interactive markers from within the tool's code, but if any controls are added to a marker, the following errors occur:
rviz: /build/ogre-1.9-kiU5_5/ogre-1.9-1.9.0+dfsg1/OgreMain/include/OgreAxisAlignedBox.h:251: void Ogre::AxisAlignedBox::setExtents(const Ogre::Vector3&, const Ogre::Vector3&): Assertion `(min.x <= max.x && min.y <= max.y && min.z <= max.z) && "The minimum corner of the box must be less than or equal to maximum corner"' failed.
rviz: /build/ogre-1.9-kiU5_5/ogre-1.9-1.9.0+dfsg1/OgreMain/src/OgreNode.cpp:405: virtual void Ogre::Node::setPosition(const Ogre::Vector3&): Assertion `!pos.isNaN() && "Invalid vector supplied as parameter"' failed.
What am I missing, and is it even possible to put interactive markers without using InteractiveMarkerClient (display in particular) and InteractiveMarkerServer?
There is a part of the code I've written:
void ControlTool::activate(){
// Regular marker
visualization_msgs::Marker marker_msg;
marker_msg.type = visualization_msgs::Marker::CUBE;
marker_msg.scale.x = 0.45;
marker_msg.scale.y = 0.45;
marker_msg.scale.z = 0.45;
marker_msg.color.r = 0.5;
marker_msg.color.g = 0.5;
marker_msg.color.b = 0.5;
marker_msg.color.a = 1.0;
marker_msg.id = 1;
marker_msg.pose.position.x = 0;
marker_msg.pose.position.y = 0;
marker_msg.pose.position.z = 0;
// Control
visualization_msgs::InteractiveMarkerControl control_msg;
control_msg.interaction_mode = visualization_msgs::InteractiveMarkerControl::BUTTON;
control_msg.always_visible = true;
control_msg.always_visible = true;
control_msg.independent_marker_orientation = true;
control_msg.name = "control1";
// control_msg.orientation = IDENTITY by default
control_msg.orientation_mode = visualization_msgs::InteractiveMarkerControl::INHERIT;
control_msg.markers.push_back(marker_msg);
// Interactive marker
visualization_msgs::InteractiveMarker int_marker_msg;
int_marker_msg.header.frame_id = "base_link";
int_marker_msg.pose.position.y = 0;
int_marker_msg.scale = 1;
int_marker_msg.name = "marker1";
int_marker_msg.controls.push_back(control_msg);
// Scene node
Ogre::SceneNode* node = context_->getSceneManager()->getRootSceneNode()->createChildSceneNode();
node->setPosition(0, 0, 0);
ROS_INFO("InteractiveMarker");
rviz::InteractiveMarker* im = new rviz::InteractiveMarker(node, context_);
ROS_INFO("Control");
rviz::InteractiveMarkerControl* im_control = new rviz::InteractiveMarkerControl(context_, node, im);
ROS_INFO("InteractiveMarker process msg");
im->processMessage(int_marker_msg);
}