Maj commentaires rvizInterface

This commit is contained in:
Unknown 2018-08-17 11:50:56 +02:00
parent 6f092b36d4
commit 60ba96e9d1
5 changed files with 80 additions and 65 deletions

View file

@ -8,9 +8,13 @@
unsigned int InteractiveObject::nextObjectID = 1; unsigned int InteractiveObject::nextObjectID = 1;
/* /* Interactive object Constructor.
* Constructor. * server : interactiveMarkers server.
* * name : name of the object.
* frame_id : frame associated to the marker.
* type : marker type (Ordinary, Bool, 2D, 3D).
* shape : shape of the marker.
* position : intial position.
*/ */
InteractiveObject::InteractiveObject(interactive_markers::InteractiveMarkerServer* server, const std::string& name, const std::string& frame_id, unsigned int type, unsigned int shape = Marker::CUBE, const tf::Vector3& position) : _name(name), _type(type), _server(server), _showVisuals(true), _followObject(true) InteractiveObject::InteractiveObject(interactive_markers::InteractiveMarkerServer* server, const std::string& name, const std::string& frame_id, unsigned int type, unsigned int shape = Marker::CUBE, const tf::Vector3& position) : _name(name), _type(type), _server(server), _showVisuals(true), _followObject(true)
{ {
@ -33,7 +37,11 @@ InteractiveObject::InteractiveObject(interactive_markers::InteractiveMarkerServe
addButtoncontrol(); addButtoncontrol();
} }
//Construit un InteractiveMarker /* Interactive marker Constructor.
* marker : marker on which interaction will be possible.
* frame_id : frame associated to the marker.
* position : intial position.
*/
void InteractiveObject::createInteractiveMarker(Marker& marker, const std::string& frame_id, const tf::Vector3& position) void InteractiveObject::createInteractiveMarker(Marker& marker, const std::string& frame_id, const tf::Vector3& position)
{ {
//// Création d'un marker interactif //// //// Création d'un marker interactif ////
@ -62,7 +70,10 @@ void InteractiveObject::createInteractiveMarker(Marker& marker, const std::strin
_server->applyChanges(); _server->applyChanges();
} }
//Fonction callback du serveur d' InteractiveMarker /* Callback function used by the InteractiveMarkerServer to update markers.
* Handle objective publishing.
* feedback : feedback containing the interaction with the marker.
*/
void InteractiveObject::processFeedback( const InteractiveMarkerFeedbackConstPtr &feedback ) void InteractiveObject::processFeedback( const InteractiveMarkerFeedbackConstPtr &feedback )
{ {
_followObject = false; //Objet manipulé -> on les libèrent _followObject = false; //Objet manipulé -> on les libèrent
@ -106,7 +117,8 @@ void InteractiveObject::processFeedback( const InteractiveMarkerFeedbackConstPtr
updateVisuals(); updateVisuals();
} }
//Ajoute une fonction bouton /* Add a Button interaction to the marker.
*/
void InteractiveObject::addButtoncontrol() void InteractiveObject::addButtoncontrol()
{ {
//// Ajout d'interactions //// //// Ajout d'interactions ////
@ -123,7 +135,8 @@ void InteractiveObject::addButtoncontrol()
_server->applyChanges(); _server->applyChanges();
} }
//Ajoute des controle pour 6DOF (Déplacement dans l'espace) /* Add a 6 Degrees of Freedom control to the marker allowing it to be moved in 3D.
*/
void InteractiveObject::add6DOFcontrol() void InteractiveObject::add6DOFcontrol()
{ {
//// Ajout d'interactions //// //// Ajout d'interactions ////
@ -179,7 +192,9 @@ void InteractiveObject::add6DOFcontrol()
_server->applyChanges(); _server->applyChanges();
} }
//Ajoute des controle pour 3DOF (Déplacement dans le plan x/z)
/* Add a 3 Degrees of Freedom control to the marker allowing it to be moved in the X/Z plan.
*/
void InteractiveObject::add3DOFcontrol() void InteractiveObject::add3DOFcontrol()
{ {
//// Ajout d'interactions //// //// Ajout d'interactions ////
@ -226,7 +241,9 @@ void InteractiveObject::add3DOFcontrol()
_server->applyChanges(); _server->applyChanges();
} }
//Ajoute des controle pour 3DOF (Déplacement dans le plan) /* Add a 3 Degrees of Freedom control to the marker allowing it to be moved in a plan.
* normal : normal vector defining a plan.
*/
void InteractiveObject::add3DOFcontrol(const tf::Vector3& normal) void InteractiveObject::add3DOFcontrol(const tf::Vector3& normal)
{ {
//// Ajout d'interactions //// //// Ajout d'interactions ////
@ -254,7 +271,9 @@ void InteractiveObject::add3DOFcontrol(const tf::Vector3& normal)
_server->applyChanges(); _server->applyChanges();
} }
//Met à jour la zone d'erreur /* Set the error area.
* error : new error margin.
*/
void InteractiveObject::setErrorArea(double error) void InteractiveObject::setErrorArea(double error)
{ {
_showVisuals = true; _showVisuals = true;
@ -264,7 +283,9 @@ void InteractiveObject::setErrorArea(double error)
updateVisuals(); updateVisuals();
} }
//Déplace le marker à une position donnée /* Move the marker to a new position.
* new_pos : new position of the marker.
*/
void InteractiveObject::moveTo(const tf::Vector3& new_pos) void InteractiveObject::moveTo(const tf::Vector3& new_pos)
{ {
tf::pointTFToMsg(new_pos, _int_marker.pose.position); tf::pointTFToMsg(new_pos, _int_marker.pose.position);
@ -274,7 +295,8 @@ void InteractiveObject::moveTo(const tf::Vector3& new_pos)
updateVisuals(); updateVisuals();
} }
//Ajoute des infos visuelles (Zone d'erreur) /* Add visualization informations (Error Margin).
*/
void InteractiveObject::addVisuals() void InteractiveObject::addVisuals()
{ {
// Set the frame ID and timestamp. See the TF tutorials for information on these. // Set the frame ID and timestamp. See the TF tutorials for information on these.
@ -302,7 +324,8 @@ void InteractiveObject::addVisuals()
} }
} }
//Rafraichis les infos visuelles /* Update the visualization informations.
*/
void InteractiveObject::updateVisuals() void InteractiveObject::updateVisuals()
{ {
// ROS_INFO_STREAM("Update visuals"); // ROS_INFO_STREAM("Update visuals");

View file

@ -36,35 +36,29 @@ protected:
ros::Publisher* _visual_pub; ros::Publisher* _visual_pub;
public: public:
//Interactive object Constructor.
InteractiveObject(interactive_markers::InteractiveMarkerServer* server, const std::string& name, const std::string& frame_id, unsigned int type, unsigned int shape, const tf::Vector3& position = tf::Vector3(0,0,0)); InteractiveObject(interactive_markers::InteractiveMarkerServer* server, const std::string& name, const std::string& frame_id, unsigned int type, unsigned int shape, const tf::Vector3& position = tf::Vector3(0,0,0));
//Construit un InteractiveMarker //Interactive marker Constructor.
void createInteractiveMarker(Marker& marker, const std::string& frame_id, const tf::Vector3& position = tf::Vector3(0,0,0)); void createInteractiveMarker(Marker& marker, const std::string& frame_id, const tf::Vector3& position = tf::Vector3(0,0,0));
//Fonction callback du serveur d' InteractiveMarker //Callback function used by the InteractiveMarkerServer to update markers.
void processFeedback( const InteractiveMarkerFeedbackConstPtr &feedback ); void processFeedback( const InteractiveMarkerFeedbackConstPtr &feedback );
//Ajoute une fonction bouton //Controls
void addButtoncontrol(); void addButtoncontrol(); //Add a Button interaction to the marker.
//Ajoute des controle pour 6DOF (Déplacement dans l'espace) void add3DOFcontrol(); //Add a 3 Degrees of Freedom control to the marker allowing it to be moved in the X/Z plan.
void add6DOFcontrol(); void add3DOFcontrol(const tf::Vector3& normal); //Add a 3 Degrees of Freedom control to the marker allowing it to be moved in a plan.
//Ajoute des controle pour 3DOF (Déplacement dans le plan x/z) void add6DOFcontrol(); //Add a 6 Degrees of Freedom control to the marker allowing it to be moved in 3D.
void add3DOFcontrol();
//Ajoute des controle pour 3DOF (Déplacement dans le plan)
void add3DOFcontrol(const tf::Vector3& normal);
//Ajoute des infos visuelles (Zone d'erreur) //Visuals
void addVisuals(); void addVisuals(); //Add visualization informations (Error Margin).
//Rafraichis les infos visuelles void updateVisuals(); //Update the visualization informations.
void updateVisuals();
//Met à jour la zone d'erreur
void setErrorArea(double error);
//Déplace le marker à une position donnée
void moveTo(const tf::Vector3& new_pos);
//Accesseurs //Accesseurs
void setErrorArea(double error); //Set the error area.
void moveTo(const tf::Vector3& new_pos); //Move the marker to a new position.
const std::string& name() const{ return _name;} const std::string& name() const{ return _name;}
void setObjectivePublisher(ros::Publisher* objective_pub){ _objective_pub=objective_pub;} void setObjectivePublisher(ros::Publisher* objective_pub){ _objective_pub=objective_pub;}
void setVisualizationPublisher(ros::Publisher* visualization_pub){ _visual_pub=visualization_pub;} void setVisualizationPublisher(ros::Publisher* visualization_pub){ _visual_pub=visualization_pub;}

View file

@ -9,6 +9,9 @@
namespace rviz_interface namespace rviz_interface
{ {
/* Constructor
* parent : QT widget parent.
*/
InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent ) InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent )
{ {
QHBoxLayout* error_layout = new QHBoxLayout; QHBoxLayout* error_layout = new QHBoxLayout;
@ -40,13 +43,16 @@ InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent )
_config_publisher = _nh.advertise<rviz_interface::InterfaceConfig>( "/RvizInterface/interface_config", 1 ); _config_publisher = _nh.advertise<rviz_interface::InterfaceConfig>( "/RvizInterface/interface_config", 1 );
} }
/* Destructor
*/
InterfacePanel::~InterfacePanel() InterfacePanel::~InterfacePanel()
{ {
delete _max_error_editor; delete _max_error_editor;
delete _objective_type_editor; delete _objective_type_editor;
} }
//Update the error in the current_configuration & publish the configuration. /* Update the error in the current_configuration & publish the configuration.
*/
void InterfacePanel::updateError() void InterfacePanel::updateError()
{ {
current_config.max_error = _max_error_editor->text().toDouble(); current_config.max_error = _max_error_editor->text().toDouble();
@ -57,7 +63,9 @@ void InterfacePanel::updateError()
} }
} }
//Update the objective type (ie Precise or not) in the current_configuration & publish the configuration. /* Update the objective type (ie Precise or not) in the current_configuration & publish the configuration.
* state : New objective type (1 : Precise).
*/
void InterfacePanel::updateType(int state) void InterfacePanel::updateType(int state)
{ {
current_config.objective_type = state; current_config.objective_type = state;
@ -76,7 +84,9 @@ void InterfacePanel::updateType(int state)
} }
} }
//Update the visual flag (ie Show visuals or not) in the current_configuration & publish the configuration. /* Update the visual flag (ie Show visuals or not) in the current_configuration & publish the configuration.
* state : Visual flag (1 : Show visuals).
*/
void InterfacePanel::updateVisuals(int state) void InterfacePanel::updateVisuals(int state)
{ {
current_config.show_visuals = state; current_config.show_visuals = state;
@ -86,7 +96,8 @@ void InterfacePanel::updateVisuals(int state)
} }
} }
//Send a signal through the configuration telling the subscriber to follow the object it's linked to. /* Send a signal through the configuration telling the subscriber to follow the object it's linked to.
*/
void InterfacePanel::handleResetButton() void InterfacePanel::handleResetButton()
{ {
current_config.follow_object = true; current_config.follow_object = true;

View file

@ -7,8 +7,7 @@
#include "RvizInterface.hpp" #include "RvizInterface.hpp"
/* /* Constructor.
* Constructor.
* Launch the Rviz Interface with on the parameters from the launch file. * Launch the Rviz Interface with on the parameters from the launch file.
* server_topic : Topic name of the interactive markers server. * server_topic : Topic name of the interactive markers server.
*/ */
@ -88,7 +87,7 @@ RvizInterface::RvizInterface(const std::string & server_topic): _server(server_t
} }
} }
//Destructeur //Destructor
RvizInterface::~RvizInterface() RvizInterface::~RvizInterface()
{ {
for(unsigned int i=0;i<_objects.size();i++) for(unsigned int i=0;i<_objects.size();i++)
@ -97,7 +96,11 @@ RvizInterface::~RvizInterface()
} }
} }
//Fonction Callback du panel Rviz gérant les configurations
/* Callback function for the Rviz panel handling configuration changes.
* new_config : ROS message containing the new configuration.
* @see InterfaceConfig.msg
*/
void RvizInterface::configCallback(const rviz_interface::InterfaceConfig & new_config) void RvizInterface::configCallback(const rviz_interface::InterfaceConfig & new_config)
{ {
for(unsigned int i=0;i<_objects.size();i++) for(unsigned int i=0;i<_objects.size();i++)
@ -113,23 +116,10 @@ void RvizInterface::configCallback(const rviz_interface::InterfaceConfig & new_c
} }
} }
//Fonction callback gérant la position de l'objet /* Callback function handling the position updates of markers.
//PROVISOIRE : Pour un seul objet avec test PCL * new_center : ROS message containing the current position of an object.
// void RvizInterface::positionCallback(const geometry_msgs::PointStamped & new_center) * @see : NamedPoint.msg
// { */
// //Synchro des frames
// _objects[0]->int_marker().header.frame_id = new_center.header.frame_id;
// _objects[0]->err_marker().header.frame_id = new_center.header.frame_id;
// if(_objects[0]->isFollowing()) //Le marqueur suit l'objet
// {
// //Deplacement du marqueur
// tf::Vector3 position = tf::Vector3(new_center.point.x,new_center.point.y,new_center.point.z);
// _objects[0]->moveTo(position);
// }
// }
//Fonction callback gérant la position des objets
void RvizInterface::positionCallback(const rviz_interface::NamedPoint & new_center) void RvizInterface::positionCallback(const rviz_interface::NamedPoint & new_center)
{ {
for(unsigned int i=0;i<_objects.size();i++) for(unsigned int i=0;i<_objects.size();i++)

View file

@ -39,14 +39,11 @@ protected:
std::vector<InteractiveObject*> _objects; std::vector<InteractiveObject*> _objects;
public: public:
RvizInterface(const std::string & server_topic); RvizInterface(const std::string & server_topic); //Constructor
~RvizInterface(); ~RvizInterface(); //Destructor
//Fonction Callback du panel Rviz gérant les configurations void configCallback(const rviz_interface::InterfaceConfig & new_config); //Callback function for the Rviz panel handling configuration changes.
void configCallback(const rviz_interface::InterfaceConfig & new_config); void positionCallback(const rviz_interface::NamedPoint & new_center); //Callback function handling the position updates of markers.
//Fonction callback gérant la position des objets
void positionCallback(const rviz_interface::NamedPoint & new_center);
}; };
#endif #endif