-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit
- Loading branch information
0 parents
commit af08cc9
Showing
11 changed files
with
1,337 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(nao_led_interfaces) | ||
|
||
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(geometry_msgs REQUIRED) | ||
find_package(rosidl_default_generators REQUIRED) | ||
|
||
rosidl_generate_interfaces(${PROJECT_NAME} | ||
"msg/LedIndexes.msg" | ||
"msg/LedModes.msg" | ||
"action/LedsPlay.action" | ||
DEPENDENCIES geometry_msgs | ||
) | ||
|
||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# comment the line when a copyright and license is added to all source files | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# comment the line when this package is in a git repo and when | ||
# a copyright and license is added to all source files | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
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,16 @@ | ||
# Request: | ||
uint8[2] leds | ||
uint8 mode | ||
float32 frequency | ||
std_msgs/ColorRGBA[8] colors # max 8 colors for eyes | ||
float32[12] intensities # max 12 leds for head | ||
float32 duration #seconds | ||
--- | ||
# Result | ||
bool success | ||
|
||
--- | ||
#Feedback | ||
|
||
|
||
|
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,9 @@ | ||
uint8 HEAD=0 | ||
uint8 REYE=1 | ||
uint8 LEYE=2 | ||
uint8 REAR=3 | ||
uint8 LEAR=4 | ||
uint8 CHEST=5 | ||
uint8 RFOOT=6 | ||
uint8 LFOOT=7 | ||
uint8 NUMLEDS=8 |
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 @@ | ||
uint8 STEADY=0 | ||
uint8 BLINKING=1 | ||
uint8 LOOP=2 |
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,24 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="3"> | ||
<name>nao_led_interfaces</name> | ||
<version>0.0.0</version> | ||
<description>TODO: Package description</description> | ||
<maintainer email="bnontn89@gmail.com">antbono</maintainer> | ||
<license>Apache License 2.0</license> | ||
|
||
<buildtool_depend>ament_cmake</buildtool_depend> | ||
|
||
<depend>geometry_msgs</depend> | ||
<buildtool_depend>rosidl_default_generators</buildtool_depend> | ||
<exec_depend>rosidl_default_runtime</exec_depend> | ||
<member_of_group>rosidl_interface_packages</member_of_group> | ||
|
||
|
||
<test_depend>ament_lint_auto</test_depend> | ||
<test_depend>ament_lint_common</test_depend> | ||
|
||
<export> | ||
<build_type>ament_cmake</build_type> | ||
</export> | ||
</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,123 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(nao_led_server) | ||
|
||
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(nao_led_interfaces REQUIRED) | ||
find_package(nao_lola_sensor_msgs REQUIRED) | ||
find_package(nao_lola_command_msgs REQUIRED) | ||
find_package(std_msgs REQUIRED) | ||
find_package(std_srvs REQUIRED) | ||
find_package(rclcpp REQUIRED) | ||
find_package(rclcpp_action REQUIRED) | ||
find_package(rclcpp_components REQUIRED) | ||
find_package(rcutils REQUIRED) | ||
|
||
|
||
# Include Cpp "include" directory | ||
include_directories(include) | ||
|
||
|
||
#################### LED SERVER ########################### | ||
add_library(led_server SHARED | ||
src/led_action_server.cpp) | ||
|
||
target_include_directories(led_server PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
target_compile_definitions(led_server | ||
PRIVATE "CUSTOM_ACTION_CPP_BUILDING_DLL") | ||
|
||
rclcpp_components_register_node(led_server | ||
PLUGIN "nao_led_action_server::LedsPlayActionServer" | ||
EXECUTABLE led_action_server | ||
) | ||
|
||
set(LED_SERVER_INCLUDE_DEPENDS | ||
"rclcpp" | ||
"rclcpp_action" | ||
"rclcpp_components" | ||
"nao_lola_command_msgs" | ||
"nao_lola_sensor_msgs" | ||
"nao_led_interfaces" | ||
"std_msgs") | ||
|
||
ament_target_dependencies(led_server ${LED_SERVER_INCLUDE_DEPENDS}) | ||
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) | ||
ament_export_dependencies(${LED_SERVER_INCLUDE_DEPENDS}) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include) | ||
install( | ||
TARGETS led_server | ||
EXPORT export_${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
INCLUDES DESTINATION include) | ||
|
||
#################### LED CLIENT ########################### | ||
add_library(led_client SHARED | ||
src/led_action_client.cpp | ||
) | ||
|
||
target_include_directories(led_server PRIVATE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include>) | ||
|
||
target_compile_definitions(led_client | ||
PRIVATE "CUSTOM_ACTION_CPP_BUILDING_DLL") | ||
|
||
rclcpp_components_register_node(led_client | ||
PLUGIN "nao_led_action_client::LedsPlayActionClient" | ||
EXECUTABLE led_action_client | ||
) | ||
|
||
set(LED_CLIENT_INCLUDE_DEPENDS | ||
"rclcpp" | ||
"rclcpp_action" | ||
"rclcpp_components" | ||
"nao_lola_command_msgs" | ||
"nao_lola_sensor_msgs" | ||
"nao_led_interfaces" | ||
"std_msgs" | ||
) | ||
|
||
ament_target_dependencies(led_client ${LED_CLIENT_INCLUDE_DEPENDS}) | ||
ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) | ||
ament_export_dependencies(${LED_CLIENT_INCLUDE_DEPENDS}) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include) | ||
install( | ||
TARGETS led_client | ||
EXPORT export_${PROJECT_NAME} | ||
ARCHIVE DESTINATION lib | ||
LIBRARY DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
INCLUDES DESTINATION include) | ||
|
||
|
||
|
||
|
||
#################### TEST ############################### | ||
if(BUILD_TESTING) | ||
find_package(ament_lint_auto REQUIRED) | ||
# the following line skips the linter which checks for copyrights | ||
# comment the line when a copyright and license is added to all source files | ||
set(ament_cmake_copyright_FOUND TRUE) | ||
# the following line skips cpplint (only works in a git repo) | ||
# comment the line when this package is in a git repo and when | ||
# a copyright and license is added to all source files | ||
set(ament_cmake_cpplint_FOUND TRUE) | ||
ament_lint_auto_find_test_dependencies() | ||
endif() | ||
|
||
ament_package() |
85 changes: 85 additions & 0 deletions
85
nao_led_server/include/nao_led_server/led_action_client.hpp
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,85 @@ | ||
// Copyright 2024 Antonio Bono | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef NAO_LED_SERVER__LED_ACTION_CLIENT_HPP_ | ||
#define NAO_LED_SERVER__LED_ACTION_CLIENT_HPP_ | ||
|
||
#include <functional> | ||
#include <future> | ||
#include <memory> | ||
#include <string> | ||
#include <sstream> | ||
|
||
#include "ament_index_cpp/get_package_share_directory.hpp" | ||
#include "boost/filesystem.hpp" | ||
|
||
#include "rclcpp/rclcpp.hpp" | ||
#include "rclcpp_action/rclcpp_action.hpp" | ||
#include "rclcpp_components/register_node_macro.hpp" | ||
|
||
#include "nao_lola_command_msgs/msg/head_leds.hpp" | ||
#include "nao_lola_command_msgs/msg/right_eye_leds.hpp" | ||
#include "nao_lola_command_msgs/msg/left_eye_leds.hpp" | ||
#include "nao_lola_command_msgs/msg/right_ear_leds.hpp" | ||
#include "nao_lola_command_msgs/msg/left_ear_leds.hpp" | ||
#include "nao_lola_command_msgs/msg/chest_led.hpp" | ||
#include "nao_lola_command_msgs/msg/right_foot_led.hpp" | ||
#include "nao_lola_command_msgs/msg/left_foot_led.hpp" | ||
|
||
#include "nao_led_interfaces/action/leds_play.hpp" | ||
#include "nao_led_interfaces/msg/led_indexes.hpp" | ||
#include "nao_led_interfaces/msg/led_modes.hpp" | ||
#include "nao_led_interfaces/action/leds_play.hpp" | ||
|
||
#include "std_msgs/msg/color_rgba.hpp" | ||
|
||
namespace nao_led_action_client { | ||
|
||
class LedsPlayActionClient : public rclcpp::Node { | ||
public: | ||
explicit LedsPlayActionClient(const rclcpp::NodeOptions & options = rclcpp::NodeOptions{}); | ||
virtual ~LedsPlayActionClient(); | ||
|
||
void eyesStatic( bool flag ); | ||
void headStatic( bool flag ); | ||
void earsStatic( bool flag ); | ||
void chestStatic( bool flag ); | ||
void earsLoop( bool flag ); | ||
void headLoop( bool flag ); | ||
void eyesLoop( bool flag ); | ||
|
||
private: | ||
|
||
void goalResponseCallback( | ||
const rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::SharedPtr & goal_handle); | ||
void feedbackCallback( | ||
rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::SharedPtr, | ||
const std::shared_ptr<const nao_led_interfaces::action::LedsPlay::Feedback> feedback); | ||
void resultCallback( | ||
const rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::WrappedResult & result); | ||
|
||
|
||
rclcpp_action::Client<nao_led_interfaces::action::LedsPlay>::SharedPtr client_ptr_; | ||
|
||
rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::SharedPtr head_goal_handle_; | ||
//std::shared_future<nao_led_interfaces::action::LedsPlay::Impl::CancelGoalService::Response::SharedPtr> head_goal_handle_; | ||
rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::SharedPtr eyes_goal_handle_; | ||
rclcpp_action::ClientGoalHandle<nao_led_interfaces::action::LedsPlay>::SharedPtr ears_goal_handle_; | ||
|
||
|
||
}; // LedsPlayActionClient | ||
|
||
} // nao_led_action_client | ||
|
||
#endif // NAO_LED_SERVER__LED_ACTION_CLIENT_HPP_ |
Oops, something went wrong.