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

Enable catkin_virtualenv and google_chat_ros (and others) #1864

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
de7a887
[jsk_unitree_startup/cross] Add python3-venv for catkin virtualenv
iory Jul 25, 2022
f9d4bac
[jsk_unitree_startup/cross] Use sitecustomize.py instead of setting P…
iory Jul 26, 2022
554a87b
[jsk_unitree_startup/cross] Recursively append python site/dist-packa…
iory Jul 26, 2022
f52c4de
[jsk_unitree_startup/cross] Add google_chat_ros
iory Jul 26, 2022
dd38754
[jsk_unitree_startup/cross] Use bug-fix version of catkin-virtualenv
iory Jul 26, 2022
c0b2cc8
[jsk_unitree_startup/cross] Install python3 dependencies for catkin_v…
iory Jul 26, 2022
5337838
[jsk_unitree_startup/cross] Add JSK_UNITREE_COMPILE_PARALLEL option t…
iory Jul 26, 2022
785af9e
[jsk_unitree_startup/cross] Install sitecustomize.py for real unitree…
iory Jul 26, 2022
1e045b1
[jsk_unitree_startup] Fixed install.sh command description. -d is cor…
iory Jul 26, 2022
bba78e2
[jsk_unitree_startup] Use perl instead of 'grep -Po'
iory Jul 26, 2022
b1c13cd
[jsk_unitree_startup/cross] Install LTE settings only TARGET_DIRECTOR…
iory Jul 26, 2022
f55266b
[jsk_unitree_startup/cross] Use sshpass instead of /usr/bin/sshpass
iory Jul 26, 2022
1c21dd2
[jsk_unitree_startup/cross] Use bug-fix branch for enabling aarch64 (…
iory Jul 26, 2022
c60b7d9
[jsk_unitree_startup/cross] Set default value 4 to JSK_UNITREE_COMPIL…
iory Jul 26, 2022
ce8e63a
Revert "[jsk_unitree_startup/cross] Add JSK_UNITREE_COMPILE_PARALLEL …
iory Jul 27, 2022
5cf2dec
Revert "[jsk_unitree_startup/cross] Set default value 4 to JSK_UNITRE…
iory Jul 27, 2022
6023c36
[jsk_unitree_startup/cross] Passthrough MAKEFLAGS
iory Jul 27, 2022
b9bbd11
[jsk_unitree_startup/cross] Add comments for unitree.repos
iory Jul 27, 2022
e753fba
[jsk_unitree_startup/cross] Passthrough python libraries on run_user.sh
iory Jul 28, 2022
ff338cf
[unitree/cross] Add prerequisite command to readme
tkmtnt7000 Jul 28, 2022
33cf239
[jsk_unitree_startup/cross] Modified google_chat_ros branch
iory Jul 29, 2022
3e1247f
[jsk_unitree_startup/cross] Add comment for reachability
iory Jul 29, 2022
d6c223f
Revert "[jsk_unitree_startup/cross] Add python3-venv for catkin virtu…
iory Jul 29, 2022
4b5dd18
[jsk_unitree_startup/cross] Enable virtualenv via pip install
iory Jul 29, 2022
706a5b2
[jsk_unitree_startup/cross] Use unitree branch at catkin_virtualenv
iory Jul 29, 2022
e578bb8
[jsk_unitree_startup/cross] Install sysctl.conf to passthrough packet
iory Jul 30, 2022
82acc9f
[jsk_unitree_startup/cross] Install iptables.ipv4.nat to passthrough …
iory Jul 30, 2022
1a67515
[jsk_unitree_startup/cross] Add OPTIONS to passthrough user id for ma…
iory Aug 3, 2022
91961fd
[jsk_unitree_startup/cross] Enable iory's google chat ros (minor change)
iory Aug 3, 2022
f7e6089
[jsk_unitree_startup/cross] Add compress command
iory Aug 3, 2022
d1c49ac
[jsk_unitree_startup] Add emotion reaction
a-ichikura Aug 4, 2022
0231f70
[jsk_unitree_startup/cross] Add y or n
iory Aug 4, 2022
f8e3778
[jsk_unitree_startup] Add imageai.sh which is running on default unit…
iory Aug 5, 2022
8d9eb4a
[jsk_unitree_startup] Launch trt pose on jetson nano2gb (192.168.123.13)
iory Aug 5, 2022
2b7943c
[jsk_unitree_startup] Add camera image publisher
iory Aug 5, 2022
c9f5b1a
[jsk_unitree_startup] Add walk_notifyer
iory Aug 7, 2022
d3d98cc
[jsk_unitree_startup/cross] Add env.sh for machine tag
iory Aug 7, 2022
e84bafd
[jsk_unitree_startup] Add walk_notifier application
iory Aug 7, 2022
11964cf
[jsk_unitree_startup] Add wlan2 settings for sparky
iory Aug 7, 2022
5813abd
[jsk_unitree_startup/cross] Install mailutils
iory Aug 7, 2022
8758d43
[jsk_unitree_startup] Enable wlan0
iory Aug 7, 2022
6e47211
[jsk_unitree_startup/install] passthrough password
iory Aug 7, 2022
6cf0090
[jsk_unitree_startup/install] Modified owner of /var/mail/${USER}
iory Aug 7, 2022
ac6b6cc
Merge branch 'unitree-virtualenv' into unitree-miraikan
iory Aug 7, 2022
c2cb48c
[jsk_unitree_startup/WalkNotifier] Enable attachment
iory Aug 7, 2022
95fdfa5
[jsk_unitree_startup] Update version of mailutils
iory Aug 7, 2022
15260f7
[jsk_unitree_startup/cross] Disable python for mailutils
iory Aug 7, 2022
fca125f
[jsk_unitree_startup/install.sh] Use sudo for touch /var/mail/unitree
iory Aug 8, 2022
d541c81
[jsk_unitree_startup] Add Walk notifier's README
iory Aug 8, 2022
722b3fb
[jsk_unitree_startup/cross] Add y or n
iory Aug 4, 2022
749f486
[jsk_perception_3rdparty] Passthrough password
iory Aug 8, 2022
e1c68e5
[jsk_unitree_startup] Fixed start_app's rosservice names
iory Aug 8, 2022
262cd73
Merge branch 'unitree-miraikan' into unitree-virtualenv
iory Aug 26, 2022
14022cd
Revert "[jsk_unitree_startup] Update version of mailutils"
iory Aug 27, 2022
69874b1
Revert "[jsk_unitree_startup/cross] Disable python for mailutils"
iory Aug 27, 2022
f13a43d
enable to send mail
tkmtnt7000 Jul 26, 2022
2fe8f21
add more typecheck, use rospy.loginfo for message
k-okada Jul 27, 2022
d4f0597
use https://github.com/tkmtnt7000/jsk_robot/pull/5 to publish image s…
k-okada Jul 27, 2022
cc1777f
enable to receive multiple smach state
k-okada Aug 9, 2022
0dd909e
add to pubilsh /tweet message
k-okada Aug 9, 2022
0bfbf79
[jsk_robot_startup] Fix dependent on linter
tkmtnt7000 Jul 28, 2022
7d1958e
[jsk_robot_startup] Support python3 in smach_to_mail.py
tkmtnt7000 Jul 28, 2022
a935e96
[jsk_robot_startup/smach_mail] Fix typo
tkmtnt7000 Aug 9, 2022
f3933dd
[jsk_robot_startup/smach_mail] Remove unused module
tkmtnt7000 Aug 9, 2022
3d41642
[jsk_robot_startup/smach_to_mail] Set sender address and receiver add…
tkmtnt7000 Aug 9, 2022
2542efd
[jsk_robot_startup/smach_to_mail] Raise error when no address is set
tkmtnt7000 Aug 22, 2022
1075757
[jsk_robot_startup/smach_to_mail] Use yaml file to set address
tkmtnt7000 Aug 22, 2022
54a3d1a
[jsk_robot_startup] Publish whole /tweet at a time
iory Aug 22, 2022
7a4f018
[jsk_robot_startup] Add Readme for smach_to_mail.py
tkmtnt7000 Aug 23, 2022
cfdfc6e
Revert "[jsk_unitree_startup] Launch trt pose on jetson nano2gb (192.…
iory Aug 29, 2022
eb02f63
Revert "[jsk_unitree_startup] Add imageai.sh which is running on defa…
iory Aug 29, 2022
20cd79e
[jsk_unitree_startup] Copy data to jetson nano 2gb (192.168.123.13)
iory Aug 29, 2022
70cc9f9
[jsk_unitree_startup] Publish image via mqtt
iory Aug 29, 2022
096165e
[jsk_robot_startup] Add EmailBody msg
tkmtnt7000 May 24, 2022
8763099
[jsk_robot_startup] Support changing embed image size and change msg …
tkmtnt7000 May 25, 2022
56f41d7
add img_data to EmailBody, update email_topic.py and email-topic-clie…
k-okada Jul 27, 2022
61209bc
add node to publish smach_state of lead_teleop program
k-okada Jun 29, 2022
c3b18f9
[jsk_unitree_startup/human_pose_publisher.py] Add timestamp for peopl…
iory Aug 29, 2022
e6ab483
[jsk_unitree_startup/llead-teleop-state.l] Check detected person
iory Aug 29, 2022
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
1 change: 1 addition & 0 deletions jsk_robot_common/jsk_robot_startup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ add_message_files(
FILES
RoomLight.msg
Email.msg
EmailBody.msg
)

generate_messages(
Expand Down
53 changes: 53 additions & 0 deletions jsk_robot_common/jsk_robot_startup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,59 @@ rostopic pub /reboot std_msgs/Empty
```


## scripts/smach_to_mail.py

This node sends smach messages to `/email`, `/tweet`, etc... to notify robot state transition.

```mermaid
flowchart TB
subgraph S[Demo Code Running on SMACH]
START --> State_1
State_1 --> State_2
State_2 --> END
end
subgraph E[SMACH To Notification]
id1[(state list<br>DESCRIPTION / IMAGE<br>DESCRIPTION / IMAGE<br>...)]
id1 --> email[[pub /email jsk_robot_startup::Email]]
id1 --> tweet[[pub /tweet std_msgs::String]]
id1 --> chat[[pub /google_chat_ros/send/goal<br>google_chat_ros::SendMessageAction]]
end
S -->|"[{'DESCRIPTION': string, 'IMAGE': base64}]"| E
email --> email_body(["DESCRIPTION[0]<br>DESCRIPTION[1]<br>IMAGE[1]<br>DESCRIPTION[1]<br>IMAGE[1]<br>..."])
tweet --> tweet_body1(["DESCRIPTION[0]"])
tweet_body1 --> tweet_body2(["DESCRIPTION[1]<br>IMAGE[1]"])
tweet_body2 --> tweet_body3(["DESCRIPTION[2]<br>IMAGE[2]"])
chat --> chat_body1(["DESCRIPTION[0]"])
chat_body1 --> chat_body2(["DESCRIPTION[1]<br>IMAGE[1]"])
chat_body2 --> chat_body3(["DESCRIPTION[2]<br>IMAGE[2]"])
```

### Subscribing Topics

* `~smach/container_status` (`smach_msgs/SmachContainerStatus`)

Input topic smach status

### Publishing Topics

* `/email` (`jsk_robot_startup/Email`)

Email message with description and image

* `/tweet` (`std_msgs/String`)

Tweet message with description and image

### Parameters

* `~sender_address` (String)

Sender address

* `~receiver_address` (String)

Receiver address

## launch/safe_teleop.launch

This launch file provides a set of nodes for safe teleoperation common to mobile robots. Robot-specific nodes such as `/joy`, `/teleop` or `/cable_warning` must be included in the teleop launch file for each robot, such as [safe_teleop.xml for PR2](https://github.com/jsk-ros-pkg/jsk_robot/blob/master/jsk_pr2_robot/jsk_pr2_startup/jsk_pr2_move_base/safe_teleop.xml) or [safe_teleop.xml for fetch](https://github.com/jsk-ros-pkg/jsk_robot/blob/master/jsk_fetch_robot/jsk_fetch_startup/launch/fetch_teleop.xml).
Expand Down
20 changes: 19 additions & 1 deletion jsk_robot_common/jsk_robot_startup/euslisp/email-topic-client.l
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ros::load-ros-manifest "jsk_robot_startup")

(require :base64 "lib/llib/base64.l")

(defun init-mail ()
(ros::advertise "email" jsk_robot_startup::Email 1)
(ros::spin-once)
Expand All @@ -16,7 +18,23 @@
(setq msg (instance jsk_robot_startup::Email :init))
(send msg :header :stamp (ros::time-now))
(send msg :subject subject)
(send msg :body body)
(send msg :body
(mapcar #'(lambda (e)
(cond ((derivedp e image-2d)
(if (> (length (send e :entity)) (* 8 8192))
(warning-message 3 "The size of img is too large (~A)~%You may encounter 'too long string' error, see https://github.com/euslisp/EusLisp/issues/2 for more info~%" (length (send e :entity))))
(instance jsk_robot_startup::EmailBody :init :type "img"
:img_data (base64encode (send e :entity))
:img_size 100))
((probe-file e)
(instance jsk_robot_startup::EmailBody :init :type "img" :file_path e :img_size 100))
((and (> (length e) 0) ;; check html
(eq (elt e 0) #\<)
(eq (elt e (1- (length e))) #\>))
(instance jsk_robot_startup::EmailBody :init :type "html" :message e))
(t
(instance jsk_robot_startup::EmailBody :init :type "text" :message (format nil "~A" e)))))
(if (atom body) (list body) body)))
(send msg :sender_address sender-address)
(send msg :receiver_address receiver-address)
(send msg :smtp_server smtp-server)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,36 @@
(ros::spin-once)
(setq receiver-address (ros::get-param "~receiver_address"))
(setq attached-files (ros::get-param "~attached_files" nil))
(unix::sleep 10) ;; wait for server
(while (or (null (ros::get-num-subscribers "email"))
(<= (ros::get-num-subscribers "email") 0))
(ros::ros-warn "wait for email topic")
(unix::sleep 1))

(ros::ros-info "Sending a mail to ~A" receiver-address)
(send-mail "test-mail" receiver-address "test" :attached-files attached-files)
(ros::ros-info "Sent a mail")
(send-mail "test text mail" receiver-address "test")
(ros::ros-info "Sent a text mail")
(unix:sleep 1)

(send-mail "test html mail" receiver-address "<h1>test with html mail</h1>")
(ros::ros-info "Sent a html mail")
(unix:sleep 1)

(send-mail "test attached mail" receiver-address "test with attached image" :attached-files attached-files)
(ros::ros-info "Sent a mail with attached files ~A" attached-files)
(unix:sleep 1)

(when attached-files
(send-mail "test image embedded mail (file)" receiver-address (append attached-files (list "test with embedded image")))
(ros::ros-info "sent a mail with embedded image ~a" attached-files)
(unix:sleep 1)
;; read png/jpeg file, but do not extract to raw image, keep original compressed data in (img . entity)
(setq img (read-image-file (elt attached-files 0)))
(setq (img . entity) (make-string (elt (unix:stat (elt attached-files 0)) 7))) ;; size of file
(with-open-file (f (elt attached-files 0)) (unix:uread (send f :infd) (img . entity)))
(send-mail "test image embedded mail (string)" receiver-address (list "test with embedded image" img))
(ros::ros-info "Sent a mail with embedded image ~A" img)
(unix:sleep 1)
)

(ros::roseus "shutdown")
(exit)
2 changes: 1 addition & 1 deletion jsk_robot_common/jsk_robot_startup/msg/Email.msg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
std_msgs/Header header
string subject # Email subject
string body # Email body
jsk_robot_startup/EmailBody[] body # Email body
string sender_address # Sender's email address
string receiver_address # receiver's email address
string smtp_server # smtp server address
Expand Down
5 changes: 5 additions & 0 deletions jsk_robot_common/jsk_robot_startup/msg/EmailBody.msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
string type # text, html, img
string message # For text and html type
string file_path # For img type, set file path
string img_data # For img type, you can also use base64 encoded image data instead of file path
uint8 img_size # For img type [percent]
44 changes: 42 additions & 2 deletions jsk_robot_common/jsk_robot_startup/scripts/email_topic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

from email.mime.application import MIMEApplication
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import errno
Expand All @@ -12,6 +13,9 @@
import socket
from socket import error as socket_error
import yaml
import copy
import random, string # for image cid
import base64


class EmailTopic(object):
Expand Down Expand Up @@ -43,7 +47,11 @@ def __init__(self):
'email', Email, self._cb, queue_size=1)

def _cb(self, msg):
rospy.loginfo('Received an msg: {}'.format(msg))
msg_compact = copy.deepcopy(msg)
for content in msg_compact.body:
if len(content.img_data) >= 64:
content.img_data = content.img_data[:64] + "...."
rospy.loginfo('Received an msg: {}'.format(msg_compact))
send_mail_args = {}
# Set default value for self._send_mail arguments
send_mail_args['subject'] = ''
Expand Down Expand Up @@ -75,7 +83,39 @@ def _send_mail(
msg["Subject"] = subject
msg["From"] = sender_address
msg["To"] = receiver_address
msg.attach(MIMEText(body, 'plain', 'utf-8'))
# Support embed image
for content in body:
if content.type == 'text':
msg.attach(MIMEText(content.message, 'plain', 'utf-8'))
elif content.type == 'html':
msg.attach(MIMEText(content.message, 'html'))
elif content.type == 'img':
if content.img_data != '':
embed_img = MIMEImage(base64.b64decode(content.img_data))
cid = ''.join(random.choice(string.ascii_lowercase) for i in range(16))
elif os.path.exists(content.file_path):
with open(content.file_path, 'rb') as img:
embed_img = MIMEImage(img.read())
cid = content.file_path
else:
rospy.logerr("'img' content requries either file_path {}".format(content.type))
rospy.logerr(" or img_data {} with img_format {}".format(content.img_data, content.img_format))
continue
embed_img.add_header(
'Content-ID', '<{}>'.format(cid))
embed_img.add_header(
'Content-Disposition', 'inline; filename="{}"'.format(os.path.basename(cid)))
msg.attach(embed_img) # This line is necessary to embed
if content.img_size:
image_size = content.img_size
else:
image_size = 100
text = '<img src="cid:{}" width={}%>'.format(cid, image_size)
bodytext = MIMEText(text, 'html')
msg.attach(bodytext)
else:
rospy.logwarn('Unknown content type {}'.format(content.type))
continue
# Attach file
for attached_file in attached_files:
if attached_file == '':
Expand Down
Loading