-
Notifications
You must be signed in to change notification settings - Fork 60
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 switchbot status publisher #505
Add switchbot status publisher #505
Conversation
Because the upstream master was updated.
@@ -17,6 +17,8 @@ def __init__(self, | |||
actionname, | |||
SwitchBotCommandAction | |||
) | |||
rospy.loginfo("Waiting for action server to start.") | |||
self.action_client.wait_for_server() |
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.
Basically it is nice to check if action server is active.
But there are some cases that user want to launch this type of client before action server is launched.
And currently this client assumes that initialization of client class has finished even action server is inactive and we want to preserve default behavior of our code so that our robot demonstration works without changing code.
So could you add timeout
args to __init__
and set some limited default to it (e.g. '5' or so on) and use it here?
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 changed timeout in wait_for_server()
as an additional __init()__
argment with 5 [sec] default value.
def __init__(self,
actionname='switchbot_ros/switch',
topicname='switchbot_ros/devices',
timeout=5):
rospy.loginfo("Waiting for action server to start. (timeout: " + str(timeout) + "[sec])")
self.action_client.wait_for_server(timeout=rospy.Duration(timeout,0))
switchbot_ros/msg/Bot.msg
Outdated
|
||
float64 battery # the current battery level, 0-100 | ||
|
||
string power # ON/OFF state |
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.
How about bool
instead of string
?
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 changed the type to bool.
float64 battery # the current battery level, 0-100 | ||
|
||
string power # ON/OFF state | ||
string device_mode # pressMode, switchMode, or customizeMode |
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.
Could you add candidates constants of this field to this message like https://docs.ros.org/en/noetic/api/visualization_msgs/html/msg/Marker.html ?
string DEVICEMODE_PRESS = "pressMode"
or something like that.
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 added 3 candedate constants as
string DEVICEMODE_PRESS = "pressMode"
string DEVICEMODE_SWITCH = "switchMode"
string DEVICEMODE_CUSTOMIZE = "customizeMode"
switchbot_ros/msg/StripLight.msg
Outdated
@@ -0,0 +1,6 @@ | |||
Header header # timestamp | |||
|
|||
string power # ON/OFF state |
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.
bool
suggestion like above.
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 changed the type to bool.
switchbot_ros/msg/StripLight.msg
Outdated
Header header # timestamp | ||
|
||
string power # ON/OFF state | ||
string color # the color value, RGB "255:255:255" |
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.
How about split this field into color_r
, color_g
, color_b
integers instead of string so that we can easily set value to here. There are some languages that do not support rich string manipulation.
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 split color
int color_r
, color_g
and color_b
.
rgb_string = status['color']
r, g, b = map(int, rgb_string.split(':'))
msg.color_r = r
msg.color_g = g
msg.color_b = b
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.
LGTM. Thanks for your contribution!.
Thanks for your review. |
wait_for_server()
after creating the action client for stability