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

Feature/humble fix gazebo launch #46

Draft
wants to merge 41 commits into
base: feature/humble_devel
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4928cb4
add cube_petit_ros cube_petit_description
AiriYokochi May 21, 2024
dc581f7
update readme
AiriYokochi May 21, 2024
8d0b957
add gazebo launch
AiriYokochi May 21, 2024
e784dc5
fix xacro name
AiriYokochi May 21, 2024
e6b66e3
add teleop_key
AiriYokochi May 21, 2024
0d66686
Merge branch 'feature/humble_add_gazebo' into feature/humble_bringup
AiriYokochi May 21, 2024
feefa96
add lidar bringup
AiriYokochi May 21, 2024
84a2eda
add hw interface
AiriYokochi May 22, 2024
38290e4
add hwcontol launch
AiriYokochi May 22, 2024
999af39
add launch
AiriYokochi May 22, 2024
b86a788
fix path
AiriYokochi May 22, 2024
c312c6b
fix bug
AiriYokochi May 22, 2024
67b388f
add gazebo xacro
AiriYokochi May 22, 2024
ac4d398
add lidar bringup
AiriYokochi May 22, 2024
99023a1
hardware interface setting file
AiriYokochi May 23, 2024
57f3682
fixpy
AiriYokochi May 23, 2024
4ba523c
update_hardware interface
AiriYokochi May 23, 2024
0e1b534
fix hardware interface
AiriYokochi May 26, 2024
55d0468
fix for gazebo xacro
AiriYokochi May 27, 2024
5d78414
update teleop
AiriYokochi May 27, 2024
d0235de
fix teleop config
AiriYokochi May 28, 2024
407899b
add text_to_jtalk package
AiriYokochi Jun 4, 2024
3e51d89
update jtalk
AiriYokochi Jun 4, 2024
0c0a2ab
add janken
AiriYokochi Jun 13, 2024
544168e
add depthai_hand_tracker
AiriYokochi Jun 13, 2024
3aa6957
change path
AiriYokochi Jun 19, 2024
48948de
add speech_to_text_package
AiriYokochi Jun 4, 2024
ddd0a69
add hotword
AiriYokochi Jun 4, 2024
83f71d4
add teleop and talk to bringup launch
AiriYokochi Jun 19, 2024
b0df33b
add hotword to launch
AiriYokochi Jun 20, 2024
318669d
delete unneed log
AiriYokochi Jun 20, 2024
2ad77c5
add facial_animation
AiriYokochi Jun 19, 2024
c8ab4a4
add to launch file
AiriYokochi Jun 19, 2024
3c3d8fb
delete lines
AiriYokochi Jun 20, 2024
5c3cbfd
update google-chrome config
AiriYokochi Jun 20, 2024
0278d65
add param
AiriYokochi Jun 24, 2024
a679340
add to launch file
AiriYokochi Jun 19, 2024
6a6997c
add speech
AiriYokochi Jun 20, 2024
bd768cf
update_CmakeLists
AiriYokochi Jun 21, 2024
16fc748
fix gazebo launch
AiriYokochi Jun 21, 2024
4c6382e
fix bringup
AiriYokochi Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add speech_to_text_package
  • Loading branch information
AiriYokochi committed Jun 19, 2024
commit 48948de5055a1dd3f4575d933cc1bd6ebd31699c
35 changes: 35 additions & 0 deletions cube_petit_speech_to_text/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.8)
project(cube_petit_speech_to_text)

if(CMAKE_COMPILER_IS_GNUCXX
OR CMAKE_CXX_COMPILER_ID
MATCHES
"Clang"
)
add_compile_options(
-Wall
-Wextra
-Wpedantic
)
endif()

find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
install(
DIRECTORY launch
DESTINATION share/${PROJECT_NAME}
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_copyright_FOUND TRUE)
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()

install(
PROGRAMS scripts/cube_petit_speech_to_text.py
DESTINATION lib/${PROJECT_NAME}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-

# Copyright (c) 2024 SoftBank Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Launch file."""
from launch_ros.actions import Node

from launch import LaunchDescription

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
# from launch.actions import GroupAction
from launch.actions import DeclareLaunchArgument
from launch.actions import IncludeLaunchDescription
from launch.launch_description_sources import PythonLaunchDescriptionSource
import os

def generate_launch_description() -> LaunchDescription:
"""Generate launch description."""
return LaunchDescription([
Node(
package='cube_petit_speech_to_text',
executable='cube_petit_speech_to_text.py',
name='speech_to_text'
),
])
25 changes: 25 additions & 0 deletions cube_petit_speech_to_text/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>cube_petit_speech_to_text</name>
<version>0.0.0</version>
<description>The cube_petit_speech_to_text package</description>
<maintainer email="SBGRP-git@g.softbank.co.jp">SoftBank corp.</maintainer>
<license>Apache 2.0</license>
<url type="repository">https://github.com/sbgisen/cube_petit_ros</url>
<url type="bugtracker">https://github.com/sbgisen/cube_petit_ros/issues</url>

<exec_depend>rclpy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<exec_depend>sbgisen_msgs</exec_depend>
<exec_depend>python3-psutil</exec_depend>
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>
1 change: 1 addition & 0 deletions cube_petit_speech_to_text/resources/Cube-petit_ref.json

Large diffs are not rendered by default.

98 changes: 98 additions & 0 deletions cube_petit_speech_to_text/scripts/cube_petit_speech_to_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#!/usr/bin/env python3
# -*- coding:utf-8 -*-

# Copyright (c) 2024 SoftBank Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os
import signal
import subprocess
import sys
from datetime import datetime

import rclpy
import rclpy.node
from rclpy.executors import ExternalShutdownException
from std_msgs.msg import String
from xml.dom.expatbuilder import TEXT_NODE


class JuliusSpeechToText(rclpy.node.Node):
def __init__(self):
super().__init__('cube_petit_speech_to_text')
self.publisher_ = self.create_publisher(String, '/julius_result_text', 1)
self.rate = self.create_rate(1) # 1hz
self.pkill_julius()
self.start_listening()

def __del__(self):
self.stop_listening()
self.pkill_julius()

def start_listening(self):
cmd = 'cd ~/lib/julius_libs/dictation-kit/;bash run-linux-dnn.sh'
self.julius_process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
self.get_logger().info('julius:started')

def stop_listening(self):
self.get_logger().info('julius:successfully finished')
self.julius_process.kill()

def pkill_julius(self):
p = subprocess.Popen(['pgrep', '-l', 'julius'], stdout=subprocess.PIPE)
out, err = p.communicate()
for line in out.splitlines():
line = line.decode()
pid = int(line.split(None, 1)[0])
os.kill(pid, signal.SIGKILL)

def text_streaming(self):
for line in iter(self.julius_process.stdout.readline, b""):
out_string = line.decode().replace("\n", " ")
print(out_string)
find_text_flag = out_string.find('sentence1:')
find_pass_flag = out_string.find('pass1_best:')
find_short_text_flag = out_string.find('<input rejected by short input>')
if find_text_flag != -1 and find_short_text_flag == -1:
text_string = out_string.replace("sentence1:", "")
text_string = text_string.replace(" ", "")
text_string = text_string.replace("。", "")
if text_string != '。' and len(text_string) > 3:
self.publisher_.publish(String(data=text_string))
print(text_string)
elif find_pass_flag != -1 and find_short_text_flag != -1:
text_string = out_string.replace("pass1_best:", "")
text_string = text_string.replace("<input rejected by short input>", "")
text_string = text_string.replace(" ", "")
text_string = text_string.replace("。", "")
if text_string != '。' and len(text_string) > 3:
self.publisher_.publish(String(data=text_string))
print(text_string)

def main():
rclpy.init()
try:
node = JuliusSpeechToText()
node.text_streaming()
rclpy.spin(node)
except KeyboardInterrupt:
pass
except ExternalShutdownException:
sys.exit(1)
finally:
rclpy.try_shutdown()
node.destroy_node()

if __name__ == '__main__':
main()
23 changes: 23 additions & 0 deletions cube_petit_speech_to_text/setup-julius.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Juliusのセットアップ方法

```
cd setup
source install-julius.sh
```

## Cube-petit(固有名詞)を辞書に追加する

Cuboidくん、cube_petitを認識できるようにするため、
辞書ファイル`csj.pdp.htkdic`に読み方と発音を登録します

```
cd ~/lib/julius_libs/dictation-kit/model/lang_m/

vim bccwj.60k.pdp.htkdic
```

`bccwj.60k.pdp.htkdic`の一番下に2行追加
```
キューボイド [キューボイド] ky_B u:_E b_I o_I i_E d_I o_E
キューブプチ [キューブプチ] ky_B u:_I b_I u_E p_B u_I ch_I i_E
```
32 changes: 32 additions & 0 deletions cube_petit_speech_to_text/setup/install-julius.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#! /bin/sh

# juliusでディクテーションを行うために必要なライブラリのインストールスクリプトです。
# Ubuntuを想定し、checkinstallコマンドを使用してインストールしています。

# セットアップに必要な機能をインストール
sudo apt install -y autotools-dev autoconf software-properties-common
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt update
# git LFSをインストール(dictation-kitの大サイズのファイルをcloneする際に必要)
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
sudo apt-get install git-lfs
git lfs install

# juliusのインストール
# (参考:http://motok5.hatenablog.com/entry/2018/09/22/083226)
now_dir=$PWD
mkdir -p ~/lib/julius_libs
cd ~/lib/julius_libs

# julius本体のダウンロード(検証済み:v4.5)
git clone https://github.com/julius-speech/julius.git
cd julius
./configure
make
sudo checkinstall -y --pkgname='julius' --pkgversion='4.5'

# dictation-kitのダウンロード(検証済み:v4.3.1)
cd ..
git clone https://github.com/julius-speech/dictation-kit.git

cd $now_dir