Kinematics Animation Multithread
Public Member Functions | Private Member Functions | Private Attributes | List of all members
KinematicAnimation Class Reference

Class KinematicAnimation. More...

#include <kinematic_animation.h>

Collaboration diagram for KinematicAnimation:
Collaboration graph
[legend]

Public Member Functions

 KinematicAnimation ()
 Constructor. More...
 
void initialize (igl::opengl::glfw::Viewer *viewer, Exoskeleton *left_exo, AnimatedHand *anim_hand, MenuHandler *menu_handler)
 Initialize animation. More...
 
bool animation_loop (igl::opengl::glfw::Viewer &viewer)
 Animation loop callback. More...
 

Private Member Functions

void setup_exoskeletons (igl::opengl::glfw::Viewer &viewer)
 Setup exoskeletons. More...
 

Private Attributes

Exoskeletonm_left_exo
 Exoskeleton handler pointer. More...
 
AnimatedHandm_anim_hand
 Animated hand pointer. More...
 
MenuHandlerm_menu_handler
 Menu handler pointer. More...
 
Hand m_left_hand
 Left and right hand. More...
 
Hand m_right_hand
 
Eigen::Vector3d m_left_origin = Eigen::Vector3d(0.0, 0.2, 0.0)
 Left hand origin. More...
 
Eigen::Vector3d m_right_origin = Eigen::Vector3d(0.0, -0.2, 0.0)
 Right hand origin. More...
 
bool m_initialize_animation = 1
 Bool start animation. More...
 
Eigen::Matrix3d m_camera_center
 Camera matrix. More...
 

Detailed Description

Class KinematicAnimation.

This class implements the kinematic animation for the hand.

Definition at line 15 of file kinematic_animation.h.

Constructor & Destructor Documentation

◆ KinematicAnimation()

KinematicAnimation::KinematicAnimation ( )
inline

Constructor.

Definition at line 19 of file kinematic_animation.h.

19{};

Member Function Documentation

◆ animation_loop()

bool KinematicAnimation::animation_loop ( igl::opengl::glfw::Viewer &  viewer)

Animation loop callback.

This is the main animation callback function. This is where the rendering is happening. The function is passed as a lambda function to the Viewer handler (see main.cpp).

Parameters
viewerReference to the viewer handle.
Returns
true Animation should stop.
false Animations keeps playing.

Definition at line 36 of file kinematic_animation.cpp.

37{
38 if (viewer.core().is_animating)
39 {
40 viewer.core().align_camera_center(m_camera_center);
41
42 // Initialize if ports are set
44 {
45 // Setup exoskeleton
46 setup_exoskeletons(viewer);
47
48 // Dont initialize animations again
50 }
51
53 {
54 // Get euler angles
55 auto euler_id =
57
58 // Update left hand
59 m_left_hand.update(euler_id, viewer);
60
61 // Update right hand
62 m_right_hand.update(euler_id, viewer);
63 }
64 }
65 return false;
66}
std::vector< Eigen::Vector3d > get_hand_angles(const std::vector< double > &joint_angles)
std::vector< double > get_joint_angles(void)
Get joint angles.
Definition: exoskeleton.cpp:54
void update(const std::vector< Eigen::Vector3d > &euler_id, igl::opengl::glfw::Viewer &viewer)
It updates the hand vertices based on the euler angles for its skeleton joints. These are fed through...
Definition: hand.cpp:72
MenuHandler * m_menu_handler
Menu handler pointer.
Eigen::Matrix3d m_camera_center
Camera matrix.
bool m_initialize_animation
Bool start animation.
AnimatedHand * m_anim_hand
Animated hand pointer.
void setup_exoskeletons(igl::opengl::glfw::Viewer &viewer)
Setup exoskeletons.
Hand m_left_hand
Left and right hand.
Exoskeleton * m_left_exo
Exoskeleton handler pointer.
bool are_ports_set(void)
Check whether the USB ports have been sent by the user (Is OK pressed?).
Definition: menu_handler.h:32
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialize()

void KinematicAnimation::initialize ( igl::opengl::glfw::Viewer *  viewer,
Exoskeleton left_exo,
AnimatedHand anim_hand,
MenuHandler menu_handler 
)

Initialize animation.

Initializes kinematics animation by copying the input arguments to the member variables.

Parameters
viewerPointer to the igl Viewer object.
left_exoPointer to the left exoskeleton object.
anim_handPointer to the animated hand object.
menu_handlerPointer to menu handler object.

Definition at line 11 of file kinematic_animation.cpp.

13{
14 // Get exoskeleton handler pointer
15 m_left_exo = left_exo;
16
17 // Get animation hand pointer
18 m_anim_hand = anim_hand;
19
20 // Get menu handler pointer
21 m_menu_handler = menu_handler;
22
23 // Set camera center
24 m_camera_center << -0.1, -0.1, 0.0, 0.1, -0.1, 0.0, 0.0, 0.1, 0.0;
25}
Here is the caller graph for this function:

◆ setup_exoskeletons()

void KinematicAnimation::setup_exoskeletons ( igl::opengl::glfw::Viewer &  viewer)
private

Setup exoskeletons.

This function setups the exoskeletons. It initializes the serial communications, the exoskeleton and the hand objects.

Parameters
viewerA reference to the viewer handle.

Definition at line 73 of file kinematic_animation.cpp.

74{
75 // Define serial COM for left exoskeleton
76 std::string serial_com_left = m_menu_handler->get_left_exoskeleton_port();
77
78 // Define serial COM for right exoskeleton
79 std::string serial_com_right = m_menu_handler->get_right_exoskeleton_port();
80
81 // Define baudrate
82 unsigned int baud_rate = 115200;
83
84 // Initialize left exoskeleton
85 m_left_exo->initialize(serial_com_left, baud_rate);
86
87 // Initialize right exoskeleton (to be done)
88
89 // Initialize left hand
91
92 // Initialize right hand
94}
void initialize(const std::string &serial_com, unsigned int serial_baudrate)
Initialize.
Definition: exoskeleton.cpp:10
void initialize(igl::opengl::glfw::Viewer *viewer, Exoskeleton *exo_handler, AnimatedHand *anim_hand, bool type, const Eigen::Vector3d &origin)
Initialize the hand.
Definition: hand.cpp:15
Eigen::Vector3d m_left_origin
Left hand origin.
Eigen::Vector3d m_right_origin
Right hand origin.
std::string get_right_exoskeleton_port(void)
Get the USB port for the right exoskeleton.
Definition: menu_handler.h:38
std::string get_left_exoskeleton_port(void)
Get the USB port for the left exoskeleton.
Definition: menu_handler.h:35
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_anim_hand

AnimatedHand* KinematicAnimation::m_anim_hand
private

Animated hand pointer.

Definition at line 36 of file kinematic_animation.h.

◆ m_camera_center

Eigen::Matrix3d KinematicAnimation::m_camera_center
private

Camera matrix.

Definition at line 57 of file kinematic_animation.h.

◆ m_initialize_animation

bool KinematicAnimation::m_initialize_animation = 1
private

Bool start animation.

Definition at line 51 of file kinematic_animation.h.

◆ m_left_exo

Exoskeleton* KinematicAnimation::m_left_exo
private

Exoskeleton handler pointer.

Definition at line 33 of file kinematic_animation.h.

◆ m_left_hand

Hand KinematicAnimation::m_left_hand
private

Left and right hand.

Definition at line 42 of file kinematic_animation.h.

◆ m_left_origin

Eigen::Vector3d KinematicAnimation::m_left_origin = Eigen::Vector3d(0.0, 0.2, 0.0)
private

Left hand origin.

Definition at line 45 of file kinematic_animation.h.

◆ m_menu_handler

MenuHandler* KinematicAnimation::m_menu_handler
private

Menu handler pointer.

Definition at line 39 of file kinematic_animation.h.

◆ m_right_hand

Hand KinematicAnimation::m_right_hand
private

Definition at line 42 of file kinematic_animation.h.

◆ m_right_origin

Eigen::Vector3d KinematicAnimation::m_right_origin = Eigen::Vector3d(0.0, -0.2, 0.0)
private

Right hand origin.

Definition at line 48 of file kinematic_animation.h.


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