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

[jsk_robot_startup] Speak when shut down or reboot #1589

Closed
wants to merge 6 commits into from

Conversation

nakane11
Copy link
Member

@nakane11 nakane11 commented Sep 8, 2022

Duplicate knorth55#319

Tell users that robot is shutting down like boot sound.

iory
iory previously approved these changes Sep 9, 2022
@k-okada
Copy link
Member

k-okada commented Sep 9, 2022

I think shutdown.py is a fundamental program and we do not want to raise any errors during execution. For example,,,

        self.client_jp = SoundClient(sound_action='/robotsound_jp', blocking=True)

What will happen if sound_client failed to play sound and keep blocking ?

Another solution may use Non-ROS layer to tell everyone to shutdown.
As far as I understand, pr2 uses rc.d mechanism to play sound beep on startup.
and if rc0.d/K00endbootstartshutdownbeep.sh ? rc6.d/S80endshutdownbeep.sh ? rc6.d/K00endbootstartshutdownbeep.sh??? works correctly, it should play beep sound.

One reason would be... they try to play sound after OS stopped the sound driver? or something.
In that case, we could chnage/move file name.

https://linuc.org/study/knowledge/515/
https://www.2daygeek.com/6-commands-to-shutdown-halt-poweroff-reboot-the-linux-system/

$ find rc* | grep beep
rc0.d/S80endshutdownbeep.sh
rc0.d/K00endbootstartshutdownbeep.sh
rc1.d/S99endbootstartshutdownbeep.sh
rc2.d/S99endbootstartshutdownbeep.sh
rc3.d/S99endbootstartshutdownbeep.sh
rc4.d/S99endbootstartshutdownbeep.sh
rc5.d/S99endbootstartshutdownbeep.sh
rc6.d/S80endshutdownbeep.sh
rc6.d/K00endbootstartshutdownbeep.sh
rcS.d/S19startbootbeep.sh

applications@pr1040:/etc/rc0.d $ cat K00endbootstartshutdownbeep.sh
#!/bin/sh

if test -e /etc/slave; then
# Slave boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 587.33 -l 250 -n -f 659.26 -l 250 -n -f 783.99 -l 500
# Slave boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 659.26 -l 250 -n -f 783.99 -l 250 -n -f 880.00 -l 250 -n -f 1046.50 -l 500
# Slave shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 1046.50 -l 250 -n -f 880.00 -l 250 -n -f 783.99 -l 250 -n -f 659.26 -l 500
# Slave shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 783.99 -l 250 -n -f 659.26 -l 250 -n -f 587.33 -l 250 -n -f 523.25 -l 500
    fi

else

# Master boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 261.63 -l 250 -n -f 293.44 -l 250 -n -f 329.63 -l 250 -n -f 392.00 -l 500
# Master boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 329.63 -l 250 -n -f 392.00 -l 250 -n -f 440.00 -l 250 -n -f 523.25 -l 500
# Master shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 440.00 -l 250 -n -f 392.00 -l 250 -n -f 329.63 -l 500
# Master shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 392.00 -l 250 -n -f 329.63 -l 250 -n -f 293.44 -l 250 -n -f 261.33 -l 500
    fi

fi

applications@pr1040:/etc/rc0.d $ cat S80endshutdownbeep.sh
#!/bin/sh

if test -e /etc/slave; then
# Slave boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 587.33 -l 250 -n -f 659.26 -l 250 -n -f 783.99 -l 500
# Slave boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 659.26 -l 250 -n -f 783.99 -l 250 -n -f 880.00 -l 250 -n -f 1046.50 -l 500
# Slave shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 1046.50 -l 250 -n -f 880.00 -l 250 -n -f 783.99 -l 250 -n -f 659.26 -l 500
# Slave shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 783.99 -l 250 -n -f 659.26 -l 250 -n -f 587.33 -l 250 -n -f 523.25 -l 500
    fi

else

# Master boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 261.63 -l 250 -n -f 293.44 -l 250 -n -f 329.63 -l 250 -n -f 392.00 -l 500
# Master boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 329.63 -l 250 -n -f 392.00 -l 250 -n -f 440.00 -l 250 -n -f 523.25 -l 500
# Master shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 440.00 -l 250 -n -f 392.00 -l 250 -n -f 329.63 -l 500
# Master shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 392.00 -l 250 -n -f 329.63 -l 250 -n -f 293.44 -l 250 -n -f 261.33 -l 500
    fi

fi
applications@pr1040:/etc/rc5.d $ cat S99endbootstartshutdownbeep.sh
#!/bin/sh

if test -e /etc/slave; then
# Slave boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 587.33 -l 250 -n -f 659.26 -l 250 -n -f 783.99 -l 500
# Slave boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 659.26 -l 250 -n -f 783.99 -l 250 -n -f 880.00 -l 250 -n -f 1046.50 -l 500
# Slave shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 1046.50 -l 250 -n -f 880.00 -l 250 -n -f 783.99 -l 250 -n -f 659.26 -l 500
# Slave shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 783.99 -l 250 -n -f 659.26 -l 250 -n -f 587.33 -l 250 -n -f 523.25 -l 500
    fi

else

# Master boot-start
    if (echo $0|grep 'S..startbootbeep.sh' > /dev/null); then
        beep -f 261.63 -l 250 -n -f 293.44 -l 250 -n -f 329.63 -l 250 -n -f 392.00 -l 500
# Master boot-finish
    elif (echo $0|grep 'S..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 329.63 -l 250 -n -f 392.00 -l 250 -n -f 440.00 -l 250 -n -f 523.25 -l 500
# Master shutdown-start
    elif (echo $0|grep 'K..endbootstartshutdownbeep.sh' > /dev/null); then
        beep -f 523.25 -l 250 -n -f 440.00 -l 250 -n -f 392.00 -l 250 -n -f 329.63 -l 500
# Master shutdown-finish
    elif (echo $0|grep 'S..endshutdownbeep.sh' > /dev/null); then
        beep -f 392.00 -l 250 -n -f 329.63 -l 250 -n -f 293.44 -l 250 -n -f 261.33 -l 500
    fi

fi

@iory iory dismissed their stale review September 9, 2022 10:32

came up with a better solution.

@nakane11
Copy link
Member Author

nakane11 commented Sep 10, 2022

If we adopt rc.d mechanism, we have to put a script(ex. endshutdownbeep.sh) in /etc/init.d, create symbolic links from /etc/rc*.d to the script and install beep.
Buzzer in motherboard may be quiet compared to speaker.

I used SimpleActionClient to wait for speaking to finish before shutting down.

Copy link
Member

@iory iory left a comment

Choose a reason for hiding this comment

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

This change adds the ability to speak, which is good because timeout is set and users not using robotsound_jp can safely use the shutdown node.

@k-okada
Copy link
Member

k-okada commented Sep 22, 2022

I still in favor of adding spaking ability on highe level such as https://github.com/knorth55/jsk_robot/pull/314/files (or more higher) or lower level such as rc.d as startup beep sound.

@nakane11
Copy link
Member Author

OK. I'll consider the best way.

@nakane11
Copy link
Member Author

nakane11 commented Sep 29, 2022

@k-okada
fetch cannot use beep because it does not have buzzer(maybe it comes with a case) and I checked Boot Beep is set to enabled in BIOS.

I tried to use rc.d and it worked on my laptop. master...nakane11:jsk_robot:rc-shutdown
However, it seemed possible that aplay could not be executed before alsa became unavailable.

So I used systemd instead. #1628
Even if services fail, they automatically end(/etc/systemd/system.conf) and shutdown is safely executed.

@k-okada
Copy link
Member

k-okada commented Oct 13, 2022

moved to #1628

@k-okada k-okada closed this Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants