Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef CARTESIAN_CONTROL_H_
00031 #define CARTESIAN_CONTROL_H_
00032
00033 #include "rviz_interaction_tools/gripper.h"
00034
00035 #include "rviz/ogre_helpers/shape.h"
00036 #include "rviz_interaction_tools/mesh_object.h"
00037
00038 #include <OGRE/OgreMaterial.h>
00039 #include <OGRE/OgreRay.h>
00040
00041 #include <string>
00042
00043 namespace rviz {
00044 class VisualizationManager;
00045 }
00046
00047 namespace Ogre {
00048 class SceneNode;
00049 }
00050
00051 namespace rviz_interaction_tools
00052 {
00053
00054
00055
00056
00057
00058 class CartesianControl
00059 {
00060 public:
00061
00062 static const float NO_INTERSECTION = 99999;
00063
00064 enum StatusT
00065 {
00066 HIDDEN,
00067 IDLE,
00068 ROTATING,
00069 DRAGGING
00070 };
00071
00072 CartesianControl( Ogre::SceneNode *scene_node, rviz::VisualizationManager *vis_manager );
00073
00074 virtual ~CartesianControl();
00075
00076
00077 void setPosition( Ogre::Vector3 position );
00078 void setOrientation( Ogre::Quaternion orientation );
00079
00080
00081 Ogre::Vector3 getPosition();
00082 Ogre::Quaternion getOrientation();
00083
00084
00085 void setControlsPosition( Ogre::Vector3 position );
00086 void setControlsOrientation( Ogre::Quaternion orientation );
00087
00088 void setFixedControlsOrientation( bool use ) { fixed_controls_orientation_ = use; }
00089 bool getFixedControlsOrientation() { return fixed_controls_orientation_; }
00090
00091
00092 Ogre::Vector3 getControlsPosition();
00093 Ogre::Quaternion getControlsOrientation( );
00094
00095
00096 geometry_msgs::PoseStamped getPose();
00097
00098 void show();
00099 void hide();
00100
00101 void update();
00102
00103 void mouseMove( Ogre::Ray mouse_ray );
00104 void mouseDown( Ogre::Ray mouse_ray );
00105 void mouseUp( Ogre::Ray mouse_ray );
00106
00107
00108 float getClosestIntersection( Ogre::Ray mouse_ray );
00109
00110 protected:
00111
00112 static const float HANDLE_RADIUS_OUTER = 0.13;
00113 static const float HANDLE_RADIUS_INNER = 0.10;
00114 static const float HANDLE_SIZE = 0.03;
00115 static const float HANDLE_ALPHA = 0.5;
00116
00117 enum SideT
00118 {
00119 POS,
00120 NEG
00121 };
00122
00123 void addControls( unsigned axis );
00124
00125 rviz::Shape* addDragBox( Ogre::Vector3 axis );
00126
00127 void addRing(
00128 Ogre::Vector3 axis1, Ogre::Vector3 axis2,
00129 Ogre::MaterialPtr material, unsigned render_queue_group );
00130
00131
00132 void addRingSegment(
00133 Ogre::Vector3 axis1, Ogre::Vector3 axis2,
00134 Ogre::MaterialPtr material, unsigned render_queue_group,
00135 float a_min, float a_max );
00136
00137 bool intersectRing( Ogre::Ray mouse_ray, unsigned axis,
00138 Ogre::Vector3 &intersection_3d, Ogre::Vector2 &intersection_2d, float &ray_t,
00139 float inner_radius=HANDLE_RADIUS_INNER, float outer_radius=HANDLE_RADIUS_OUTER );
00140
00141 bool intersectPlane( Ogre::Ray mouse_ray, unsigned axis,
00142 Ogre::Vector3 &intersection_3d, Ogre::Vector2 &intersection_2d, float &ray_t );
00143
00144 bool getClosestRing( Ogre::Ray mouse_ray,
00145 Ogre::Vector3 &nearest_intersection_3d, Ogre::Vector2 &nearest_intersection_2d,
00146 float &nearest_t, unsigned &nearest_axis );
00147
00148 bool intersectBox( Ogre::Ray mouse_ray, unsigned axis, SideT side,
00149 Ogre::Vector3 &intersection_3d, float &intersection_1d, float &ray_t );
00150
00151 bool getClosestBox( Ogre::Ray mouse_ray,
00152 Ogre::Vector3 &nearest_intersection_3d, float &nearest_intersection_1d,
00153 float &nearest_t, unsigned &nearest_axis, SideT &nearest_side );
00154
00155 Ogre::Vector3 getAxis( unsigned axis );
00156
00157 bool getClosestPosition( Ogre::Ray mouse_ray, unsigned axis, float &pos );
00158
00159 rviz::VisualizationManager *vis_manager_;
00160
00161 bool fixed_controls_orientation_;
00162
00163 Ogre::SceneNode *main_node_;
00164 Ogre::SceneNode *controls_node_;
00165
00166
00167 std::map< unsigned, std::map<SideT, rviz::Shape*> > drag_boxes_;
00168
00169 std::vector<rviz_interaction_tools::MeshObject*> ring_segments_;
00170
00171 rviz::Shape* marker_;
00172
00173 StatusT status_;
00174
00175 double last_angle_;
00176 double last_drag_pos_;
00177 SideT last_drag_side_;
00178 int last_axis_;
00179
00180 Ogre::Vector3 position_;
00181 Ogre::Quaternion orientation_;
00182 };
00183
00184 }
00185
00186 #endif