diff --git a/.gitmodules b/.gitmodules index e24492940..fccaa0ed0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule ".travis"] path = .travis - url = git://github.com/jsk-ros-pkg/jsk_travis + url = https://github.com/jsk-ros-pkg/jsk_travis diff --git a/.travis b/.travis index 5e0ae4e34..4e8b3cf26 160000 --- a/.travis +++ b/.travis @@ -1 +1 @@ -Subproject commit 5e0ae4e342f736d06b0bdaebb239bf6a260598bf +Subproject commit 4e8b3cf2637d593d05106e84edf2e4532677d37c diff --git a/chaplus_ros/package.xml b/chaplus_ros/package.xml index 23eb63681..642265a5e 100644 --- a/chaplus_ros/package.xml +++ b/chaplus_ros/package.xml @@ -1,5 +1,5 @@ - + chaplus_ros 2.1.24 The ROS package for chaplus service @@ -12,8 +12,8 @@ catkin - rospy - python-requests + python-requests + python3-requests rospy diff --git a/gdrive_ros/CMakeLists.txt b/gdrive_ros/CMakeLists.txt index cd4dc12fa..f4214cc51 100644 --- a/gdrive_ros/CMakeLists.txt +++ b/gdrive_ros/CMakeLists.txt @@ -2,10 +2,13 @@ cmake_minimum_required(VERSION 2.8.3) project(gdrive_ros) find_package(catkin REQUIRED COMPONENTS + rospy std_msgs message_generation ) +catkin_python_setup() + add_service_files( FILES Upload.srv @@ -22,12 +25,20 @@ catkin_package( message_runtime ) -install(DIRECTORY node_scripts - DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +catkin_install_python(PROGRAMS node_scripts/gdrive_server_node.py node_scripts/sample_gdrive_rospy_client.py + DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) + +install(DIRECTORY launch + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS ) -install(DIRECTORY launch +install(DIRECTORY sample + DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} + USE_SOURCE_PERMISSIONS +) + +install(DIRECTORY euslisp DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} USE_SOURCE_PERMISSIONS ) diff --git a/gdrive_ros/euslisp/gdrive-ros-utils.l b/gdrive_ros/euslisp/gdrive-ros-utils.l new file mode 100644 index 000000000..59cc2cb93 --- /dev/null +++ b/gdrive_ros/euslisp/gdrive-ros-utils.l @@ -0,0 +1,55 @@ +(ros::load-ros-manifest "gdrive_ros") + +(defun wait-for-gdrive-server (&rest args) + (if args + (ros::wait-for-service "/gdrive_server/upload" args) + (ros::wait-for-service "/gdrive_server/upload") + ) + ) + +(defun upload-file (file-path + file-title + &key + (parents-path nil) + (parents-id nil) + (use-timestamp-folder nil) + (use-timestamp-file-title nil)) + (let ((req (instance gdrive_ros::UploadRequest :init)) + (res nil)) + (send req :file_path file-path) + (send req :file_title file-title) + (send req :parents_path parents-path) + (send req :parents_id parents-id) + (send req :use_timestamp_folder use-timestamp-folder) + (send req :use_timestamp_file_title use-timestamp-file-title) + (setq res (ros::service-call "/gdrive_server/upload" req t)) + (list (send res :success) + (send res :file_id) + (send res :file_url) + (send res :parents_id) + (send res :parents_url)) + )) + +(defun upload-multiple-files + (file-paths + file-titles + &key + (parents-path nil) + (parents-id nil) + (use-timestamp-folder nil) + (use-timestamp-file-title nil)) + (let ((req (instance gdrive_ros::MultipleUploadRequest :init)) + (res nil)) + (send req :file_paths file-paths) + (send req :file_titles file-titles) + (send req :parents_path parents-path) + (send req :parents_id parents-id) + (send req :use_timestamp_folder use-timestamp-folder) + (send req :use_timestamp_file_title use-timestamp-file-title) + (setq res (ros::service-call "/gdrive_server/upload_multi" req t)) + (list (send res :successes) + (send res :file_ids) + (send res :file_urls) + (send res :parents_id) + (send res :parents_url)) + )) diff --git a/gdrive_ros/euslisp/sample-gdrive-roseus-client.l b/gdrive_ros/euslisp/sample-gdrive-roseus-client.l new file mode 100755 index 000000000..4d4e4b89a --- /dev/null +++ b/gdrive_ros/euslisp/sample-gdrive-roseus-client.l @@ -0,0 +1,23 @@ +#!/usr/bin/env roseus + +(require "package://gdrive_ros/euslisp/gdrive-ros-utils.l") + +(ros::roseus "sample_gdrive_roseus_client") + +(wait-for-gdrive-server) +(ros::ros-info "Gdrive server ready.") + +(setq file-name (ros::get-param "~file_name")) +(setq file-title (ros::get-param "~file_title")) +(setq parents-path (ros::get-param "~parents_path")) + +(ros::ros-info "Uploading files...") +(setq res (upload-file file-name file-title :parents-path parents-path)) +(ros::ros-info "Response: ~A" res) + +(ros::ros-info "Uploading multiple files...") +(setq res (upload-multiple-files (list file-name) (list file-title) :parents-path parents-path)) +(ros::ros-info "Response: ~A" res) + +(ros::roseus "shutdown") +(exit) diff --git a/gdrive_ros/node_scripts/sample_gdrive_rospy_client.py b/gdrive_ros/node_scripts/sample_gdrive_rospy_client.py new file mode 100755 index 000000000..4a35dce2c --- /dev/null +++ b/gdrive_ros/node_scripts/sample_gdrive_rospy_client.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python + +import rospy +from gdrive_ros.gdrive_ros_client import GDriveROSClient + + +def main(): + + rospy.init_node('sample_gdrive_rospy_client') + + file_name = rospy.get_param('~file_name') + file_title = rospy.get_param('~file_title') + parents_path = rospy.get_param('~parents_path') + + client = GDriveROSClient() + + client.wait_for_gdrive_server() + + rospy.loginfo('Uploading files...') + ret = client.upload_file(file_name, file_title, parents_path=parents_path) + rospy.loginfo('Result: {}'.format(ret)) + + rospy.loginfo('Uploading files...') + ret = client.upload_multiple_files([file_name], [file_title], parents_path=parents_path) + rospy.loginfo('Result: {}'.format(ret)) + + rospy.loginfo('Successfully finished.') + + +if __name__=='__main__': + main() diff --git a/gdrive_ros/package.xml b/gdrive_ros/package.xml index 378890869..cdc0316f0 100644 --- a/gdrive_ros/package.xml +++ b/gdrive_ros/package.xml @@ -13,8 +13,10 @@ https://github.com/jsk-ros-pkg/jsk_3rdparty/issues catkin + rospy message_generation std_msgs + rospy message_runtime pydrive-pip diff --git a/gdrive_ros/sample/sample_roseus_client.launch b/gdrive_ros/sample/sample_roseus_client.launch new file mode 100644 index 000000000..a583ebf2c --- /dev/null +++ b/gdrive_ros/sample/sample_roseus_client.launch @@ -0,0 +1,16 @@ + + + + + + + + + + file_name: $(arg file_name) + file_title: $(arg file_title) + parents_path: $(arg parents_path) + + + diff --git a/gdrive_ros/sample/sample_rospy_client.launch b/gdrive_ros/sample/sample_rospy_client.launch new file mode 100644 index 000000000..e799ab898 --- /dev/null +++ b/gdrive_ros/sample/sample_rospy_client.launch @@ -0,0 +1,16 @@ + + + + + + + + + + file_name: $(arg file_name) + file_title: $(arg file_title) + parents_path: $(arg parents_path) + + + diff --git a/gdrive_ros/setup.py b/gdrive_ros/setup.py new file mode 100644 index 000000000..a365fe1b0 --- /dev/null +++ b/gdrive_ros/setup.py @@ -0,0 +1,9 @@ +from distutils.core import setup +from catkin_pkg.python_setup import generate_distutils_setup + +d = generate_distutils_setup( + packages=['gdrive_ros'], + package_dir={'': 'src'} +) + +setup(**d) diff --git a/gdrive_ros/src/gdrive_ros/__init__.py b/gdrive_ros/src/gdrive_ros/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/gdrive_ros/src/gdrive_ros/gdrive_ros_client.py b/gdrive_ros/src/gdrive_ros/gdrive_ros_client.py new file mode 100644 index 000000000..6b8123fa8 --- /dev/null +++ b/gdrive_ros/src/gdrive_ros/gdrive_ros_client.py @@ -0,0 +1,82 @@ +import rospy +from gdrive_ros.srv import MultipleUpload +from gdrive_ros.srv import MultipleUploadRequest +from gdrive_ros.srv import Upload +from gdrive_ros.srv import UploadRequest + + +class GDriveROSClient: + + def __init__(self): + + self.srv_upload = rospy.ServiceProxy( + '/gdrive_server/upload', + Upload + ) + self.srv_upload_multi = rospy.ServiceProxy( + '/gdrive_server/upload_multi', + MultipleUpload + ) + + def wait_for_gdrive_server(self,timeout=None): + if timeout is None: + rospy.wait_for_service('/gdrive_server/upload') + rospy.wait_for_service('/gdrive_server/upload_multi') + + try: + rospy.wait_for_service('/gdrive_server/upload', timeout=timeout) + rospy.wait_for_service('/gdrive_server/upload_multi', timeout=timeout) + return True + except rospy.ROSException as e: + rospy.logerr('Error: {}'.format(e)) + return False + + def upload_file(self, + file_path, + file_title, + parents_path='', + parents_id='', + use_timestamp_folder=False, + use_timestamp_file_title=False + ): + # + req = UploadRequest() + req.file_path = file_path + req.file_title = file_title + req.parents_path = parents_path + req.parents_id = parents_id + req.use_timestamp_folder = use_timestamp_folder + req.use_timestamp_file_title = use_timestamp_file_title + # + res = self.srv_upload(req) + # + return (res.success, + res.file_id, + res.file_url, + res.parents_id, + res.parents_url) + + def upload_multiple_files(self, + file_paths, + file_titles, + parents_path='', + parents_id='', + use_timestamp_folder=False, + use_timestamp_file_title=False + ): + # + req = MultipleUploadRequest() + req.file_paths = file_paths + req.file_titles = file_titles + req.parents_path = parents_path + req.parents_id = parents_id + req.use_timestamp_folder = use_timestamp_folder + req.use_timestamp_file_title = use_timestamp_file_title + # + res = self.srv_upload_multi(req) + # + return (res.successes, + res.file_ids, + res.file_urls, + res.parents_id, + res.parents_url) diff --git a/respeaker_ros/scripts/respeaker_gencfg.py b/respeaker_ros/scripts/respeaker_gencfg.py index 099499589..63f6548fa 100755 --- a/respeaker_ros/scripts/respeaker_gencfg.py +++ b/respeaker_ros/scripts/respeaker_gencfg.py @@ -4,12 +4,13 @@ import os import sys -from respeaker_node import PARAMETERS, init_respeaker +from respeaker_node import PARAMETERS, RespeakerInterface def main(out): - dev = init_respeaker() - if not dev: + try: + dev = RespeakerInterface() + except RuntimeError as e: print('No device found. Please connect a device.') return with open(out, "w") as f: diff --git a/switchbot_ros/README.md b/switchbot_ros/README.md index 982cffec2..11a212fd5 100644 --- a/switchbot_ros/README.md +++ b/switchbot_ros/README.md @@ -15,7 +15,9 @@ JSK members can edit the original file [here](https://docs.google.com/presentati Especially, please set your device name and enable cloud service. 3. Get your token -On switchbot App, profile -> settings, and press `version` for 10 times and you can get token. For JSK members, we already have shared one [here](https://drive.google.com/file/d/1YZ4P4aaPemB_umB9S0xDG66BJt59-2lz/view?usp=sharing). +On switchbot App, profile -> settings, and press `version` for 10 times and you can get token. + +For JSK members, please see [this slide](https://docs.google.com/presentation/d/11UkuxVT4u_LcAYJQnPvt4mzxos9Qvflth5hgZmtqmyk/edit?usp=sharing) for account and token details and installed switchbots for our lab. ### Using switchbot ros Execute `roslaunch switchbot_ros switchbot.launch token:=YOUR_TOKEN` and publish ActionGoal. diff --git a/switchbot_ros/package.xml b/switchbot_ros/package.xml index c6e5576da..a17cd96b4 100644 --- a/switchbot_ros/package.xml +++ b/switchbot_ros/package.xml @@ -15,7 +15,7 @@ python-requests python3-requests - message_exectime + message_runtime rospy std_msgs diff --git a/switchbot_ros/scripts/switchbot_ros_server.py b/switchbot_ros/scripts/switchbot_ros_server.py index c1d495fe8..7366b7ff2 100755 --- a/switchbot_ros/scripts/switchbot_ros_server.py +++ b/switchbot_ros/scripts/switchbot_ros_server.py @@ -27,7 +27,10 @@ def __init__(self): try: self.bots = SwitchBotAPIClient(token=self.token) device_list_str = 'Switchbot device list:\n' - for device in self.bots.device_list: + device_list = sorted( + self.bots.device_list, + key=lambda device: str(device['deviceName'])) + for device in device_list: device_list_str += 'Name: ' + str(device['deviceName']) device_list_str += ', Type: ' + str(device['deviceType']) device_list_str += '\n'