![]() |
MIPI - Physical Interface for MIDI Files
|
#include <controller.h>


Public Member Functions | |
| Controller () | |
| Standalone Class for Controlling a UR3e. Typically reads data from .mipi files for plaback on a piano. Exposes various services for control. | |
| ~Controller () | |
| Standard Destructor for Controller Class. | |
Private Member Functions | |
General Methods | |
Methods used throughout the class for various purposes | |
| void | sendTwistMsg (double x, double y, double z, double angular_x=0.0, double angular_y=0.0, double angular_z=0.0) |
| A convenience method that neatly packs up a twist messge and publishes it to the UR_Driver. | |
| void | sendJointJog (double shoulder_lift, double elbow, double wrist_1, double wrist_2, double wrist_3, double shoulder_pan) |
| A wrapper for sending joint jog commands for direct joint velocity control. | |
| void | sendJointJog (std::vector< double > vel) |
| A secondary wrapper for the sending Joint Jog commands that takes a vector instead of individual velocities. | |
| void | sendVector (const vector3 &vec) |
| The public method for sending translational End Effector vector commands to the UR3e. | |
| void | sendStop () |
| A simple helper method for immediately sending stop to the UR3e. | |
| int | activeTrackDebug (vector3 target, bool x=false, bool y=false, bool z=false) |
| A method for enabling "activeTrack" mode, allowing for live visual servoing following a topic. | |
Startup & Shutdown Sequence | |
Functions related to the startup and shutdown sequence of the controller | |
| void | startup () |
| The startup sequence that moves the robot into the starting position for playing. | |
Subscriber Callbacks | |
All Subscriber callbacks that the Controller Class uses | |
| void | debug_target_callback (const geometry_msgs::msg::Point::SharedPtr msg) |
| Callback function for catching the debug subscriber, used to activate activeTrack. | |
| void | key_positions_callback (const geometry_msgs::msg::PoseArray::SharedPtr msg) |
| Subscriber Callback that obtains the key positions from the. | |
| void | joint_state_callback (const sensor_msgs::msg::JointState::SharedPtr msg) |
| Subscriber Callback that obtains the joint state of the robot. | |
Service Callbacks | |
All Service callbacks that the Controller Class uses | |
| void | load_callback (const std::shared_ptr< jamc::srv::Load::Request > request, std::shared_ptr< jamc::srv::Load::Response > response) |
| Callback function for the Load Service, used to load .mipi files and select which instrument channel. | |
| void | time_scale_callback (const std::shared_ptr< jamc::srv::TimeScale::Request > request, std::shared_ptr< jamc::srv::TimeScale::Response > response) |
| Callback function for the TimeScale Service, used to set the time scaling factor for playback. | |
| void | play_pause_callback (const std::shared_ptr< jamc::srv::Func::Request > request, std::shared_ptr< jamc::srv::Func::Response > response) |
| Callback function for the Play/Pause Service, used to toggle playback of the current track. | |
| void | play_direction_callback (const std::shared_ptr< jamc::srv::Func::Request > request, std::shared_ptr< jamc::srv::Func::Response > response) |
| Callback function for the Play Direction Service, used to toggle the direction of playback. | |
| void | debug_service_callback (const std::shared_ptr< jamc::srv::Func::Request > request, std::shared_ptr< jamc::srv::Func::Response > response) |
| Callback function for the debug service, used to test anything. | |
Control Loop | |
Functions related to the control loop of the controller | |
| void | control_loop () |
| The main control loop that runs when the control node starts. | |
| double | calculate_z (double xy) |
| A helper method for calculating the target Z velocity (Scaled to meet a target height based on the X&Y magnitued) | |
| std::optional< vector3 > | calculate_velocity (int note) |
| Velocity calculation for control loop. If the note is not visible, will travel in the parallel to the keyboard to find it. | |
| std::optional< vector3 > | play_note (double duration, double time) |
| Plays a single note or presses a button, streams Z velocity for a hardcoded duration to push down on whatever the EE is above. | |
Private Attributes | |
Variables & Helpers | |
Variables used by the class | |
| long | CONTROL_TIME |
| Clock::time_point | LAST_CONTROL_TIME_POINT |
| STATE | state_ |
| MidiProcessor | connor |
| std::mutex | key_positions_mutex_ |
| geometry_msgs::msg::PoseArray | key_positions_ |
| std::mutex | song_mutex_ |
| std::vector< int > | song_ |
| std::vector< double > | note_timings_ |
| std::vector< double > | note_durations_ |
| bool | play_ = false |
| double | time_scale_ = 1.0 |
| bool | direction_ = true |
| int | current_note_index_ = 0 |
| bool | song_loaded_ = false |
| std::mutex | joint_mutex_ |
| std::vector< double > | latest_joint_state_ |
| rclcpp::TimerBase::SharedPtr | control_timer_ |
| rclcpp::TimerBase::SharedPtr | startup_timer_ |
| bool | startup_complete_ = false |
Publishers | |
All Publishers that the Controller Class uses | |
| rclcpp::Publisher< geometry_msgs::msg::TwistStamped >::SharedPtr | twist_pub_ |
| rclcpp::Publisher< control_msgs::msg::JointJog >::SharedPtr | joint_traj_streaming_pub_ |
Subscribers | |
All Subscribers that the Controller Class uses | |
| rclcpp::Subscription< geometry_msgs::msg::Point >::SharedPtr | debug_target_sub_ |
| rclcpp::Subscription< geometry_msgs::msg::PoseArray >::SharedPtr | key_positions_sub_ |
| rclcpp::Subscription< sensor_msgs::msg::JointState >::SharedPtr | joint_state_sub_ |
Services | |
Services that the Controller Class provides | |
| rclcpp::Service< jamc::srv::Load >::SharedPtr | load_service_ |
| rclcpp::Service< jamc::srv::TimeScale >::SharedPtr | time_service_ |
| rclcpp::Service< jamc::srv::Func >::SharedPtr | play_pause_service_ |
| rclcpp::Service< jamc::srv::Func >::SharedPtr | play_direction_service_ |
| rclcpp::Service< jamc::srv::Func >::SharedPtr | debug_service_ |
| Control::Controller::Controller | ( | ) |
Standalone Class for Controlling a UR3e. Typically reads data from .mipi files for plaback on a piano. Exposes various services for control.
This class contains the following ROS2 I/O

| Control::Controller::~Controller | ( | ) |
Standard Destructor for Controller Class.
|
private |
A method for enabling "activeTrack" mode, allowing for live visual servoing following a topic.
| target | A vector3 struct that is the target |
| x | A bool to enable motion in the X plane |
| y | A bool to enable motion in the Y plane |
| z | A bool to enable motion in the Z plane |
|
private |
Velocity calculation for control loop. If the note is not visible, will travel in the parallel to the keyboard to find it.
| note | The MIDI note value for the current note being played |
|
private |
A helper method for calculating the target Z velocity (Scaled to meet a target height based on the X&Y magnitued)
| xy | The magnitude of the vector in the x and y direction |
|
private |
The main control loop that runs when the control node starts.

|
private |
Callback function for the debug service, used to test anything.
| request | The request from the service call, empty for this trigger service |
| response | The response for the service call, containing a message |

|
private |
Callback function for catching the debug subscriber, used to activate activeTrack.
| msg | Input from the topic subscription |

|
private |
Subscriber Callback that obtains the joint state of the robot.
| msg | JointState object that contains the robots joint state |

|
private |
Subscriber Callback that obtains the key positions from the.
| msg | PoseArray containing the positions of the keys |

|
private |
Callback function for the Load Service, used to load .mipi files and select which instrument channel.
| request | The request from the service call, containing the filepath and instrument index |
| response | The response for the service call, containing a message |

|
private |
Callback function for the Play Direction Service, used to toggle the direction of playback.
| request | The request from the service call, empty for this trigger service |
| response | The response for the service call, containing a message |

|
private |
Plays a single note or presses a button, streams Z velocity for a hardcoded duration to push down on whatever the EE is above.
| duration | The time to hold the note for |
| time | The current time into the note |
|
private |
Callback function for the Play/Pause Service, used to toggle playback of the current track.
| request | The request from the service call, empty for this trigger service |
| response | The response for the service call, containing a message |

|
private |
A wrapper for sending joint jog commands for direct joint velocity control.
| shoulder_lift | Velocity for the shoulder lift joint |
| elbow | Velocity for the elbow joint |
| wrist_1 | Velocity for the wrist 1 joint |
| wrist_2 | Velocity for the wrist 2 joint |
| wrist_3 | Velocity for the wrist 3 joint |
| shoulder_pan | Velocity for the shoulder pan joint |
|
private |
A secondary wrapper for the sending Joint Jog commands that takes a vector instead of individual velocities.
| vel | A vector of doubles containing the joint velocities |
|
private |
A simple helper method for immediately sending stop to the UR3e.
|
private |
A convenience method that neatly packs up a twist messge and publishes it to the UR_Driver.
| x | A double for translational velocity of the End Effector in the X axis |
| y | A double for translational velocity of the End Effector in the Y axis |
| z | A double for translational velocity of the End Effector in the Z axis |
| angular_x | A double for rotational velocity of the End Effector in the X axis (Optional, Defaults to 0.0) |
| angular_y | A double for rotational velocity of the End Effector in the Y axis (Optional, Defaults to 0.0) |
| angular_z | A double for rotational velocity of the End Effector in the Z axis (Optional, Defaults to 0.0) |
|
private |
The public method for sending translational End Effector vector commands to the UR3e.
| vec | Takes a vector3 struct (included in this class, or declared using {x, y, z}) |
|
private |
The startup sequence that moves the robot into the starting position for playing.

|
private |
Callback function for the TimeScale Service, used to set the time scaling factor for playback.
| request | The request from the service call, containing the time scale factor |
| response | The response for the service call, containing a message |

|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |