-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenAI example client ported to SMACC (#557)
* initial commit for openAI example * Replaced get with post, added key fetch logic * Added ability to modify the body of an http request for the http client * Added functionality to encode and send image data to ChatGPT * Added APIs to add headers to an outgoing HTTP request * HTTP requests can now deal with CDNs * Expanded example openAI node to submit a more sophisticated request with an image * Using env variable for test iamge location * Fixed commit errors * Renamed instantiation of HTTP request CB to something more specific to OpenAI
- Loading branch information
Showing
24 changed files
with
2,006 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
smacc2_sm_reference_library/sm_atomic_openai/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(sm_atomic_openai) | ||
|
||
set(CMAKE_BUILD_TYPE "Debug") | ||
|
||
# Default to C++17 | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 17) | ||
endif() | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
endif() | ||
|
||
# find dependencies | ||
find_package(ament_cmake REQUIRED) | ||
find_package(smacc2 REQUIRED) | ||
find_package(ros_timer_client REQUIRED) | ||
find_package(http_client REQUIRED) | ||
find_package(Boost COMPONENTS thread REQUIRED) | ||
find_package(OpenSSL REQUIRED) | ||
find_package(OpenCV REQUIRED) | ||
|
||
include_directories(include | ||
${smacc2_INCLUDE_DIRS} | ||
${ros_timer_client_INCLUDE_DIRS} | ||
${http_client_INCLUDE_DIRS} | ||
) | ||
|
||
add_executable(${PROJECT_NAME}_node | ||
src/sm_atomic_openai/sm_atomic_openai_node.cpp) | ||
|
||
target_link_libraries(${PROJECT_NAME}_node | ||
${smacc2_LIBRARIES} | ||
${ros_timer_client_LIBRARIES} | ||
${http_client_LIBRARIES} | ||
${Boost_LIBRARIES} | ||
${OpenCV_LIBRARIES} | ||
OpenSSL::SSL | ||
OpenSSL::Crypto | ||
) | ||
|
||
ament_target_dependencies(${PROJECT_NAME}_node smacc2) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include | ||
) | ||
|
||
install(DIRECTORY | ||
launch | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
install(DIRECTORY | ||
config | ||
DESTINATION share/${PROJECT_NAME} | ||
) | ||
|
||
install(TARGETS | ||
${PROJECT_NAME}_node | ||
DESTINATION lib/${PROJECT_NAME}) | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<h2>State Machine Diagram</h2> | ||
|
||
![sm_atomic_http](docs/SmAtomic_2021-10-18_93942.svg) | ||
|
||
<h2>Description</h2> A completely minimal state machine example.<br></br> | ||
|
||
<h2>Build Instructions</h2> | ||
|
||
First, source your chosen ros2 distro. | ||
``` | ||
source /opt/ros/rolling/setup.bash | ||
``` | ||
``` | ||
source /opt/ros/humble/setup.bash | ||
``` | ||
|
||
Before you build, make sure you've installed all the dependencies... | ||
|
||
``` | ||
rosdep install --ignore-src --from-paths src -y -r | ||
``` | ||
|
||
Then build with colcon build... | ||
|
||
``` | ||
colcon build | ||
``` | ||
<h2>Operating Instructions</h2> | ||
After you build, remember to source the proper install folder... | ||
|
||
``` | ||
source ~/workspace/humble_ws/install/setup.bash | ||
``` | ||
|
||
And then run the launch file... | ||
|
||
``` | ||
ros2 launch sm_atomic_http sm_atomic_http.launch | ||
``` | ||
|
||
<h2>Viewer Instructions</h2> | ||
If you have the SMACC2 Runtime Analyzer installed then type... | ||
|
||
``` | ||
ros2 run smacc2_rta smacc2_rta | ||
``` | ||
|
||
If you don't have the SMACC2 Runtime Analyzer click <a href="https://robosoft.ai/product-category/smacc2-runtime-analyzer/">here</a>. |
3 changes: 3 additions & 0 deletions
3
smacc2_sm_reference_library/sm_atomic_openai/config/sm_atomic_openai_config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
global_parameter_server: | ||
ros__parameters: | ||
signal_detector_loop_freq: 200 |
7 changes: 7 additions & 0 deletions
7
smacc2_sm_reference_library/sm_atomic_openai/config/sm_atomic_openai_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
state_machine_rosparam_ws: /SmAtomicOpenAI | ||
success_switch: | ||
- type: state_reached | ||
state_name: "sm_atomic_openai::State2" | ||
failure_switch: | ||
- type: timeout | ||
duration: 10.0 # sec |
Oops, something went wrong.