void init_markers() { //initialize stamped pose for at a legal (if boring) pose g_stamped_pose.header.stamp = ros::Time::now(); g_stamped_pose.header.frame_id = "world"; g_stamped_pose.pose.position.x = 0; g_stamped_pose.pose.position.y = 0; g_stamped_pose.pose.position.z = 0; g_stamped_pose.pose.orientation.x = 0; g_stamped_pose.pose.orientation.y = 0; g_stamped_pose.pose.orientation.z = 0; g_stamped_pose.pose.orientation.w = 1; //the following parameters only need to get set once arrow_marker_x.type = visualization_msgs::Marker::ARROW; arrow_marker_x.action = visualization_msgs::Marker::ADD; //create or modify marker arrow_marker_x.ns = "triad_namespace"; arrow_marker_x.lifetime = ros::Duration(); //never delete // make the arrow thin arrow_marker_x.scale.x = 0.01; arrow_marker_x.scale.y = 0.01; arrow_marker_x.scale.z = 0.01; arrow_marker_x.color.r = 1.0; // red, for the x axis arrow_marker_x.color.g = 0.0; arrow_marker_x.color.b = 0.0; arrow_marker_x.color.a = 1.0; arrow_marker_x.id = 0; arrow_marker_x.header = g_stamped_pose.header; //y and z arrow params are the same, except for colors arrow_marker_y = arrow_marker_x; arrow_marker_y.color.r = 0.0; arrow_marker_y.color.g = 1.0; //green for y axis arrow_marker_y.color.b = 0.0; arrow_marker_y.color.a = 1.0; arrow_marker_y.id = 1; arrow_marker_z = arrow_marker_x; arrow_marker_z.id = 2; arrow_marker_z.color.r = 0.0; arrow_marker_z.color.g = 0.0; arrow_marker_z.color.b = 1.0; //blue for z axis arrow_marker_z.color.a = 1.0; //set the poses of the arrows based on g_stamped_pose update_arrows(); }
int main(int argc, char** argv) { ros::init(argc, argv, "triad_display"); // this will be the node name; ros::NodeHandle nh; // subscribe to stamped-pose publications ros::Subscriber pose_sub = nh.subscribe("triad_display_pose", 1, poseCB); ros::Publisher vis_pub = nh.advertise<visualization_msgs::Marker>("triad_display", 1); init_markers(); ros::Rate timer(20); //timer to run at 20 Hz while (ros::ok()) { update_arrows(); vis_pub.publish(arrow_marker_x); //publish the marker ros::Duration(0.01).sleep(); vis_pub.publish(arrow_marker_y); //publish the marker ros::Duration(0.01).sleep(); vis_pub.publish(arrow_marker_z); //publish the marker ros::spinOnce(); //let callbacks perform an update timer.sleep(); } }
GUI_status ScrollWidgetGump::scroll_movement_event(ScrollEventType event) { switch(event) { case SCROLL_UP : if(position > 0) { //timer = new TimedCallback(this, NULL, 2000); position--; update_arrows(); //grab_focus(); } return GUI_YUM; case SCROLL_DOWN : //timer = new TimedCallback(this, NULL, 2000); if(page_break && position + scroll_height >= msg_buf.size()) { if(position + scroll_height == msg_buf.size()) // break was just off the page so advance text position++; process_page_break(); update_arrows(); } else if(position + scroll_height < msg_buf.size()) { position++; update_arrows(); } return (GUI_YUM); case SCROLL_PAGE_UP: if(position > 0) { position = position > scroll_height ? position - scroll_height : 0; update_arrows(); } return GUI_YUM; case SCROLL_PAGE_DOWN: if(position + scroll_height < msg_buf.size() || page_break) { if(position + scroll_height >= msg_buf.size()) position = msg_buf.size(); else { position += scroll_height; update_arrows(); return GUI_YUM; } if(page_break) // we didn't have enough text showing to fill out the current page. { position = msg_buf.size(); process_page_break(); } update_arrows(); } return GUI_YUM; case SCROLL_TO_BEGINNING : if(position > 0) { position = 0; update_arrows(); } return GUI_YUM; case SCROLL_TO_END : if(position + scroll_height < msg_buf.size() || page_break) { while(position + scroll_height < msg_buf.size() || page_break) { if(page_break) process_page_break(); else // added else just in case noting is added to the buffer position++; } update_arrows(); } return GUI_YUM; default : //release_focus(); //new TimedCallback(this, NULL, 50); break; } return GUI_PASS; }
void ScrollWidgetGump::display_string(std::string s) { MsgScroll::display_string(s); update_arrows(); }