Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROS 2 lights converter #223

Merged
merged 13 commits into from
Feb 20, 2024
Merged

ROS 2 lights converter #223

merged 13 commits into from
Feb 20, 2024

Conversation

KmakD
Copy link
Contributor

@KmakD KmakD commented Feb 6, 2024

This is a basic converter and most likely its functionality may change and be extended. Right now it is hard to predict what will be required by controller and I want to avoid rewriting parts of code.
The converter has only one simple method, this may change when implementing controller that's why I've put it inside separate files.

Copy link
Contributor

@pkowalsk1 pkowalsk1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the structure of this package. I pointed out a few minor things that, in my opinion, would look better. What are we doing with the header files? "" or <>? xd

@@ -0,0 +1,42 @@
// Copyright 2023 Husarion sp. z o.o.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update it to 2024?

{
public:
/**
* @brief Virtual LED segment of the robot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to move this description to the class brief. In my opinion, it would be better to add short descriptions to all or most impoertant classes in this package as it becomes more complex.


#include <panther_lights/animation/animation.hpp>

#include <iostream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it unused?


~LEDPanel() = default;

void UpdateFrame(const std::size_t iterator_first, const std::vector<std::uint8_t> & values);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a suggestion, but maybe we could add a short description and information about exceptions here?

Comment on lines +77 to +78
std::size_t first_led_iterator_;
std::size_t last_led_iterator_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure it is an iterator? Maybe something similar to first_led_position_?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods from algorithm library use "iterator" naming and I was using this logic

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with iterator 🤓

Comment on lines 41 to 42
auto segment_desc =
YAML::Load("{led_range: 0-" + std::to_string(segment_led_num_ - 1) + ", channel: 1}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto segment_desc =
YAML::Load("{led_range: 0-" + std::to_string(segment_led_num_ - 1) + ", channel: 1}");
const auto segment_desc =
YAML::Load("{led_range: 0-" + std::to_string(segment_led_num_ - 1) + ", channel: 1}");

led_segment_ = std::make_shared<panther_lights::LEDSegment>(segment_desc, controller_freq);
}

// this method may be moved to utils
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea. Should we do it now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked at it and it may be a bit tricky - test_utils have dependencie on rclcpp. There is no point in adding rclcpp dependencies in here. The best solution, I guess, is to devide test_utils into 2 files(for ros and non ros utils). This however makes need for changes in other repositories using current test_utils and I dont nkow if it is a good idea to make them in this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, so it's up to you

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make another PR with this


TEST(TestLEDSegmentInitialization, ValidDescription)
{
auto segment_desc = YAML::Load("{led_range: 0-10, channel: 1}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto segment_desc = YAML::Load("{led_range: 0-10, channel: 1}");
const auto segment_desc = YAML::Load("{led_range: 0-10, channel: 1}");


TEST(TestLEDSegmentInitialization, DescriptionMissingRequiredKey)
{
auto segment_desc = YAML::Load("");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move it to function like CreateSegmentDescription() in test_segment_converter.cpp?

Comment on lines 80 to 83
auto anim_desc = YAML::Load(
"{type: panther_lights::ImageAnimation, "
"image: $(find panther_lights)/animations/triangle01_red.png, "
"duration: 2}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this. Could we move it to function?

@KmakD KmakD requested a review from pkowalsk1 February 13, 2024 11:44
panther_utils/include/panther_utils/test/test_utils.hpp Outdated Show resolved Hide resolved
panther_utils/test/test_test_utils.cpp Outdated Show resolved Hide resolved
panther_lights/src/controller_node.cpp Outdated Show resolved Hide resolved
panther_lights/src/segment_converter.cpp Outdated Show resolved Hide resolved
panther_lights/src/led_segment.cpp Outdated Show resolved Hide resolved
panther_lights/test/test_led_panel.cpp Outdated Show resolved Hide resolved
@KmakD KmakD requested a review from pawelirh February 19, 2024 10:39
@KmakD KmakD merged commit 3c2ad2d into ros2-lights-controller Feb 20, 2024
@KmakD KmakD deleted the ros2-lights-converter branch February 20, 2024 08:02
pkowalsk1 added a commit that referenced this pull request Mar 11, 2024
* ROS 2 lights animations (#221)

* add animation and image_animation class

* controller node and pluginlib

* add tests and fix issues

* add animation images

* add alpha channel

* add charging animation with tests

* update dummy controller

* fix missing includes

* add missing dep

* Update panther_lights/include/panther_lights/animation/animation.hpp

Co-authored-by: Paweł Kowalski <82044322+pkowalsk1@users.noreply.github.com>

* Update panther_lights/include/panther_lights/animation/animation.hpp

Co-authored-by: Paweł Kowalski <82044322+pkowalsk1@users.noreply.github.com>

* review changes

* update tests

---------

Co-authored-by: Paweł Kowalski <82044322+pkowalsk1@users.noreply.github.com>

* ROS 2 lights converter (#223)

* add led_segment

* WIP led_panel and segment converter

* simplify converter

* update segment conversion

* add test for led panel, segment, and converter

* review fixes

* update copyright year

* update controller so it somehow works

* Update tests

* Apply review fixes

* fix gpio tests

* parse controller configuration

* add default animation

* add yaml_utils to panther_utils

* add led animation and queue

* Fix queuing

* fix bug

* priority and timeout queue validation

* move queue to separate file

* add briefs

* param and brightness handle

* user animations, bugs, briefs

* use yaml utils

* fix tests

* update tests

* add led_animation test

* test fixxes

* add led animations queue tests

* clean up code | clean up code

* Update documentation | add launching controller node

* make it work

* update scheduler

* Update panther_lights/LIGHTS_API.md

Co-authored-by: Paweł Irzyk <108666440+pawelirh@users.noreply.github.com>

* review fixes

* update pre-commit and fix typos

* Update panther_bringup/README.md

Co-authored-by: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com>

* Update panther_hardware_interfaces/README.md

Co-authored-by: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com>

* Update panther_lights/README.md

Co-authored-by: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com>

* Update panther_lights/test/test_controller_node.cpp

Co-authored-by: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com>

* review fixes

* Update README.md

---------

Co-authored-by: Paweł Kowalski <82044322+pkowalsk1@users.noreply.github.com>
Co-authored-by: Paweł Irzyk <108666440+pawelirh@users.noreply.github.com>
Co-authored-by: rafal-gorecki <126687345+rafal-gorecki@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants