Skip to content

Commit

Permalink
ros formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
antbono committed Apr 12, 2024
1 parent 6ddfa48 commit de060d7
Show file tree
Hide file tree
Showing 8 changed files with 731 additions and 690 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/build_and_test_humble.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Build (humble)
name: Build and test (humble)

# Controls when the action will run.
on:
Expand Down Expand Up @@ -28,16 +28,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ros-tooling/setup-ros@v0.7
#with:
# use-ros2-testing: true
with:
use-ros2-testing: true
- uses: ros-tooling/action-ros-ci@v0.3
with:
skip-tests: true
#skip-tests: true
target-ros2-distro: humble
colcon-defaults: |
{
"build": {
"symlink-install": false
}
}
vcs-repo-file-url: dependencies.repos
14 changes: 4 additions & 10 deletions .github/workflows/build_and_test_iron.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Build (iron)
name: Build and test (iron)

# Controls when the action will run.
on:
Expand Down Expand Up @@ -28,16 +28,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ros-tooling/setup-ros@v0.7
#with:
# use-ros2-testing: true
with:
use-ros2-testing: true
- uses: ros-tooling/action-ros-ci@v0.3
with:
skip-tests: true
#skip-tests: true
target-ros2-distro: iron
colcon-defaults: |
{
"build": {
"symlink-install": false
}
}
vcs-repo-file-url: dependencies.repos
4 changes: 2 additions & 2 deletions .github/workflows/build_and_test_rolling.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This is a basic workflow to help you get started with Actions

name: Build (rolling)
name: Build and test (rolling)

# Controls when the action will run.
on:
Expand Down Expand Up @@ -32,6 +32,6 @@ jobs:
use-ros2-testing: true
- uses: ros-tooling/action-ros-ci@master
with:
skip-tests: true
#skip-tests: true
target-ros2-distro: rolling
vcs-repo-file-url: dependencies.repos
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build (humble)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_humble.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_humble.yaml)
[![Build (iron)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_iron.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_iron.yaml)
[![Build (rolling)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_rolling.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_rolling.yaml)
[![Build and test (humble)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_humble.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_humble.yaml)
[![Build and test (iron)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_iron.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_iron.yaml)
[![Build and test (rolling)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_rolling.yaml/badge.svg)](https://github.com/antbono/nao_led/actions/workflows/build_and_test_rolling.yaml)

# nao_led

Expand Down
77 changes: 38 additions & 39 deletions nao_led_server/include/nao_led_server/led_action_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,41 @@

#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_
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

} // namespace nao_led_action_client

#endif // NAO_LED_SERVER__LED_ACTION_CLIENT_HPP_
112 changes: 51 additions & 61 deletions nao_led_server/include/nao_led_server/led_action_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
//#include <vector>
#include <array>
//#include <chrono>
#include <string> // std::string, std::stof
#include <string> // std::string, std::stof
#include <cstring>
#include <iostream> // std::cout
#include <iostream> // std::cout

#include "rclcpp/rclcpp.hpp"
#include "rclcpp_action/rclcpp_action.hpp"
Expand All @@ -38,80 +38,70 @@
#include "nao_lola_command_msgs/msg/right_foot_led.hpp"
#include "nao_lola_command_msgs/msg/left_foot_led.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_server
namespace nao_led_action_server
{

using LedsPlay = nao_led_interfaces::action::LedsPlay;
using GoalHandleLedsPlay = rclcpp_action::ServerGoalHandle<LedsPlay>;
using LedIndexes = nao_led_interfaces::msg::LedIndexes;
using LedModes = nao_led_interfaces::msg::LedModes;


class LedsPlayActionServer : public rclcpp::Node
class LedsPlayActionServer : public rclcpp::Node
{
public:
explicit LedsPlayActionServer(const rclcpp::NodeOptions & options = rclcpp::NodeOptions{});
virtual ~LedsPlayActionServer();

private:

rclcpp_action::Server<nao_led_interfaces::action::LedsPlay>::SharedPtr action_server_;
std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle_;


rclcpp::Publisher<nao_lola_command_msgs::msg::HeadLeds>::SharedPtr head_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightEyeLeds>::SharedPtr right_eye_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftEyeLeds>::SharedPtr left_eye_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightEarLeds>::SharedPtr right_ear_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftEarLeds>::SharedPtr left_ear_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::ChestLed>::SharedPtr chest_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightFootLed>::SharedPtr right_foot_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftFootLed>::SharedPtr left_foot_pub_;

std_msgs::msg::ColorRGBA color_off_;
//color_off_.r=0.0; color_off_.g=0.0; color_off_.b=0.0;
nao_led_interfaces::msg::LedIndexes led_indexes_msg_;
nao_led_interfaces::msg::LedModes led_modes_msg_;


rclcpp_action::GoalResponse handleGoal(
const rclcpp_action::GoalUUID & uuid,
std::shared_ptr<const nao_led_interfaces::action::LedsPlay::Goal> goal);

rclcpp_action::CancelResponse handleCancel(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void handleAccepted(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void execute(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void steadyMode(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2> & leds,
float frequency,
std::array<std_msgs::msg::ColorRGBA, 8> & colors, std::array<float, 12> & intensities);

bool blinkingMode(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2> & leds, float frequency,
std::array<std_msgs::msg::ColorRGBA, 8> & colors);

bool loopMode(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2> & leds, float frequency,
std::array<std_msgs::msg::ColorRGBA, 8> & colors);
public:
explicit LedsPlayActionServer(const rclcpp::NodeOptions& options = rclcpp::NodeOptions{});
virtual ~LedsPlayActionServer();

private:
rclcpp_action::Server<nao_led_interfaces::action::LedsPlay>::SharedPtr action_server_;
std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle_;

rclcpp::Publisher<nao_lola_command_msgs::msg::HeadLeds>::SharedPtr head_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightEyeLeds>::SharedPtr right_eye_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftEyeLeds>::SharedPtr left_eye_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightEarLeds>::SharedPtr right_ear_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftEarLeds>::SharedPtr left_ear_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::ChestLed>::SharedPtr chest_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::RightFootLed>::SharedPtr right_foot_pub_;
rclcpp::Publisher<nao_lola_command_msgs::msg::LeftFootLed>::SharedPtr left_foot_pub_;

std_msgs::msg::ColorRGBA color_off_;
// color_off_.r=0.0; color_off_.g=0.0; color_off_.b=0.0;
nao_led_interfaces::msg::LedIndexes led_indexes_msg_;
nao_led_interfaces::msg::LedModes led_modes_msg_;

rclcpp_action::GoalResponse handleGoal(const rclcpp_action::GoalUUID& uuid,
std::shared_ptr<const nao_led_interfaces::action::LedsPlay::Goal> goal);

rclcpp_action::CancelResponse handleCancel(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void handleAccepted(
const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void
execute(const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle);

void
steadyMode(const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2>& leds, float frequency, std::array<std_msgs::msg::ColorRGBA, 8>& colors,
std::array<float, 12>& intensities);

bool
blinkingMode(const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2>& leds, float frequency, std::array<std_msgs::msg::ColorRGBA, 8>& colors);

bool
loopMode(const std::shared_ptr<rclcpp_action::ServerGoalHandle<nao_led_interfaces::action::LedsPlay>> goal_handle,
std::array<uint8_t, 2>& leds, float frequency, std::array<std_msgs::msg::ColorRGBA, 8>& colors);
};

}
} // namespace nao_led_action_server

#endif // NAO_LED_SERVER__LED_ACTION_SERVER_HPP_
Loading

0 comments on commit de060d7

Please sign in to comment.