-
Notifications
You must be signed in to change notification settings - Fork 13.7k
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
Add CAN rgb led #14710
Add CAN rgb led #14710
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing do to import failing the led
lib in some targets.
src/drivers/uavcan/sensors/rgb.cpp
Outdated
@@ -0,0 +1,126 @@ | |||
/**************************************************************************** | |||
* | |||
* Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved. | |
* Copyright (c) 2020 PX4 Development Team. All rights reserved. |
UavcanUavcanRgb::init() | ||
{ | ||
/* | ||
* Setup timer and call back function for periodic updates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the description to the header file? Thanks
src/drivers/uavcan/sensors/rgb.hpp
Outdated
@@ -0,0 +1,78 @@ | |||
/**************************************************************************** | |||
* | |||
* Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Copyright (c) 2014, 2015 PX4 Development Team. All rights reserved. | |
* Copyright (c) 2020 PX4 Development Team. All rights reserved. |
|
||
/** | ||
* @file rgb.hpp | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a description with @brief
annotation? Thanks
/** | ||
* @brief The RGB class | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/drivers/uavcan/sensors/rgb.hpp
Outdated
/* | ||
* Max update rate to avoid exessive bus traffic | ||
*/ | ||
static constexpr unsigned MAX_RATE_HZ = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static constexpr unsigned MAX_RATE_HZ = 100; | |
static constexpr unsigned MAX_RATE_HZ = 100; |
src/drivers/uavcan/sensors/rgb.hpp
Outdated
LedController _led_controller; | ||
|
||
/* | ||
* libuavcan related things |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with a description of each object.
src/drivers/uavcan/sensors/rgb.hpp
Outdated
|
||
typedef uavcan::MethodBinder<UavcanUavcanRgb *, void (UavcanUavcanRgb::*)(const uavcan::TimerEvent &)> | ||
TimerCbBinder; | ||
LedController _led_controller; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LedController _led_controller; | |
LedController _led_controller; |
src/drivers/uavcan/sensors/rgb.cpp
Outdated
#include <systemlib/err.h> | ||
|
||
|
||
UavcanUavcanRgb::UavcanUavcanRgb(uavcan::INode &node) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name this something like UavcanRgbLed
instead of having UavcanUavcan
in the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
src/drivers/uavcan/sensors/rgb.cpp
Outdated
_r = 0; _g = 0; _b = 255; | ||
break; | ||
|
||
case led_control_s::COLOR_AMBER: //make it the same as yellow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case led_control_s::COLOR_AMBER: //make it the same as yellow | |
case led_control_s::COLOR_AMBER: // make it the same as yellow |
src/drivers/uavcan/sensors/rgb.hpp
Outdated
* libuavcan related things | ||
*/ | ||
uavcan::Publisher<uavcan::equipment::indication::LightsCommand> _rgb_pub; | ||
uavcan::TimerEventForwarder<TimerCbBinder> _timer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uavcan::TimerEventForwarder<TimerCbBinder> _timer; | |
uavcan::TimerEventForwarder<TimerCbBinder> _timer; |
src/drivers/uavcan/sensors/rgb.cpp
Outdated
void | ||
UavcanUavcanRgb::periodic_update(const uavcan::TimerEvent &) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
void | |
UavcanUavcanRgb::periodic_update(const uavcan::TimerEvent &) | |
void UavcanUavcanRgb::periodic_update(const uavcan::TimerEvent &) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've seen the general PX4 style moving away from the multi-line function header...
src/drivers/uavcan/sensors/rgb.hpp
Outdated
/* | ||
* Max update rate to avoid exessive bus traffic | ||
*/ | ||
static constexpr unsigned MAX_RATE_HZ = 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100 Hz still seems excessive. What about 20 or 30?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
20 is also is ok , the effect of the breathing light will not be particularly smooth
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good; the only thing I'm wondering about (this is just an organizational thing) is whether this should be under "actuators" instead of "sensors", since an LED is an actuator (a device acting upon a command) rather than a sensor (providing data to the autopilot). Maybe @dagar has an opinion on this as well?
Besides that, looks good.
Yes, but if we're going to do anything here I'd probably want to start by making it a bit more dynamic (at startup). We're paying for a lot of additional state for every possible use case. |
There's a build failure that needs to be fixed, I'll take a look. |
Thank you |
I've tried this PR my branch based on 1.10.1 running on the V5 Nano and I've notice that the board's led won't light up. Also should led be added to the DEPENDS in the CMakeLists? |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
Add CAN rgb led