|
FP Perception 0.1.2
|
SentimentDriver class for handling prompt_tools based sentument analysis. More...
#include <sentiment_driver.hpp>


Public Member Functions | |
| SentimentDriver () | |
| Constructor for SentimentDriver. | |
| ~SentimentDriver () override | |
| Destructor for SentimentDriver. | |
| void | initialize (const rclcpp::Node::SharedPtr &node) override |
| Initialize the driver. | |
| void | deinitialize () override |
| Deinitialize the driver. | |
| sentiment_result | analyze (const sentiment_request &request_data) override |
| Set data to the driver. | |
| void | test () override |
| Test method for the driver. | |
Public Member Functions inherited from fp_perception::RestBase | |
| RestBase () | |
| Constructor. | |
| virtual | ~RestBase () |
| Destructor. | |
| virtual void | initialize_rest_base (const rclcpp::Node::SharedPtr &node, std::string plugin_name="RestBase", std::string api_key_name="") |
| Initialize the REST base class. | |
| virtual fp_perception::RESTResponse | call (const fp_perception::RESTRequest &req) |
| Request data from the REST API. | |
| virtual fp_perception::RESTResponse | call_audio (const fp_perception::RESTRequest &req) |
| Request audio data from the REST API. | |
| virtual fp_perception::RESTResponse | call_tts (const fp_perception::RESTRequest &req) |
Public Member Functions inherited from fp_perception::DriverBase | |
| virtual | ~DriverBase ()=default |
| virtual std::string | getName () const |
| Get the name of the driver. | |
| void | check_directory (std::string folder_name) |
| Check if the test directory exists, create it if not. | |
| const std::filesystem::path | check_file (const std::string &file_name) |
Protected Member Functions | |
| nlohmann::json | toJson (const fp_perception::RESTRequest &request) override |
| Convert a prompt request to a JSON object. | |
| fp_perception::RESTResponse | fromJson (const nlohmann::json &object) override |
| Convert a JSON object to a RESTResponse. | |
| void | produce_diagnostics (diagnostic_updater::DiagnosticStatusWrapper &status) |
Protected Member Functions inherited from fp_perception::RestBase | |
| void | apply_timeouts (CURL *curl) |
| void | record_rest_result (bool success, long http_code, const std::string &error) |
Protected Member Functions inherited from fp_perception::DriverBase | |
| void | initialize_base (const rclcpp::Node::SharedPtr &node) |
| Initializer base driver in place of constructor due to plugin semantics. | |
| bool | diagnostics_enabled () const |
| void | enable_diagnostics (const std::string &hardware_id, const std::string &task_name, std::function< void(diagnostic_updater::DiagnosticStatusWrapper &)> task, std::chrono::milliseconds period=std::chrono::seconds(1)) |
| void | disable_diagnostics () |
Protected Attributes | |
| fp_perception::RESTResponse | response_ |
| sentiment_result | last_result_ |
Protected Attributes inherited from fp_perception::RestBase | |
| std::string | plugin_name_ |
| std::string | uri_ |
| std::string | method_ |
| bool | ssl_verify_ |
| std::string | auth_type_ |
| std::string | api_key_ |
| long | timeout_sec_ { 60 } |
| long | connect_timeout_sec_ { 10 } |
| std::atomic< uint64_t > | rest_request_count_ { 0 } |
| std::atomic< uint64_t > | rest_failure_count_ { 0 } |
| std::atomic< bool > | last_rest_success_ { true } |
| std::atomic< long > | last_rest_http_code_ { 0 } |
| std::mutex | rest_status_mutex_ |
| std::string | last_rest_error_ |
Protected Attributes inherited from fp_perception::DriverBase | |
| rclcpp::Node::SharedPtr | node_ |
| ROS node for the driver. | |
| std::string | name_ |
| Name of the driver. | |
| std::mutex | buffer_mutex_ |
| Mutex to protect access to the driver data. | |
| std::condition_variable | buffer_cv_ |
| Condition variable to notify when new data is available. | |
| std::atomic< bool > | is_running_ { false } |
| Flag to indicate if the driver thread is running. | |
| bool | diagnostics_enabled_ { false } |
| Flag to enable standard ROS diagnostics publishing. | |
| std::unique_ptr< diagnostic_updater::Updater > | diagnostics_updater_ |
| rclcpp::TimerBase::SharedPtr | diagnostics_timer_ |
Additional Inherited Members | |
Static Protected Member Functions inherited from fp_perception::RestBase | |
| static std::string | build_http_error_message (long http_code, const std::string &response_data) |
| static size_t | write_callback (void *contents, size_t size, size_t nmemb, std::string *userp) |
SentimentDriver class for handling prompt_tools based sentument analysis.
This class is responsible for managing the sentiment analysis using the prompt_tools service. It provides methods to initialize the driver, start and stop the service, and retrieve sentiment analysis data. It uses the prompt_msgs::srv::Prompt service to send text for sentiment analysis and receive the response.
|
inline |
Constructor for SentimentDriver.
Initializes the sentiment analysis service client.
|
inlineoverride |
Destructor for SentimentDriver.
Cleans up the sentiment analysis service client.
|
inlineoverridevirtual |
Set data to the driver.
This function sends the latest audio data to the transcription service. It expects the input to be a vector of audio chunks in the form of std::vector<std::vector<int16_t>>.
| input | The latest data from the driver. |
Implements fp_perception::SentimentAnalysisDriver.
|
inlineoverridevirtual |
Deinitialize the driver.
Required by DriverBase. Clears cached response state and releases the node.
Implements fp_perception::DriverBase.
|
inlineoverrideprotectedvirtual |
Convert a JSON object to a RESTResponse.
This method converts the JSON response from the sentiment analysis service to a RESTResponse object.
| object | The JSON object to convert |
Implements fp_perception::RestBase.
|
inlineoverridevirtual |
Initialize the driver.
This function should be overridden in derived classes to provide specific initialization.
| node | Shared pointer to the ROS node |
Reimplemented from fp_perception::DriverBase.
|
inlineprotected |
|
inlineoverridevirtual |
Test method for the driver.
This function can be overridden in derived classes to implement specific test logic.
Reimplemented from fp_perception::DriverBase.
|
inlineoverrideprotectedvirtual |
Convert a prompt request to a JSON object.
This method converts the sentiment request to a JSON object that can be sent to the sentiment analysis service. It includes the prompt text and options for the JSON object.
| prompt | The sentiment request to convert |
Implements fp_perception::RestBase.
|
protected |
|
protected |