Skip to content

Commit

Permalink
Merge branch 'master' into fetch15
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 authored Apr 4, 2022
2 parents 44e3abd + 7d289ff commit 5e80b4f
Show file tree
Hide file tree
Showing 17 changed files with 265 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .travis
6 changes: 3 additions & 3 deletions chaplus_ros/package.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
<package format="2">
<package format="3">
<name>chaplus_ros</name>
<version>2.1.24</version>
<description>The ROS package for chaplus service</description>
Expand All @@ -12,8 +12,8 @@

<buildtool_depend>catkin</buildtool_depend>

<exec_depend>rospy</exec_depend>
<exec_depend>python-requests</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-requests</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 3">python3-requests</exec_depend>
<exec_depend>rospy</exec_depend>

<export>
Expand Down
17 changes: 14 additions & 3 deletions gdrive_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
Expand Down
55 changes: 55 additions & 0 deletions gdrive_ros/euslisp/gdrive-ros-utils.l
Original file line number Diff line number Diff line change
@@ -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))
))
23 changes: 23 additions & 0 deletions gdrive_ros/euslisp/sample-gdrive-roseus-client.l
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions gdrive_ros/node_scripts/sample_gdrive_rospy_client.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 2 additions & 0 deletions gdrive_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
<url type="bugtracker">https://github.com/jsk-ros-pkg/jsk_3rdparty/issues</url>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>std_msgs</build_depend>
<run_depend>rospy</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>pydrive-pip</run_depend>

Expand Down
16 changes: 16 additions & 0 deletions gdrive_ros/sample/sample_roseus_client.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<launch>
<arg name="file_name" />
<arg name="file_title" />
<arg name="parents_path" default="/example_folder" />

<include file="$(find gdrive_ros)/launch/gdrive_server.launch" />

<node name="sample_gdrive_roseus_client" pkg="gdrive_ros" type="sample-gdrive-roseus-client.l"
output="screen" required="true">
<rosparam subst_value="true">
file_name: $(arg file_name)
file_title: $(arg file_title)
parents_path: $(arg parents_path)
</rosparam>
</node>
</launch>
16 changes: 16 additions & 0 deletions gdrive_ros/sample/sample_rospy_client.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<launch>
<arg name="file_name" />
<arg name="file_title" />
<arg name="parents_path" default="/example_folder" />

<include file="$(find gdrive_ros)/launch/gdrive_server.launch" />

<node name="sample_gdrive_rospy_client" pkg="gdrive_ros" type="sample_gdrive_rospy_client.py"
output="screen" required="true">
<rosparam subst_value="true">
file_name: $(arg file_name)
file_title: $(arg file_title)
parents_path: $(arg parents_path)
</rosparam>
</node>
</launch>
9 changes: 9 additions & 0 deletions gdrive_ros/setup.py
Original file line number Diff line number Diff line change
@@ -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)
Empty file.
82 changes: 82 additions & 0 deletions gdrive_ros/src/gdrive_ros/gdrive_ros_client.py
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 additions & 3 deletions respeaker_ros/scripts/respeaker_gencfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion switchbot_ros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion switchbot_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<exec_depend condition="$ROS_PYTHON_VERSION == 2">python-requests</exec_depend>
<exec_depend condition="$ROS_PYTHON_VERSION == 3">python3-requests</exec_depend>
<exec_depend>message_exectime</exec_depend>
<exec_depend>message_runtime</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>

Expand Down
5 changes: 4 additions & 1 deletion switchbot_ros/scripts/switchbot_ros_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5e80b4f

Please sign in to comment.