25 #include <ISM/utility/Util.hpp> 32 #define KEYCODE_AUTOMATIC_PROCESSING 0x20 //space 33 #define KEYCODE_PROCESS_ONLY_MARKED 0x6D //m 35 #define KEYCODE_PROCESS_CONFIGURATION 0x0A //enter 37 #define KEYCODE_RESET 0x7F //delete or backspace 38 #define KEYCODE_ADD 0x61 //a 39 #define KEYCODE_SHOW 0x73 //s 40 #define KEYCODE_REMOVE 0x64 //d 41 #define KEYCODE_UPDATE_VIEW 0x75 //u 43 #define KEYCODE_HELP 0x68 //h 47 : processKeyboardInputFunc_(processKeyboardInputFunc), processObjectInputFunc_(processObjectInputFunc)
51 assert(!processConfigFunc.empty());
56 std::string object_input_topic;
57 int object_input_queue_size;
58 int object_input_thread_count;
59 bool ignore_ids, ignore_types;
60 std::string base_frame;
61 bool use_confidence_from_msg;
62 int enable_rotation_mode;
63 std::string rotation_frame, rotation_object_type, rotation_object_id;
64 bool enable_neighborhood_evaluation;
65 double neighbour_angle_threshold, neighbour_distance_threshold;
66 double automatic_processing_interval;
67 int keyboard_poll_rate;
68 std::string input_visualization_topic;
70 getNodeParameters(object_input_topic, object_input_queue_size, object_input_thread_count, base_frame, ignore_types, ignore_ids, use_confidence_from_msg,
71 enable_rotation_mode, rotation_frame, rotation_object_type, rotation_object_id,
72 enable_neighborhood_evaluation, neighbour_angle_threshold, neighbour_distance_threshold,
73 keyboard_poll_rate, automatic_processing_interval, input_visualization_topic);
143 boost::this_thread::interruption_point();
150 catch (boost::thread_interrupted&) {}
157 int temp_key_value = getchar();
158 tcflush(STDIN_FILENO, TCIFLUSH);
170 switch(temp_key_value)
197 switch(temp_key_value)
200 ISM::printRed(
"\tRESET\n");
204 ISM::printBlue(
"\tADD\n");
208 ISM::printBlue(
"\tREMOVE\n");
212 ISM::printGreen(
"\tPROCESS_CONFIGURATION!\n");
216 ISM::printBlue(
"\tSHOW_CONFIGURATION\n");
220 ISM::printBlue(
"\tUPDATE_VIEW\n");
238 ROS_DEBUG_STREAM(
"Received object message. THREAD-ID: " << boost::this_thread::get_id());
243 ROS_DEBUG(
"Rejected object message and clean estimations since camera is currently moving ");
272 bool stopped =
false;
273 bool retrieved =
ptu_->getParam(
"reached_desired_position", stopped);
274 isInMotion = !stopped && retrieved;
282 if (
set->objects.empty())
284 ISM::printRed(
"Configuration is empty!\n");
298 ISM::printGreen(
"\tAUTO_PROCESS_CONFIGURATION!\n");
310 ISM::printGreen(
"Marked and in view:\n");
313 if (est->marked && est->in_view)
315 std::cout <<
"\t" << est->object->type <<
" " << est->object->observedId << std::endl;
318 ISM::printBlue(
"Marked and out of view:\n");
321 if (est->marked && !est->in_view)
323 std::cout <<
"\t" << est->object->type <<
" " << est->object->observedId << std::endl;
326 ISM::printYellow(
"Not marked:\n");
331 std::cout <<
"\t" << est->object->type <<
" " << est->object->observedId << std::endl;
334 std::cout << std::endl;
339 std::stringstream commands;
342 commands <<
"Commands for Auto Processing:\n" 343 <<
"\tpress \"m\"\tchange PROCESSING_MODE\n" 344 <<
"\tpress \"space\"\tswitch to Manual Processing\n\n" 345 <<
"\tpress \"h\"\tshow INFO and COMMAND description\n" 346 <<
"\tpress \"^C\"\tquit node\n";
350 commands <<
"Commands for Manual Processing:\n" 351 <<
"\tpress \"m\"\t-change PROCESSING_MODE\n" 352 <<
"\tpress \"space\"\t-switch to Auto Processing\n\n" 353 <<
"\tpress \"enter\"\t-process object configuration\n" 354 <<
"\tpress \"delete\\\t-reset all objects\n\t backspace\"\n\n" 355 <<
"\tpress \"a\"\t-add objects from current view to marked objects\n" 356 <<
"\tpress \"d\"\t-remove objects in the current view from marked objects\n" 357 <<
"\tpress \"u\"\t-update view to get rid of old estimations\n\n" 358 <<
"\tpress \"s\"\t-show object configuration\n\n" 359 <<
"\tpress \"h\"\t-show INFO and COMMAND description\n" 360 <<
"\tpress \"^C\"\t-quit node\n";
364 ISM::printYellow(commands.str() +
"\n");
371 std::stringstream status, info;
373 info <<
"rviz color legend: ";
377 status <<
"STATUS: Auto Processing";
381 status <<
"STATUS: Manual Processing";
384 status <<
"\t\tPROCESSING_MODE: ";
388 status <<
"Only Marked Objects\n";
390 info <<
"\033[32;1m" <<
"marked and in current view (green), " 391 <<
"\033[36m" <<
"marked but not in current view (blue)." 392 <<
"\033[0m" <<
"\n";
396 status <<
"All Objects\n";
398 info <<
"\033[32;1m" <<
"marked and in current view (green), " 399 <<
"\033[36m" <<
"marked but not in current view (blue), " 400 <<
"\033[33m" <<
"not marked but in the current view (yellow)." 401 <<
"\033[0m" <<
"\n";
404 ISM::printGreen(status.str());
405 std::cout <<
"\n" << info.str() <<
"\n";
418 std::vector<ISM::ObjectPtr> objects;
419 std::map<ISM::ObjectPtr, double> objects_to_hue_map;
424 bool visualize =
false;
427 hueTemp = est->in_view ? 120.0 : 180.0;
438 objects.push_back(est->object);
439 objects_to_hue_map.insert(std::make_pair(est->object, hueTemp));
447 ROS_DEBUG(
"No subscriber exist for the visualization.\n");
451 void SceneConfigurator::getNodeParameters(std::string& object_topic,
int& queue_size,
int& object_input_thread_count, std::string& base_frame,
bool& ignore_types,
bool& ignore_ids,
bool& use_confidence_from_msg,
452 int& enable_rotation_mode, std::string& rotation_frame, std::string& rotation_object_type, std::string& rotation_object_id,
453 bool& enable_neighborhood_evaluation,
double& neighbour_angle_threshold,
double& neighbour_distance_threshold,
454 int& keyboard_poll_rate,
double& automatic_processing_interval, std::string& input_visualization_topic)
459 if (!nh.
getParam(
"objectTopic", object_topic))
461 object_topic =
"/objects";
465 if (!nh.
getParam(
"queueSizePbdObjectCallback", queue_size))
471 if (!nh.
getParam(
"object_input_thread_count", object_input_thread_count))
473 object_input_thread_count = 1;
475 ROS_INFO_STREAM(
"object_input_thread_count: " << object_input_thread_count);
477 if (!nh.
getParam(
"baseFrame", base_frame))
483 if (!nh.
getParam(
"use_confidence_from_msg", use_confidence_from_msg))
485 use_confidence_from_msg =
false;
487 ROS_INFO_STREAM(
"use_confidence_from_msg: " << use_confidence_from_msg);
489 if (!nh.
getParam(
"enableRotationMode", enable_rotation_mode))
491 enable_rotation_mode = 0;
495 if (!nh.
getParam(
"rotationFrame", rotation_frame))
497 rotation_frame =
"/map";
501 if (!nh.
getParam(
"rotationObjectType", rotation_object_type))
503 rotation_object_type =
"";
507 if (!nh.
getParam(
"rotationObjectId", rotation_object_id))
509 rotation_object_id =
"";
513 if (!nh.
getParam(
"enableNeighborhoodEvaluation", enable_neighborhood_evaluation))
515 enable_neighborhood_evaluation =
false;
517 ROS_INFO_STREAM(
"enableNeighborhoodEvaluation: " << enable_neighborhood_evaluation);
519 if (!nh.
getParam(
"angleNeighbourThreshold", neighbour_angle_threshold))
521 neighbour_angle_threshold = 30;
523 ROS_INFO_STREAM(
"angleNeighbourThreshold: " << neighbour_angle_threshold);
525 if (!nh.
getParam(
"distanceNeighbourThreshold", neighbour_distance_threshold))
527 neighbour_distance_threshold = 0.05;
529 ROS_INFO_STREAM(
"distanceNeighbourThreshold: " << neighbour_distance_threshold);
531 if (!nh.
getParam(
"keyboard_poll_rate", keyboard_poll_rate))
533 keyboard_poll_rate = 10;
537 if (!nh.
getParam(
"capture_interval", automatic_processing_interval))
539 automatic_processing_interval = 1;
543 if (!nh.
getParam(
"input_objects_visualization_topic", input_visualization_topic))
545 input_visualization_topic =
"input_objects_scene_configurator_viz";
547 ROS_INFO_STREAM(
"input_objects_visualization_topic: " << input_visualization_topic);
549 if (!nh.
getParam(
"ignoreTypes", ignore_types))
551 ignore_types =
false;
555 if (!nh.
getParam(
"ignoreIds", ignore_ids))
ISM::ObjectSetPtr getObjectSetFromAllEstimations()
ProcessKeyboardInputFunction processKeyboardInputFunc_
SceneConfigurator(ProcessConfigurationFunction processConfigFunc, ProcessKeyboardInputFunction processKeyboardInputFunc=ProcessKeyboardInputFunction(), ProcessObjectInputFunction processObjectInputFunc=ProcessObjectInputFunction())
void objectInputCallback(const asr_msgs::AsrObject &object)
void keyboardInputMain(const unsigned int poll_rate)
boost::function< void(ISM::ObjectSetPtr)> ProcessConfigurationFunction
void updateVisualizationCallback(const ros::TimerEvent &e)
boost::function< void(int)> ProcessKeyboardInputFunction
void automaticProcessingCallback(const ros::TimerEvent &e)
boost::shared_ptr< ObjectConverter > ObjectConverterPtr
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
#define KEYCODE_AUTOMATIC_PROCESSING
ros::CallbackQueue object_queue_
void clearUnmarkedEstimations()
ROSCPP_DECL const std::string & getName()
boost::function< void(ISM::ObjectPtr)> ProcessObjectInputFunction
termios original_terminal_settings_
boost::shared_ptr< NodeHandle > NodeHandlePtr
void getNodeParameters(std::string &object_topic, int &queue_size, int &object_input_thread_count, std::string &base_frame, bool &ignore_types, bool &ignore_ids, bool &use_confidence_from_msg, int &enable_rotation_mode, std::string &rotation_frame, std::string &rotation_object_type, std::string &rotation_object_id, bool &enable_neighborhood_evaluation, double &neighbour_angle_threshold, double &neighbour_distance_threshold, int &keyboard_poll_rate, double &automatic_processing_interval, std::string &visualization_topic)
ProcessObjectInputFunction processObjectInputFunc_
void addEstimation(ISM::ObjectPtr object)
ros::AsyncSpinner * spinner_
bool getAutomaticProcessingActive()
ros::Timer visualization_timer_
#define KEYCODE_PROCESS_ONLY_MARKED
void processKeyboardInput()
ROSCPP_DECL void set(const std::string &key, const XmlRpc::XmlRpcValue &v)
boost::thread * keyboard_thread_
void resetInViewForAllEstimations()
void setCallbackQueue(CallbackQueueInterface *queue)
ros::Publisher visualization_publisher_
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
bool use_only_marked_objects_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void processConfiguration()
#define ROS_DEBUG_STREAM(args)
VIZ::ObjectModelVisualizerRVIZ * object_model_visualizer_
termios modified_terminal_settings_
ISM::ObjectSetPtr getObjectSetFromMarkedEstimations()
std::vector< ObjectEstimationPtr > ObjectEstimationPtrs
uint32_t getNumSubscribers() const
#define ROS_INFO_STREAM(args)
void clearAllEstimations()
IH::ObjectConverterPtr object_msg_converter_
bool getParam(const std::string &key, std::string &s) const
#define KEYCODE_PROCESS_CONFIGURATION
#define KEYCODE_UPDATE_VIEW
ros::Subscriber object_input_subscriber_
ProcessConfigurationFunction processConfigurationFunc_
ros::Timer automatic_processing_timer_
#define ROS_ERROR_STREAM(args)
bool automatic_processing_active_
SceneConfiguratorData * data_
void setMarkedForAllEstimationsInView(bool marked)
ObjectEstimationPtrs getAllEstimations()