SMACC
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
smacc_rviz_plugin::ImuVisual Class Reference

#include <imu_visual.h>

Collaboration diagram for smacc_rviz_plugin::ImuVisual:
Collaboration graph

Public Member Functions

 ImuVisual (Ogre::SceneManager *scene_manager, Ogre::SceneNode *parent_node)
 
virtual ~ImuVisual ()
 
void setMessage (const sensor_msgs::Imu::ConstPtr &msg)
 
void setFramePosition (const Ogre::Vector3 &position)
 
void setFrameOrientation (const Ogre::Quaternion &orientation)
 
void setColor (float r, float g, float b, float a)
 

Private Attributes

boost::shared_ptr< rviz::Arrow > acceleration_arrow_
 
Ogre::SceneNode * frame_node_
 
Ogre::SceneManager * scene_manager_
 

Detailed Description

Definition at line 49 of file imu_visual.h.

Constructor & Destructor Documentation

◆ ImuVisual()

smacc_rviz_plugin::ImuVisual::ImuVisual ( Ogre::SceneManager *  scene_manager,
Ogre::SceneNode *  parent_node 
)

Definition at line 42 of file imu_visual.cpp.

43{
44 scene_manager_ = scene_manager;
45
46 // Ogre::SceneNode s form a tree, with each node storing the
47 // transform (position and orientation) of itself relative to its
48 // parent. Ogre does the math of combining those transforms when it
49 // is time to render.
50 //
51 // Here we create a node to store the pose of the Imu's header frame
52 // relative to the RViz fixed frame.
53 frame_node_ = parent_node->createChildSceneNode();
54
55 // We create the arrow object within the frame node so that we can
56 // set its position and direction relative to its header frame.
57 acceleration_arrow_.reset(new rviz::Arrow( scene_manager_, frame_node_ ));
58}
boost::shared_ptr< rviz::Arrow > acceleration_arrow_
Definition: imu_visual.h:76
Ogre::SceneManager * scene_manager_
Definition: imu_visual.h:84
Ogre::SceneNode * frame_node_
Definition: imu_visual.h:80

References acceleration_arrow_, frame_node_, and scene_manager_.

◆ ~ImuVisual()

smacc_rviz_plugin::ImuVisual::~ImuVisual ( )
virtual

Definition at line 60 of file imu_visual.cpp.

61{
62 // Destroy the frame node since we don't need it anymore.
63 scene_manager_->destroySceneNode( frame_node_ );
64}

References frame_node_, and scene_manager_.

Member Function Documentation

◆ setColor()

void smacc_rviz_plugin::ImuVisual::setColor ( float  r,
float  g,
float  b,
float  a 
)

Definition at line 97 of file imu_visual.cpp.

98{
99 acceleration_arrow_->setColor( r, g, b, a );
100}

References acceleration_arrow_.

◆ setFrameOrientation()

void smacc_rviz_plugin::ImuVisual::setFrameOrientation ( const Ogre::Quaternion &  orientation)

Definition at line 91 of file imu_visual.cpp.

92{
93 frame_node_->setOrientation( orientation );
94}

References frame_node_.

◆ setFramePosition()

void smacc_rviz_plugin::ImuVisual::setFramePosition ( const Ogre::Vector3 &  position)

Definition at line 86 of file imu_visual.cpp.

87{
88 frame_node_->setPosition( position );
89}

References frame_node_.

◆ setMessage()

void smacc_rviz_plugin::ImuVisual::setMessage ( const sensor_msgs::Imu::ConstPtr &  msg)

Definition at line 66 of file imu_visual.cpp.

67{
68 const geometry_msgs::Vector3& a = msg->linear_acceleration;
69
70 // Convert the geometry_msgs::Vector3 to an Ogre::Vector3.
71 Ogre::Vector3 acc( a.x, a.y, a.z );
72
73 // Find the magnitude of the acceleration vector.
74 float length = acc.length();
75
76 // Scale the arrow's thickness in each dimension along with its length.
77 Ogre::Vector3 scale( length, length, length );
78 acceleration_arrow_->setScale( scale );
79
80 // Set the orientation of the arrow to match the direction of the
81 // acceleration vector.
82 acceleration_arrow_->setDirection( acc );
83}

References acceleration_arrow_.

Member Data Documentation

◆ acceleration_arrow_

boost::shared_ptr<rviz::Arrow> smacc_rviz_plugin::ImuVisual::acceleration_arrow_
private

Definition at line 76 of file imu_visual.h.

Referenced by ImuVisual(), setColor(), and setMessage().

◆ frame_node_

Ogre::SceneNode* smacc_rviz_plugin::ImuVisual::frame_node_
private

Definition at line 80 of file imu_visual.h.

Referenced by ImuVisual(), setFrameOrientation(), setFramePosition(), and ~ImuVisual().

◆ scene_manager_

Ogre::SceneManager* smacc_rviz_plugin::ImuVisual::scene_manager_
private

Definition at line 84 of file imu_visual.h.

Referenced by ImuVisual(), and ~ImuVisual().


The documentation for this class was generated from the following files: