Maj commentaires rvizInterface
This commit is contained in:
parent
6f092b36d4
commit
60ba96e9d1
5 changed files with 80 additions and 65 deletions
|
@ -8,9 +8,13 @@
|
|||
|
||||
unsigned int InteractiveObject::nextObjectID = 1;
|
||||
|
||||
/*
|
||||
* Constructor.
|
||||
*
|
||||
/* Interactive object 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)
|
||||
{
|
||||
|
@ -33,7 +37,11 @@ InteractiveObject::InteractiveObject(interactive_markers::InteractiveMarkerServe
|
|||
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)
|
||||
{
|
||||
//// Création d'un marker interactif ////
|
||||
|
@ -62,7 +70,10 @@ void InteractiveObject::createInteractiveMarker(Marker& marker, const std::strin
|
|||
_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 )
|
||||
{
|
||||
_followObject = false; //Objet manipulé -> on les libèrent
|
||||
|
@ -106,7 +117,8 @@ void InteractiveObject::processFeedback( const InteractiveMarkerFeedbackConstPtr
|
|||
updateVisuals();
|
||||
}
|
||||
|
||||
//Ajoute une fonction bouton
|
||||
/* Add a Button interaction to the marker.
|
||||
*/
|
||||
void InteractiveObject::addButtoncontrol()
|
||||
{
|
||||
//// Ajout d'interactions ////
|
||||
|
@ -123,7 +135,8 @@ void InteractiveObject::addButtoncontrol()
|
|||
_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()
|
||||
{
|
||||
//// Ajout d'interactions ////
|
||||
|
@ -179,7 +192,9 @@ void InteractiveObject::add6DOFcontrol()
|
|||
_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()
|
||||
{
|
||||
//// Ajout d'interactions ////
|
||||
|
@ -226,7 +241,9 @@ void InteractiveObject::add3DOFcontrol()
|
|||
_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)
|
||||
{
|
||||
//// Ajout d'interactions ////
|
||||
|
@ -254,7 +271,9 @@ void InteractiveObject::add3DOFcontrol(const tf::Vector3& normal)
|
|||
_server->applyChanges();
|
||||
}
|
||||
|
||||
//Met à jour la zone d'erreur
|
||||
/* Set the error area.
|
||||
* error : new error margin.
|
||||
*/
|
||||
void InteractiveObject::setErrorArea(double error)
|
||||
{
|
||||
_showVisuals = true;
|
||||
|
@ -264,7 +283,9 @@ void InteractiveObject::setErrorArea(double error)
|
|||
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)
|
||||
{
|
||||
tf::pointTFToMsg(new_pos, _int_marker.pose.position);
|
||||
|
@ -274,7 +295,8 @@ void InteractiveObject::moveTo(const tf::Vector3& new_pos)
|
|||
updateVisuals();
|
||||
}
|
||||
|
||||
//Ajoute des infos visuelles (Zone d'erreur)
|
||||
/* Add visualization informations (Error Margin).
|
||||
*/
|
||||
void InteractiveObject::addVisuals()
|
||||
{
|
||||
// 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()
|
||||
{
|
||||
// ROS_INFO_STREAM("Update visuals");
|
||||
|
|
|
@ -36,35 +36,29 @@ protected:
|
|||
ros::Publisher* _visual_pub;
|
||||
|
||||
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));
|
||||
|
||||
//Construit un InteractiveMarker
|
||||
//Interactive marker Constructor.
|
||||
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 );
|
||||
|
||||
//Ajoute une fonction bouton
|
||||
void addButtoncontrol();
|
||||
//Ajoute des controle pour 6DOF (Déplacement dans l'espace)
|
||||
void add6DOFcontrol();
|
||||
//Ajoute des controle pour 3DOF (Déplacement dans le plan x/z)
|
||||
void add3DOFcontrol();
|
||||
//Ajoute des controle pour 3DOF (Déplacement dans le plan)
|
||||
void add3DOFcontrol(const tf::Vector3& normal);
|
||||
//Controls
|
||||
void addButtoncontrol(); //Add a Button interaction to the marker.
|
||||
void add3DOFcontrol(); //Add a 3 Degrees of Freedom control to the marker allowing it to be moved in the X/Z plan.
|
||||
void add3DOFcontrol(const tf::Vector3& normal); //Add a 3 Degrees of Freedom control to the marker allowing it to be moved in a plan.
|
||||
void add6DOFcontrol(); //Add a 6 Degrees of Freedom control to the marker allowing it to be moved in 3D.
|
||||
|
||||
//Ajoute des infos visuelles (Zone d'erreur)
|
||||
void addVisuals();
|
||||
//Rafraichis les infos visuelles
|
||||
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);
|
||||
//Visuals
|
||||
void addVisuals(); //Add visualization informations (Error Margin).
|
||||
void updateVisuals(); //Update the visualization informations.
|
||||
|
||||
//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;}
|
||||
void setObjectivePublisher(ros::Publisher* objective_pub){ _objective_pub=objective_pub;}
|
||||
void setVisualizationPublisher(ros::Publisher* visualization_pub){ _visual_pub=visualization_pub;}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
namespace rviz_interface
|
||||
{
|
||||
|
||||
/* Constructor
|
||||
* parent : QT widget parent.
|
||||
*/
|
||||
InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
/* Destructor
|
||||
*/
|
||||
InterfacePanel::~InterfacePanel()
|
||||
{
|
||||
delete _max_error_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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
current_config.follow_object = true;
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
|
||||
#include "RvizInterface.hpp"
|
||||
|
||||
/*
|
||||
* Constructor.
|
||||
/* Constructor.
|
||||
* Launch the Rviz Interface with on the parameters from the launch file.
|
||||
* 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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
//PROVISOIRE : Pour un seul objet avec test PCL
|
||||
// void RvizInterface::positionCallback(const geometry_msgs::PointStamped & new_center)
|
||||
// {
|
||||
// //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
|
||||
/* Callback function handling the position updates of markers.
|
||||
* new_center : ROS message containing the current position of an object.
|
||||
* @see : NamedPoint.msg
|
||||
*/
|
||||
void RvizInterface::positionCallback(const rviz_interface::NamedPoint & new_center)
|
||||
{
|
||||
for(unsigned int i=0;i<_objects.size();i++)
|
||||
|
|
|
@ -39,14 +39,11 @@ protected:
|
|||
std::vector<InteractiveObject*> _objects;
|
||||
|
||||
public:
|
||||
RvizInterface(const std::string & server_topic);
|
||||
~RvizInterface();
|
||||
RvizInterface(const std::string & server_topic); //Constructor
|
||||
~RvizInterface(); //Destructor
|
||||
|
||||
//Fonction Callback du panel Rviz gérant les configurations
|
||||
void configCallback(const rviz_interface::InterfaceConfig & new_config);
|
||||
|
||||
//Fonction callback gérant la position des objets
|
||||
void positionCallback(const rviz_interface::NamedPoint & new_center);
|
||||
void configCallback(const rviz_interface::InterfaceConfig & new_config); //Callback function for the Rviz panel handling configuration changes.
|
||||
void positionCallback(const rviz_interface::NamedPoint & new_center); //Callback function handling the position updates of markers.
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue