app.core package#

Submodules#

app.core.invkinematics module#

class app.core.invkinematics.InvKineWindow[source]#

Bases: QMainWindow

InvKineWindow Class#

This class defines the main GUI window for the FlapKine Inverse Kinematics application.

It enables importing 3D coordinate data, visualizing it, and computing inverse kinematics angles (Roll, Pitch, Yaw) based on selected Euler angle sequences.

angle_data#

Signal emitted when inverse kinematics results are calculated.

Type:

pyqtSignal

menu_bar#

Custom menu bar for handling file and application actions.

Type:

MenuBar

data_path#

Input field to specify or display the path of the imported data file.

Type:

QLineEdit

euler_angles_order#

Dropdown for selecting Euler angle sequences (e.g., XYZ, ZYX, etc.).

Type:

QComboBox

finish_button#

Button to finalize processing and emit the results.

Type:

QPushButton

left_group#

Contains the 3D scatter plot visualization components.

Type:

QGroupBox

right_group#

Contains the line plots for Roll (α), Pitch (β), and Yaw (γ) angles.

Type:

QGroupBox

data#

The cleaned and filtered 3D point data imported from CSV.

Type:

np.ndarray

inv_result#

Tuple of calculated angles and selected Euler sequence.

Type:

tuple

__init__():

Constructor that initializes all UI elements, signals, and layout.

initUI() QVBoxLayout:[source]#

Constructs the main layout of the application including widgets and plots.

createImportWidget() QWidget:[source]#

Builds the “Import Data” section including file path and Euler angle selection.

createEulerAngleSelection() QWidget:[source]#

Returns a widget with a dropdown for choosing the Euler angle convention.

createGraphGroup() QGroupBox:[source]#

Assembles the left and right graph groups into one visualization section.

process_data(data: pd.DataFrame) pd.DataFrame:[source]#

Applies filtering (e.g., Savitzky-Golay) and machine learning corrections (e.g., Random Forest) to raw input data.

import_data():

Handles CSV file selection and invokes data processing.

calCulate_InverseKinematics() tuple[list, list, list]:[source]#

Computes the Roll (α), Pitch (β), and Yaw (γ) angles from 3D data and Euler sequence.

createLeftGroup() QGroupBox:[source]#

Initializes the left-side UI group for selecting points and rendering 3D plots using VTK.

createRightGroup() QGroupBox:[source]#

Initializes the right-side UI group with line plots for the inverse kinematics angles.

plot_data_left():

Renders a 3D scatter plot of the current data selection in the left VTK widget.

plot_data_right():

Plots α, β, γ angle variations using line charts in the right VTK widgets.

finish_button_fun():

Emits angle_data signal with results and closes the window.

angle_data#

int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Type:

pyqtSignal(*types, name

Type:

str = …, revision

calCulate_InverseKinematics() tuple[list, list, list][source]#

Calculates the inverse kinematics angles: α (alpha), β (beta), and γ (gamma).

This method:
  • Iterates through each time frame of the imported 3D point data.

  • Extracts the 3D coordinates of 4 points for each frame.

  • Computes two directional vectors based on those points.

  • Calculates the normal vector to the plane formed by these vectors.

  • Uses the selected Euler angle sequence to analytically compute the angles.

Returns:

A tuple containing three lists of calculated angles in radians:
  • alpha_values (list): α angles.

  • beta_values (list): β angles.

  • gamma_values (list): γ angles.

Return type:

tuple

createEulerAngleSelection() QWidget[source]#

Creates the Euler Angle Sequence selection widget.

This dropdown allows the user to select a specific Euler rotation sequence to be used in inverse kinematics calculations. Common intrinsic and extrinsic sequences are provided in the options.

Upon changing the selection, the corresponding angle plots are updated to reflect the new rotation order.

Returns:

A widget containing a label and a QComboBox for Euler angle sequence selection.

Return type:

QWidget

createGraphGroup() QGroupBox[source]#

Creates the main visualization group for the application.

This method sets up the grouped section of the GUI that displays both: - The 3D scatter plot (left group) for visualizing imported data points. - The angle plots (right group) for displaying Roll, Pitch, and Yaw over time.

The layout is organized using a horizontal splitter to allow dynamic resizing of both visual areas side-by-side.

Returns:

A group box containing the combined visualization components.

Return type:

QGroupBox

createImportWidget() QWidget[source]#

Creates the ‘Import Data’ UI section.

This widget provides functionality for importing external CSV data files. It includes:

  • A label indicating the section purpose.

  • A text input field for specifying the path to the data file.

  • An ‘Import Data’ button to load and process the file.

  • A dropdown for selecting the Euler angle rotation order.

When the import button is clicked, it triggers the data import and processing pipeline.

Returns:

A horizontal layout widget containing file import controls and Euler angle selection.

Return type:

QWidget

createLeftGroup() None[source]#

Creates the left group for 3D point visualization.

This section of the UI:
  • Provides a dropdown (QComboBox) to select between 4 tracked 3D points.

  • Initializes a VTK rendering widget (QVTKRenderWindowInteractor) to display

the trajectory of the selected point in 3D space.

Note

This visualization helps in analyzing the spatial motion of each point before calculating α (alpha), β (beta), and γ (gamma) angles.

Sets:

self.left_group (QGroupBox): Group box containing the dropdown and VTK widget.

createRightGroup() None[source]#

Creates the right group for visualizing the inverse kinematics angles.

This UI section sets up three vertically stacked VTK context views to display:
  • α (alpha) angle over time

  • β (beta) angle over time

  • γ (gamma) angle over time

Each subplot is rendered using vtkChartXY within a QVTKRenderWindowInteractor. These charts provide real-time feedback of angle calculations derived from the selected Euler sequence and 3D point data.

Sets:

self.right_group (QGroupBox): Group box containing the three VTK angle plots.

finish_button_fun()[source]#

Finalizes the inverse kinematics computation and emits the results.

This method:
  • Calculates the Euler angles (α, β, γ) using the selected rotation sequence.

  • Packages the result along with the selected Euler angle convention.

  • Emits the data via the angle_data signal for downstream processing or visualization.

  • Closes the current window upon completion.

Side Effects:
  • Updates self.inv_result with computed angles and selected sequence.

  • Emits angle_data signal carrying the result tuple.

  • Closes the active dialog/UI window.

import_data() None[source]#

Handles the process of importing and preparing CSV data for inverse kinematics analysis.

This method:
  • Opens a file dialog for the user to select a CSV file.

  • Updates the data path in the input field.

  • Processes the imported data using filtering and correction.

  • Converts the cleaned data into a NumPy array.

  • Enables UI components related to angle selection and visualization.

  • Triggers updates for both 3D point and angle visualization.

  • Activates the “Finish” button to allow finalizing the process.

initUI() QVBoxLayout[source]#

Sets up the main UI layout for the inverse kinematics window.

Constructs and arranges the primary user interface elements vertically:
  • Import Widget: Includes file path input and import button.

  • Graph Visualization Group: Contains 3D scatter plot and angle plot visualizations.

  • Finish Button: Triggers finalization of data processing and emits results.

The finish button is initially disabled and is activated after valid data is imported.

Returns:

The main vertical layout containing all primary UI components.

Return type:

QVBoxLayout

plot_data_left() None[source]#

Plots the 3D trajectory of the selected point in the left VTK view.

This method:
  • Extracts the x, y, z coordinates of the selected point across all time steps.

  • Renders a scatter plot using spherical glyphs in a VTK renderer.

  • Dynamically adjusts camera position and axis bounds to mimic the cubic aspect

of Plotly-style 3D plots for visual consistency and better spatial perception.

The plotted data provides a temporal spatial reference for one of the tracked points used in inverse kinematics analysis.

Side Effects:
  • Updates self.scatter_actor_left with new point data.

  • Adjusts camera and clipping ranges.

  • Triggers a re-render of the left VTK widget.

plot_data_right()[source]#

Plots the inverse kinematics angles (α, β, γ) on three VTK line charts.

This method:
  • Computes the Euler angles (alpha, beta, gamma) using the selected sequence.

  • Updates three vertically stacked VTK charts for visualizing these angles over time.

  • Each chart is color-coded:
    • α (alpha) in red

    • β (beta) in green

    • γ (gamma) in blue

  • Applies styling for axes and titles to ensure clarity and visual consistency.

These plots help visualize the orientation evolution of the tracked plane using the selected Euler angle convention.

Side Effects:
  • Updates chart_r_1, chart_r_2, chart_r_3 with fresh plot data.

  • Triggers a re-render of all three right-side VTK widgets.

static process_data(data: DataFrame) DataFrame[source]#

Applies filtering and correction to raw 3D point data using Savitzky-Golay filter and Random Forest regression.

For each of the four tracked points (pt1 to pt4), this method:
  • Smooths the X, Y, Z coordinates using Savitzky-Golay filtering.

  • Subsamples the smoothed data for training.

  • Trains individual Random Forest models to predict each coordinate over time.

  • Applies the trained models to generate corrected X, Y, Z trajectories.

Parameters:

data (pd.DataFrame) – Raw input data with point coordinates labeled as ‘pt{n}_X’, ‘pt{n}_Y’, ‘pt{n}_Z’.

Returns:

A copy of the input data with corrected X, Y, and Z values for each point.

Return type:

pd.DataFrame

Module contents#