Ajout commentaires
This commit is contained in:
parent
1cd55aba7a
commit
6b4be0fecb
17 changed files with 73897 additions and 43726 deletions
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* Rviz interactive object.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : RvizInterface.cpp/.hpp
|
||||
*/
|
||||
|
||||
#include "InteractiveObject.hpp"
|
||||
|
||||
unsigned int InteractiveObject::nextObjectID = 1;
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* Rviz interactive object.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : RvizInterface.cpp/.hpp
|
||||
*/
|
||||
|
||||
#ifndef INTERACTIVEOBJECT_HPP
|
||||
#define INTERACTIVEOBJECT_HPP
|
||||
|
||||
|
|
|
@ -1,35 +1,21 @@
|
|||
/*
|
||||
* Rviz panel for the configuration of the RvizInterface.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : RvizInterface.cpp/.hpp
|
||||
*/
|
||||
|
||||
#include "InterfacePanel.hpp"
|
||||
|
||||
namespace rviz_interface
|
||||
{
|
||||
|
||||
// BEGIN_TUTORIAL
|
||||
// Here is the implementation of the InterfacePanel class. InterfacePanel
|
||||
// has these responsibilities:
|
||||
//
|
||||
// - Act as a container for GUI elements DriveWidget and QLineEdit.
|
||||
// - Publish command velocities 10 times per second (whether 0 or not).
|
||||
// - Saving and restoring internal state from a config file.
|
||||
//
|
||||
// We start with the constructor, doing the standard Qt thing of
|
||||
// passing the optional *parent* argument on to the superclass
|
||||
// constructor, and also zero-ing the velocities we will be
|
||||
// publishing.
|
||||
InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent )
|
||||
{
|
||||
// Next we lay out the "output topic" text entry field using a
|
||||
// QLabel and a QLineEdit in a QHBoxLayout.
|
||||
QHBoxLayout* error_layout = new QHBoxLayout;
|
||||
error_layout->addWidget( new QLabel( "Max Error:" ));
|
||||
_max_error_editor = new QLineEdit;
|
||||
// max_error_editor->setValidator( new QDoubleValidator(0,MAX_ERROR,1000,max_error_editor)); // Ne gère pas les exceptions tout seul (retourne QValidator::Intermediate pour les valeurs hors bornes)
|
||||
error_layout->addWidget( _max_error_editor );
|
||||
//setLayout( error_layout );
|
||||
error_layout->addWidget( _max_error_editor );
|
||||
|
||||
// Then create the control widget.
|
||||
// drive_widget_ = new DriveWidget;
|
||||
|
||||
// Lay out the topic field above the control widget.
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
_objective_type_editor = new QCheckBox( "Precise Objective" );
|
||||
_show_visuals_editor = new QCheckBox( "Show Visuals" );
|
||||
|
@ -41,29 +27,14 @@ InterfacePanel::InterfacePanel( QWidget* parent ): rviz::Panel( parent )
|
|||
layout->addWidget( _show_visuals_editor );
|
||||
setLayout( layout );
|
||||
|
||||
// Create a timer for sending the output. Motor controllers want to
|
||||
// be reassured frequently that they are doing the right thing, so
|
||||
// we keep re-sending velocities even when they aren't changing.
|
||||
//
|
||||
// Here we take advantage of QObject's memory management behavior:
|
||||
// since "this" is passed to the new QTimer as its parent, the
|
||||
// QTimer is deleted by the QObject destructor when this InterfacePanel
|
||||
// object is destroyed. Therefore we don't need to keep a pointer
|
||||
// to the timer.
|
||||
// QTimer* output_timer = new QTimer( this );
|
||||
|
||||
// Next we make signal/slot connections.
|
||||
connect( _max_error_editor, SIGNAL( editingFinished() ), this, SLOT( updateError() ));
|
||||
connect( _objective_type_editor, SIGNAL( stateChanged(int) ), this, SLOT( updateType(int) ));
|
||||
connect(_reset_button, SIGNAL (released()), this, SLOT (handleResetButton()));
|
||||
connect( _show_visuals_editor, SIGNAL( stateChanged(int) ), this, SLOT( updateVisuals(int) ));
|
||||
// connect( output_timer, SIGNAL( timeout() ), this, SLOT( sendVel() ));
|
||||
|
||||
// Start the timer.
|
||||
// output_timer->start( 100 );
|
||||
|
||||
// Make the control widget start disabled, since we don't start with an output topic.
|
||||
// drive_widget_->setEnabled( false );
|
||||
//Error editor disabled by default
|
||||
_max_error_editor->setEnabled( false );
|
||||
|
||||
_config_publisher = _nh.advertise<rviz_interface::InterfaceConfig>( "/RvizInterface/interface_config", 1 );
|
||||
|
@ -75,10 +46,7 @@ InterfacePanel::~InterfacePanel()
|
|||
delete _objective_type_editor;
|
||||
}
|
||||
|
||||
// Read the topic name from the QLineEdit and call setTopic() with the
|
||||
// results. This is connected to QLineEdit::editingFinished() which
|
||||
// fires when the user presses Enter or Tab or otherwise moves focus
|
||||
// away.
|
||||
//Update the error in the current_configuration & publish the configuration.
|
||||
void InterfacePanel::updateError()
|
||||
{
|
||||
current_config.max_error = _max_error_editor->text().toDouble();
|
||||
|
@ -89,6 +57,7 @@ void InterfacePanel::updateError()
|
|||
}
|
||||
}
|
||||
|
||||
//Update the objective type (ie Precise or not) in the current_configuration & publish the configuration.
|
||||
void InterfacePanel::updateType(int state)
|
||||
{
|
||||
current_config.objective_type = state;
|
||||
|
@ -107,6 +76,7 @@ void InterfacePanel::updateType(int state)
|
|||
}
|
||||
}
|
||||
|
||||
//Update the visual flag (ie Show visuals or not) in the current_configuration & publish the configuration.
|
||||
void InterfacePanel::updateVisuals(int state)
|
||||
{
|
||||
current_config.show_visuals = state;
|
||||
|
@ -116,6 +86,7 @@ void InterfacePanel::updateVisuals(int state)
|
|||
}
|
||||
}
|
||||
|
||||
//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;
|
||||
|
@ -126,15 +97,6 @@ void InterfacePanel::handleResetButton()
|
|||
current_config.follow_object = false;
|
||||
}
|
||||
|
||||
// void InterfacePanel::setError( const QString& error )
|
||||
// {
|
||||
// current_config.max_error = error.toDouble();
|
||||
// if( ros::ok() && _config_publisher )
|
||||
// {
|
||||
// _config_publisher.publish( current_config );
|
||||
// }
|
||||
// }
|
||||
|
||||
// Save all configuration data from this panel to the given
|
||||
// Config object. It is important here that you call save()
|
||||
// on the parent class so the class id and panel name get saved.
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
* Rviz panel for the configuration of the RvizInterface.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : RvizInterface.cpp/.hpp
|
||||
*/
|
||||
|
||||
#ifndef INTERFACE_PANEL_HPP
|
||||
#define INTERFACE_PANEL_HPP
|
||||
|
||||
|
@ -27,24 +33,13 @@ class QLineEdit;
|
|||
|
||||
namespace rviz_interface
|
||||
{
|
||||
// BEGIN_TUTORIAL
|
||||
// Here we declare our new subclass of rviz::Panel. Every panel which
|
||||
// can be added via the Panels/Add_New_Panel menu is a subclass of
|
||||
// rviz::Panel.
|
||||
//
|
||||
|
||||
class InterfacePanel: public rviz::Panel
|
||||
{
|
||||
// This class uses Qt slots and is a subclass of QObject, so it needs
|
||||
// the Q_OBJECT macro.
|
||||
Q_OBJECT
|
||||
public:
|
||||
// QWidget subclass constructors usually take a parent widget
|
||||
// parameter (which usually defaults to 0). At the same time,
|
||||
// pluginlib::ClassLoader creates instances by calling the default
|
||||
// constructor (with no arguments). Taking the parameter and giving
|
||||
// a default of 0 lets the default constructor work and also lets
|
||||
// someone using the class for something else to pass in a parent
|
||||
// widget as they normally would with Qt.
|
||||
InterfacePanel( QWidget* parent = 0 );
|
||||
~InterfacePanel();
|
||||
|
||||
|
@ -57,42 +52,30 @@ public:
|
|||
// Next come a couple of public Qt slots.
|
||||
public Q_SLOTS:
|
||||
|
||||
// void setError( const QString& error );
|
||||
|
||||
// Here we declare some internal slots.
|
||||
protected Q_SLOTS:
|
||||
|
||||
|
||||
void updateError();
|
||||
void updateType(int state);
|
||||
void updateVisuals(int state);
|
||||
void handleResetButton();
|
||||
void updateError(); //Update the error in the current_configuration & publish the configuration.
|
||||
void updateType(int state); //Update the objective type (ie Precise or not) in the current_configuration & publish the configuration.
|
||||
void updateVisuals(int state); //Update the visual flag (ie Show visuals or not) in the current_configuration & publish the configuration.
|
||||
void handleResetButton(); //Send a signal through the configuration telling the subscriber to follow the object it's linked to.
|
||||
|
||||
|
||||
// Then we finish up with protected member variables.
|
||||
protected:
|
||||
|
||||
rviz_interface::InterfaceConfig current_config;
|
||||
rviz_interface::InterfaceConfig current_config; //Current configuration which is sent at every interaction with the panel.
|
||||
|
||||
// One-line text editor for entering the outgoing ROS topic name.
|
||||
QLineEdit* _max_error_editor;
|
||||
QCheckBox* _objective_type_editor;
|
||||
QCheckBox* _show_visuals_editor;
|
||||
QPushButton* _reset_button;
|
||||
QLineEdit* _max_error_editor; //Line editor used to let user cusomize the maximum error allowed.
|
||||
QCheckBox* _objective_type_editor; //CheckBox used to modify the objective type.
|
||||
QCheckBox* _show_visuals_editor; //CheckBox used to choose if the error area should be shown.
|
||||
QPushButton* _reset_button; //Button to reattach a marker to it's linked object.
|
||||
|
||||
// The current name of the output topic.
|
||||
// QString _max_error;
|
||||
|
||||
// The ROS publisher for the command velocity.
|
||||
//Publisher
|
||||
ros::Publisher _config_publisher;
|
||||
|
||||
// The ROS node handle.
|
||||
ros::NodeHandle _nh;
|
||||
|
||||
// The latest velocity values from the drive widget.
|
||||
// float linear_velocity_;
|
||||
// float angular_velocity_;
|
||||
// END_TUTORIAL
|
||||
};
|
||||
|
||||
} // end namespace rviz_plugin_tutorials
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
* Rviz interface to send objective.
|
||||
* Composed of 3D marker and a configuration panel.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : InteractiveObject.cpp/.hpp, InterfacePanel.cpp/.hpp
|
||||
*/
|
||||
|
||||
#include "RvizInterface.hpp"
|
||||
|
||||
//Constructeur
|
||||
|
@ -86,6 +93,7 @@ void RvizInterface::configCallback(const rviz_interface::InterfaceConfig & new_c
|
|||
// }
|
||||
// }
|
||||
|
||||
//Fonction callback gérant la position des objets
|
||||
void RvizInterface::positionCallback(const rviz_interface::NamedPoint & new_center)
|
||||
{
|
||||
for(unsigned int i=0;i<_objects.size();i++)
|
||||
|
@ -107,6 +115,7 @@ void RvizInterface::positionCallback(const rviz_interface::NamedPoint & new_cent
|
|||
}
|
||||
}
|
||||
|
||||
//RvizInterface node.
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
//Initiate ROS
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
* Rviz interface to send objective.
|
||||
* Composed of 3D marker and a configuration panel.
|
||||
* @author : antoine.harle@etu.upmc.Fr
|
||||
* @see : InteractiveObject.cpp/.hpp, InterfacePanel.cpp/.hpp
|
||||
*/
|
||||
|
||||
#ifndef RVIZINTERFACE_HPP
|
||||
#define RVIZINTERFACE_HPP
|
||||
|
||||
|
@ -38,8 +45,7 @@ public:
|
|||
//Fonction Callback du panel Rviz gérant les configurations
|
||||
void configCallback(const rviz_interface::InterfaceConfig & new_config);
|
||||
|
||||
//Fonction callback gérant la position de l'objet
|
||||
//PROVISOIRE : Pour un seul objet avec test PCL
|
||||
//Fonction callback gérant la position des objets
|
||||
void positionCallback(const rviz_interface::NamedPoint & new_center);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue