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

[rostwitter] Support extracting base64 images and tweet them from text. #375

Closed
wants to merge 21 commits into from

Conversation

iory
Copy link
Member

@iory iory commented Aug 17, 2022

What is this?

This is the another version of #371
This PR is developed on #373

smach to twitter uses cv2.imencode, so we need to do cv2.imdecode.
https://github.com/jsk-ros-pkg/jsk_robot/blob/a87dbc1a8808d0d0aed9d06a5245e7cab2fe1e87/jsk_robot_common/jsk_robot_startup/scripts/smach_to_mail.py#L92

Also, since text may contain multiple base64-encoded images or filepaths, they are extracted and modified to be tweeted in succession like following tweet. https://twitter.com/pr2jsk/status/1559813371653894144

Quick Example

launch tweet.launch https://gist.github.com/iory/d70e2ee3c0749cdde593996dd98de22b
Download sample image

wget https://user-images.githubusercontent.com/4690682/185071882-5d9c6bea-5d9b-4d18-9197-f7294d232131.jpg -O /tmp/pr2.jpg

After that, run tweet_sample.py
https://gist.github.com/iory/3a1f02d0ffecbcb40b1212fd5d850025
for fetch kitchen demo
https://twitter.com/fetch_jsk/status/1561730190098587650

@iory iory requested a review from k-okada August 17, 2022 08:16
@knorth55 knorth55 mentioned this pull request Aug 18, 2022
14 tasks
Copy link
Member

@k-okada k-okada left a comment

Choose a reason for hiding this comment

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

same comments as #373 (comment), please create real exampe, for exampe kitchen demo -> k-okada/jsk_robot#60 (comment), Or unitree k-okada/jsk_robot#60 (comment) (3). (note that we'll create unitree twitter account once we confirmed this is useful, so pleaset test on fetch account for debugging)

Please requeset reveiw, after CI passed

@tkmtnt7000
Copy link
Member

@k-okada
Copy link
Member

k-okada commented Aug 22, 2022

@tkmtnt7000 nice, please create PR of kitchen-demo with this description.

@iory
Copy link
Member Author

iory commented Aug 22, 2022

@tkmtnt7000 Thanks.
We confirmed that tweet with images is achieved by this PR.
We can check the result of the kitchen demo.
https://twitter.com/fetch_jsk/status/1561730190098587650

@tkmtnt7000
Copy link
Member

tkmtnt7000 commented Aug 23, 2022

Thank you. I send PR to jsk-ros-pkg/jsk_robot jsk-ros-pkg/jsk_robot#1568.

@tkmtnt7000 nice, please create PR of kitchen-demo with this description.

@k-okada
Copy link
Member

k-okada commented Aug 23, 2022

ok, please add README.md, I would like to know, specially, how to display in thread.
ec08a8f says Changed so that strings longer than 140 characters are displayed as a thread, but https://github.com/jsk-ros-pkg/jsk_robot/pull/1568/files#diff-dff77088a03af5caa4778675f4b8ef1da673abcf0f28c82ea7bef87abff73c5cR163-R165 publishes every description.

@tkmtnt7000
Copy link
Member

ec08a8f says Changed so that strings longer than 140 characters are displayed as a thread, but jsk-ros-pkg/jsk_robot#1568 (files) publishes every description.

Sorry, I forgot pushing update of using thread.

@tkmtnt7000
Copy link
Member

86a12a0 and 6d5811e

@k-okada
Copy link
Member

k-okada commented Aug 23, 2022

Sorry, I forgot pushing update of using thread.

will this work if smach does not send image? @tkmtnt7000

@iory
Copy link
Member Author

iory commented Aug 23, 2022

@k-okada
I added README.md.
https://github.com/jsk-ros-pkg/jsk_3rdparty/blob/09d1a3cbee95282f2a8d2ae8fdb7ec5f337e67d4/rostwitter/README.md

You can tweet text only, image only, and text with images.

@k-okada
Copy link
Member

k-okada commented Aug 24, 2022

will this work if smach does not send image? @tkmtnt7000

what will happen if sned

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]

???

[DESCRIPTION]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]

not

[DESCRIPTION]
↓
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]
↓
[IMAGE]
[DESCRIPTION]

@iory
Copy link
Member Author

iory commented Aug 24, 2022

what will happen if sned

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]
[IMAGE]
[DESCRIPTION]

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
↓
[DESCRIPTION]
[IMAGE]
↓
[DESCRIPTION]

The image will serve as a tweet delimiter.

Another example.

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE]
[DESCRIPTION (over 140 characters)]
[DESCRIPTION]
[IMAGE]

[DESCRIPTION]
[DESCRIPTION]
[IMAGE]
[IMAGE]
[IMAGE]
[IMAGE] (Up to four images per tweet)
↓
[IMAGE]
↓
[DESCRIPTION (1)] (Split into 140 full-width characters and 280 half-width characters.)
↓
[DESCRIPTION (2)]
[DESCRIPTION]
[IMAGE]

@k-okada
Copy link
Member

k-okada commented Sep 22, 2022

failing on , dialogflow_task_executive/noetic, please compete #362 @mqcmd196

2022-09-22T03:29:07.4011432Z [dialogflow_task_executive:make] �[31mCould not find a version that matches protobuf<4.0.0dev,<5.0.0dev,>=3.15.0,>=3.20.1,>=4.21.3 (from google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4019669Z 
2022-09-22T03:29:07.4019677Z 
2022-09-22T03:29:07.4019861Z                                                                                 
2022-09-22T03:29:07.4020591Z [dialogflow_task_executive:make] Tried: 2.0.3, 2.3.0, 2.4.1, 2.5.0, 2.6.0, 2.6.1, 3.0.0, 3.0.0, 3.1.0, 3.1.0.post1, 3.1.0.post1, 3.2.0, 3.2.0, 3.3.0, 3.4.0, 3.4.0, 3.5.0.post1, 3.5.0.post1, 3.5.1, 3.5.1, 3.5.2, 3.5.2, 3.5.2.post1, 3.5.2.post1, 3.6.0, 3.6.0, 3.6.1, 3.6.1, 3.7.0, 3.7.0, 3.7.1, 3.7.1, 3.8.0, 3.8.0, 3.9.0, 3.9.0, 3.9.1, 3.9.1, 3.9.2, 3.9.2, 3.10.0, 3.10.0, 3.11.0, 3.11.0, 3.11.1, 3.11.1, 3.11.2, 3.11.2, 3.11.2, 3.11.3, 3.11.3, 3.11.3, 3.12.0, 3.12.1, 3.12.2, 3.12.2, 3.12.2, 3.12.4, 3.12.4, 3.12.4, 3.13.0, 3.13.0, 3.13.0, 3.14.0, 3.14.0, 3.14.0, 3.15.0, 3.15.0, 3.15.0, 3.15.1, 3.15.1, 3.15.1, 3.15.2, 3.15.2, 3.15.2, 3.15.3, 3.15.3, 3.15.3, 3.15.4, 3.15.4, 3.15.4, 3.15.5, 3.15.5, 3.15.5, 3.15.6, 3.15.6, 3.15.6, 3.15.7, 3.15.7, 3.15.7, 3.15.8, 3.15.8, 3.15.8, 3.16.0, 3.16.0, 3.16.0, 3.17.0, 3.17.0, 3.17.0, 3.17.1, 3.17.1, 3.17.1, 3.17.2, 3.17.2, 3.17.2, 3.17.3, 3.17.3, 3.17.3, 3.18.0, 3.18.0, 3.18.0, 3.18.1, 3.18.1, 3.18.1, 3.18.3, 3.18.3, 3.18.3, 3.19.0, 3.19.0, 3.19.0, 3.19.1, 3.19.1, 3.19.1, 3.19.2, 3.19.2, 3.19.2, 3.19.3, 3.19.3, 3.19.3, 3.19.4, 3.19.4, 3.19.4, 3.19.5, 3.19.5, 3.19.5, 3.20.0, 3.20.0, 3.20.0, 3.20.1, 3.20.1, 3.20.1, 3.20.2, 3.20.2, 3.20.2, 4.21.0, 4.21.0, 4.21.0, 4.21.0, 4.21.1, 4.21.1, 4.21.1, 4.21.1, 4.21.2, 4.21.2, 4.21.2, 4.21.2, 4.21.3, 4.21.3, 4.21.3, 4.21.3, 4.21.4, 4.21.4, 4.21.4, 4.21.4, 4.21.5, 4.21.5, 4.21.5, 4.21.5, 4.21.6, 4.21.6, 4.21.6, 4.21.6
2022-09-22T03:29:07.4025328Z 
2022-09-22T03:29:07.4025334Z 
2022-09-22T03:29:07.4025601Z                                                                                 
2022-09-22T03:29:07.4027592Z [dialogflow_task_executive:make] Skipped pre-versions: 2.0.0b0, 3.0.0a2, 3.0.0a3, 3.0.0b1, 3.0.0b1.post1, 3.0.0b1.post2, 3.0.0b2, 3.0.0b2, 3.0.0b2.post1, 3.0.0b2.post1, 3.0.0b2.post2, 3.0.0b2.post2, 3.0.0b3, 3.0.0b4, 3.0.0b4, 3.2.0rc1, 3.2.0rc1, 3.2.0rc1.post1, 3.2.0rc1.post1, 3.2.0rc2, 3.2.0rc2, 3.7.0rc2, 3.7.0rc2, 3.7.0rc3, 3.7.0rc3, 3.8.0rc1, 3.8.0rc1, 3.9.0rc1, 3.9.0rc1, 3.10.0rc1, 3.10.0rc1, 3.11.0rc1, 3.11.0rc1, 3.11.0rc2, 3.11.0rc2, 3.12.0rc1, 3.12.0rc2, 3.13.0rc3, 3.13.0rc3, 3.13.0rc3, 3.14.0rc1, 3.14.0rc1, 3.14.0rc1, 3.14.0rc2, 3.14.0rc2, 3.14.0rc2, 3.14.0rc3, 3.14.0rc3, 3.14.0rc3, 3.15.0rc1, 3.15.0rc1, 3.15.0rc1, 3.15.0rc2, 3.15.0rc2, 3.15.0rc2, 3.16.0rc1, 3.16.0rc1, 3.16.0rc1, 3.16.0rc2, 3.16.0rc2, 3.16.0rc2, 3.17.0rc1, 3.17.0rc1, 3.17.0rc1, 3.17.0rc2, 3.17.0rc2, 3.17.0rc2, 3.18.0rc1, 3.18.0rc1, 3.18.0rc1, 3.18.0rc2, 3.18.0rc2, 3.18.0rc2, 3.19.0rc1, 3.19.0rc1, 3.19.0rc1, 3.19.0rc2, 3.19.0rc2, 3.19.0rc2, 3.20.0rc1, 3.20.0rc1, 3.20.0rc1, 3.20.0rc2, 3.20.0rc2, 3.20.0rc2, 3.20.1rc1, 3.20.1rc1, 3.20.1rc1, 4.0.0rc1, 4.0.0rc1, 4.0.0rc1, 4.0.0rc2, 4.0.0rc2, 4.0.0rc2, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc1, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2, 4.21.0rc2
2022-09-22T03:29:07.4029447Z 
2022-09-22T03:29:07.4029615Z 
2022-09-22T03:29:07.4030027Z                                                                                 
2022-09-22T03:29:07.4031339Z [dialogflow_task_executive:make] There are incompatible versions in the resolved dependencies:
2022-09-22T03:29:07.4036895Z 
2022-09-22T03:29:07.4036901Z 
2022-09-22T03:29:07.4037174Z                                                                                 
2022-09-22T03:29:07.4037770Z [dialogflow_task_executive:make]   protobuf<4.0.0dev,>=3.20.1 (from google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4042402Z 
2022-09-22T03:29:07.4042408Z 
2022-09-22T03:29:07.4045033Z                                                                                 
2022-09-22T03:29:07.4045709Z [dialogflow_task_executive:make]   protobuf<5.0.0dev,>=3.15.0 (from googleapis-common-protos==1.56.4->google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))
2022-09-22T03:29:07.4046396Z 
2022-09-22T03:29:07.4046548Z 
2022-09-22T03:29:07.4046652Z                                                                                 
2022-09-22T03:29:07.4047335Z [dialogflow_task_executive:make]   protobuf>=4.21.3 (from grpcio-status==1.49.1->google-api-core[grpc]==1.33.1->dialogflow==1.1.1->-r requirements.in (line 1))�[0m

@mqcmd196 mqcmd196 force-pushed the twitter-with-base64-images branch from 6d998c7 to 8e0d3a7 Compare October 23, 2022 03:19
@mqcmd196
Copy link
Member

Sorry, I overlooked the comment. I completed #362

media_ids = []
for media in media_list:
data = {'media': media}
r = self._request_url(url, 'POST', data=data)
Copy link
Member

Choose a reason for hiding this comment

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

in order to post numpy array data, we need to upgrade requests python module to 2.19.0 and above.
psf/requests@8546a15

@knorth55
Copy link
Member

I make a PR to improve this PR.
please check it. iory#9

@k-okada k-okada added question dependencies Pull requests that update a dependency file and removed dependencies Pull requests that update a dependency file PleaseFixCI labels Feb 23, 2023
@k-okada
Copy link
Member

k-okada commented Feb 23, 2023

@iory please cosnider merging iory#9

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.

6 participants