MIPI - Physical Interface for MIDI Files
Loading...
Searching...
No Matches
UI::PianoUI Class Reference

#include <ui_piano.h>

Inheritance diagram for UI::PianoUI:
Inheritance graph
Collaboration diagram for UI::PianoUI:
Collaboration graph

Public Member Functions

 PianoUI ()
 Hybrid Qt-ROS2 Class for managing the User Interface of the MIDI-to-UR3 system.
 
 ~PianoUI ()
 Standard Destructor for PianoUI Class.
 

Private Slots

void play_pause ()
 Toggles the playback state and notifies the /MIPI/play_pause service.
 
void open_midi_file ()
 UI Slot for opening a file dialog to process a raw .mid file.
 
void toggle_direction ()
 Toggles between Forward and Reverse playback logic.
 
void set_direction_forward ()
 Explicitly sets playback direction to Forward via the /MIPI/direction service.
 
void set_direction_reverse ()
 Explicitly sets playback direction to Reverse via the /MIPI/direction service.
 
void send_time_scale ()
 Transmits the current speed slider value as a time scale factor (0.01-1.0) to the robot.
 
void send_channel_selection (int index)
 Transmits the selected MIDI channel to the robot controller.
 
void load_existing_mipi (int index)
 UI Slot for loading a file selected from the dropdown menu.
 
void send_debug_request ()
 Sends a trigger request to the debug service for development testing.
 

Private Member Functions

void update_status_info ()
 Refreshes all status labels in the UI with the latest system state information.
 
void force_pause_and_reset ()
 Immediate helper method to halt UI playback tracking and reset visual sliders.
 
void populate_mipi_combobox ()
 Scans the ~/mipi_files directory to refresh the dropdown list.
 
void update_channel_radio_buttons ()
 Rebuilds the radio button group based on the currently loaded MIDI processor data.
 
void image_callback (const sensor_msgs::msg::Image::SharedPtr msg)
 ROS 2 Subscriber callback for camera feed.
 

Private Attributes

bool is_playing = false
 
PlaybackDirection current_dir = PlaybackDirection::Forward
 
QString _midi_file_path
 
QLabel * _title
 
QSlider * _track_slider
 
QPushButton * _play_pause_button
 
QPushButton * _direction_button
 
QLabel * _channel_title
 
QRadioButton * _channel_select
 
QSlider * _speed_control
 
QLabel * _new_file_label
 
QPushButton * _new_file_button
 
QLabel * _old_file_label
 
QComboBox * _old_file_button
 
QLabel * _status_val
 
QLabel * _speed_val
 
QLabel * _time_val
 
QVBoxLayout * _channel_layout
 
QButtonGroup * _channel_group
 
rclcpp::Client< jamc::srv::Func >::SharedPtr playback_client
 
rclcpp::Client< jamc::srv::Func >::SharedPtr direction_client
 
rclcpp::Client< jamc::srv::TimeScale >::SharedPtr time_scale_client
 
rclcpp::Client< jamc::srv::Load >::SharedPtr channel_client
 
rclcpp::Client< jamc::srv::Func >::SharedPtr debug_client
 
MidiProcessor processor
 
QLabel * _camera_view
 
rclcpp::Subscription< sensor_msgs::msg::Image >::SharedPtr _camera_sub
 
QPushButton * _debug_button
 

Constructor & Destructor Documentation

◆ PianoUI()

UI::PianoUI::PianoUI ( )

Hybrid Qt-ROS2 Class for managing the User Interface of the MIDI-to-UR3 system.

  • This class inherits from QWidget and rclcpp::Node. It contains the following ROS2 I/O:
  • Service Clients
  • /MIPI/play_pause (jamc/srv/Func): Triggers a play/pause state change on the robot.
  • /MIPI/direction (jamc/srv/Func): Toggles the playback direction (Forward/Reverse).
  • /MIPI/time_scale (jamc/srv/TimeScale): Sends a float (0.01 to 1.0) to scale robot velocity.
  • /MIPI/load (jamc/srv/Load): Sends the filepath and instrument index to the controller.
  • Subscriptions
  • /camera/camera/color/image_raw (sensor_msgs/msg/Image): Receives live feed for UI visualization.
Here is the call graph for this function:

◆ ~PianoUI()

UI::PianoUI::~PianoUI ( )

Standard Destructor for PianoUI Class.

Member Function Documentation

◆ force_pause_and_reset()

void UI::PianoUI::force_pause_and_reset ( )
private

Immediate helper method to halt UI playback tracking and reset visual sliders.

Sends a PAUSE request to the robot and resets the track slider to zero. Always enforces a Forward direction state.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ image_callback()

void UI::PianoUI::image_callback ( const sensor_msgs::msg::Image::SharedPtr  msg)
private

ROS 2 Subscriber callback for camera feed.

Callback function for processing incoming ROS 2 image messages.

Parameters
msgShared pointer to the image message.
Note
Uses QMetaObject::invokeMethod to ensure thread-safety when updating the UI thread from the ROS executor thread.
Parameters
msgA shared pointer to the incoming sensor_msgs::msg::Image.
Note
This uses QMetaObject::invokeMethod to ensure the UI update happens on the main thread, avoiding thread collisions with the ROS executor.
Here is the caller graph for this function:

◆ load_existing_mipi

void UI::PianoUI::load_existing_mipi ( int  index)
privateslot

UI Slot for loading a file selected from the dropdown menu.

Parameters
indexThe index of the selected file in the QComboBox.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ open_midi_file

void UI::PianoUI::open_midi_file ( )
privateslot

UI Slot for opening a file dialog to process a raw .mid file.

Converts the file to .mipi and automatically selects the first available channel for loading.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ play_pause

void UI::PianoUI::play_pause ( )
privateslot

Toggles the playback state and notifies the /MIPI/play_pause service.

Here is the caller graph for this function:

◆ populate_mipi_combobox()

void UI::PianoUI::populate_mipi_combobox ( )
private

Scans the ~/mipi_files directory to refresh the dropdown list.

Note
Blocks signals during execution to prevent recursive load triggers.
Here is the caller graph for this function:

◆ send_channel_selection

void UI::PianoUI::send_channel_selection ( int  button_id)
privateslot

Transmits the selected MIDI channel to the robot controller.

Sends a load request to the robot controller for a specific instrument channel.

Parameters
button_idThe ID of the clicked radio button (mapped to MIDI channel).
Precondition
A .mipi file must be loaded.
Postcondition
Resets playback to ensure the robot starts the new channel from a safe state.
Parameters
button_idThe ID of the radio button corresponding to the instrument index.

Clears the current playback state before sending the new file data to the robot.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_debug_request

void UI::PianoUI::send_debug_request ( )
privateslot

Sends a trigger request to the debug service for development testing.

Here is the caller graph for this function:

◆ send_time_scale

void UI::PianoUI::send_time_scale ( )
privateslot

Transmits the current speed slider value as a time scale factor (0.01-1.0) to the robot.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_direction_forward

void UI::PianoUI::set_direction_forward ( )
privateslot

Explicitly sets playback direction to Forward via the /MIPI/direction service.

Here is the caller graph for this function:

◆ set_direction_reverse

void UI::PianoUI::set_direction_reverse ( )
privateslot

Explicitly sets playback direction to Reverse via the /MIPI/direction service.

Here is the caller graph for this function:

◆ toggle_direction

void UI::PianoUI::toggle_direction ( )
privateslot

Toggles between Forward and Reverse playback logic.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_channel_radio_buttons()

void UI::PianoUI::update_channel_radio_buttons ( )
private

Rebuilds the radio button group based on the currently loaded MIDI processor data.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_status_info()

void UI::PianoUI::update_status_info ( )
private

Refreshes all status labels in the UI with the latest system state information.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _camera_sub

rclcpp::Subscription<sensor_msgs::msg::Image>::SharedPtr UI::PianoUI::_camera_sub
private

◆ _camera_view

QLabel* UI::PianoUI::_camera_view
private

◆ _channel_group

QButtonGroup* UI::PianoUI::_channel_group
private

◆ _channel_layout

QVBoxLayout* UI::PianoUI::_channel_layout
private

◆ _channel_select

QRadioButton* UI::PianoUI::_channel_select
private

◆ _channel_title

QLabel* UI::PianoUI::_channel_title
private

◆ _debug_button

QPushButton* UI::PianoUI::_debug_button
private

◆ _direction_button

QPushButton* UI::PianoUI::_direction_button
private

◆ _midi_file_path

QString UI::PianoUI::_midi_file_path
private

◆ _new_file_button

QPushButton* UI::PianoUI::_new_file_button
private

◆ _new_file_label

QLabel* UI::PianoUI::_new_file_label
private

◆ _old_file_button

QComboBox* UI::PianoUI::_old_file_button
private

◆ _old_file_label

QLabel* UI::PianoUI::_old_file_label
private

◆ _play_pause_button

QPushButton* UI::PianoUI::_play_pause_button
private

◆ _speed_control

QSlider* UI::PianoUI::_speed_control
private

◆ _speed_val

QLabel* UI::PianoUI::_speed_val
private

◆ _status_val

QLabel* UI::PianoUI::_status_val
private

◆ _time_val

QLabel* UI::PianoUI::_time_val
private

◆ _title

QLabel* UI::PianoUI::_title
private

◆ _track_slider

QSlider* UI::PianoUI::_track_slider
private

◆ channel_client

rclcpp::Client<jamc::srv::Load>::SharedPtr UI::PianoUI::channel_client
private

◆ current_dir

PlaybackDirection UI::PianoUI::current_dir = PlaybackDirection::Forward
private

◆ debug_client

rclcpp::Client<jamc::srv::Func>::SharedPtr UI::PianoUI::debug_client
private

◆ direction_client

rclcpp::Client<jamc::srv::Func>::SharedPtr UI::PianoUI::direction_client
private

◆ is_playing

bool UI::PianoUI::is_playing = false
private

◆ playback_client

rclcpp::Client<jamc::srv::Func>::SharedPtr UI::PianoUI::playback_client
private

◆ processor

MidiProcessor UI::PianoUI::processor
private

◆ time_scale_client

rclcpp::Client<jamc::srv::TimeScale>::SharedPtr UI::PianoUI::time_scale_client
private

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