Connecting the chat controlled robot to Twitch Pt2

I figured out how to use Websockets and Cors to get Spare Parts to respond to clicking buttons on a Twitch overlay! There was still plenty of things to do but this felt like a huge achievement for Spare Parts’ channel.

This was streamed on Twitch on Jan 6, 2021.

Special thanks to Greg Needel of REV Robotics, @Esden for the robotics care packages and @tigga1986 for the pan&tilt camera bracket design!

00:00:00 Stream Starts
Hey everyone! Happy Tuesday!
Welcome to all the viewers, regular and new, what’s going on?
Scotty shows his new “mug”. a 1000ml graduated cylinder mug ( similar to https://www.amazon.com/dp/B07RT6H3R3/ref=cm_sw_em_r_mt_dp_bOy9FbEZ26YC1 ) as he broke his old one and the small 400ml wasn’t available, he now rocks

00:01:08 Show & Tell; Mail call
Scotty shows chat parts from china!
He has 3 bottom flex connectors for the iPhone 12 so the USB-C project can move ahead later.
Scotty looks at the to check if they’re originals or not.
They appear to be used. He isn’t clear on how used parts for such a new device are available but reports things move fast.
The old one is still MIA, Scotty is convinced it must have been thrown away.
Scotty shares he has heard that phones are being specifically sourced new and dismantled and torn apart for parts. He is certain this is is because the sum of the parts is currently cheaper than buying the parts or making them individually.
He’s fairly certain that glue traces on the cables give away that he’s not dealing with factory discards.
Scotty moves on and shows some glue he got for the project and factory discarded iPhoneX logic boards.
He then shows off his new 3D Screwdrivers using the microscope, these are purpose built with slightly different tips that are flat so provide a better mating surface to the screws
Scotty also teases a “secret project” that he’s not ready to discuss but will go to YouTube soon!

00:15:34 Explanation and Preparation of today’s stream
As Esden ( https://www.twitch.tv/esden ) raids with 34 Raiders, Scotty starts to explain the purpose of today’s stream and recap on status of the robot so far.
“Secret Project” is teased again, this time showing a nondescript brown cardboard box or “china packing”.
The robot comes online and Scotty connects to it.
Scotty kills the processes that run on the robot
He then resumes the processes except for mic and camera as he wants to run them separately.
the robot comes online on daspareparts ( https://www.twitch.tv/daspareparts )
Scotty runs chat through Quart, a Flask like python ASGI web microframework ( https://pypi.org/project/Quart/ )
Scotty then takes chat through how websockets work and what the Quart documentation suggests for using

00:35:46 Working on websockets!
So, what do we need to do?
Putting his explanation into practice, Scotty gets the newfangled Python 3 async io figured out and cleans up the iterative process he worked through on the day prior.
He switches how the robot has been running, substituting the remo control code for the twitch version.
He changes the server for the robot to connect to and comments out the authentication lines (for now)
After a quick json import , python controller is started and…

00:48:31 It works!
Scotty now goes back to the overlay view in Twitch Developer Rig
“in theory when I push this button the robot should move backwards”
Spoiler: It doesn’t.
The buttons call OPTIONS but not GET – now we get into “stupid cors stuff” ( https://pypi.org/project/Quart-CORS/ )
Scotty imports cors from quart_cors and performs more code hygiene.
We have a thing!

01:12:50 Laying out next steps
Scotty talks a little about latency worries and intentions on making the overlay bigger.
He’s been tuning ffmpeg to the point where the image quality is compressed to the point of pixelation.
This in the goal to lower the latency as much as possible.
There’s some idea’s exchanged about how to gain access or control to the robot using channel points, nothing set in stone yet!
Scotty outlines some next steps about deployment of the extension, client authentication and wanting to block random commands to stop web requests.
TTS must be re-enabled!
He eventually starts a todo list for; Make Buttons Bigger, client and robot authentication, cloud deployment and getting the extension on twitch.
There will be anti-spam.

01:24:23 Winding down
We got a thing working, thank you for joining us and Scotty is super excited about SpareParts having it’s own twitch stream!

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>