Thinking about how to tie the strings together, and also in terms of Unity integration...
Why not use a super basic REST server, so we can send all sorts of data over to ARC?
I created a basic example, that is receiving an array of servo positions, that I am sending out from Unity.
These values can be used in ARC to loop thru and create live servo position updates!
Any thoughts on how to improve this are very welcome, all types of data can be send to ARC this way,
you could access a database and store different types of variables...so I guess its being a very versatile way to tie things together?
This is my first attempt to do things this way, so forgive me if the setup is super basic!!
Check if python3 is installed on your system
if not download python
Make sure you are having Flask installed using the packet manager of choice...
pip install Flask
py -m pip install Flask
Now create a file called EZ_ARC_REST.py
and copy the code into the file
Now you can save and run the file...
from flask import Flask, json ,request
positions = [90, 100, 120, 110, 90, 90, 70, 90, 70, 90]
app = Flask(__name__)
positions = position.strip('][').split(', ')
return 'ARC REST Index Page'
return 'Hello, greetings from different endpoint'
#returns the username
return 'Username: %s' % username
#returns the post, the post_id should be an int
if __name__ == '__main__':
There are some extra endpoints so you can get the idea, what can be done with a setup like this!
Test your server by putting some endpoints to your browsers address bar...
http://127.0.0.1:5000/set_positions/[70, 110, 120, 100, 90, 80, 65, 90, 70, 60]
The last line sends a servo array to import into ARC, you can retrieve it like this
Once the array is available, you can use it to drive servo positions, or you can just use this method to get all kinds to data over to ARC...
from System.Net import HttpWebRequest
uri = "http://127.0.0.1:5000/get_positions"
webRequest = HttpWebRequest.Create(uri)
response = webRequest.GetResponse()
from System.IO import StreamReader
streamReader = StreamReader(response.GetResponseStream())
jsonData = streamReader.ReadToEnd()
dataDict = js.DeserializeObject(jsonData)
for position in servo:
Other robots from Synthiam community
Djandco's Djandco's Wall.E
Bhouston's Inmoov's New Gripper
Upgrade to ARC Pro
Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!
Let me know :D. I'd rather see you building and programming your awesome robots than fiddling with this kind of stuff hehe
The Servo-and-Camera-Server is great, the only thing is that its functionality is limited to Camera and Single servo Position streaming, if I remember it correctly? I had some trouble getting multiple servos working for live movement, but that could also have been a pebkam...
The main reason why I proposed this idea was, that it is very versatile on what data type is being transferred.
The server basically takes everything, and is able to spit it out for further processing!
But maybe the Servo-and-Camera-Server could be modified?
I would really like to see this as a starting point, this is not at all meant as a working solution more a POC type of thing!
It allows all 24 of the EZ-Robot EZ-B v4 servos to be controlled in unity.. it also allows Unity to receive the camera video from ARC. I'll add it to my live hack list for you. Is there anything else you'd like this skill to do?
*Edit: i added the servo Camera Server to the live hack list
My robot ZOE is running on LX16A servos, this is another reason why I was choosing this route for my current setup, maybe that was my issue back then?
The current setup works great on BLYNK local server, but since it is 3rd party software, I thought Flask is being a good alternative!
All works great within ARC, but any info on making ARC integration more flawless and help bringing more ARC Users into building some fun stuff in VR would be awesome!!
The way I am doing it at the moment, is to store those arrays into a big chunk of JSON and read them out from ARC, using the same method as above!
I was planning to do a video about it so Will can see how it works, he was also interested in live movement and playback!
But I will wait for your live hack, because I think using the native functionality of the Auto Positioner in ARC might work better than my bloated system!!
A Hello World Example with Arguments (2+2 = 4): to illustrate using input arguments.
Example to Leverage a 3rd Party NLP Library
There are many libraries in the python world. This example shows how to use one of them to get natural language features about some text using the popular Spacy library. This will provide parts of speech, dependences, lemmas, and many other features about every word in the input.
It is up to you to then figure out what you want to do with all this information
Machine Learning Example #1: Object Recognition
This example takes in a filename, loads the image from disk using OpenCV2, and sends it off to a machine learning model (yolo3) in this case. The SendOutput function simply spits out any object as JSON with a time duration attached as well.
There is more code for some of the functions, this is just meant to demonstrate one way to solve the use case at a high level.
Machine Learning Example #2: Natural Language Question Answering
This one answers a natural language question based on a given context. The context could be a corpus of text like an article or wiki page, a conversation history, whatever.
There are many other use cases in areas like SLAM, Mapping, Navigation, Image Processing, Machine Learning, and many more in NLP. Most of everything that has ever been done in robotics exists in some form in python, and to a much lesser extent in other languages. Because I use a lot of windows and C#, this means I sometimes need to call python to leverage this world, passing inputs and processing outputs. Flask is one of many ways to do that.
I will leave one final code example, showing the SendOutput function in the examples above.
Disclaimer: If anyone wants to quarrel about the quality or lack thereof in my python examples, I am sorry, I am new to the space, and have my own style and considerations. I am just trying to encourage thought and innovation and hope this helps others to pursue their own goals.
I was actually using a third party REST server called BLYNK, but now I guess I will be switching...because request.args.get() is awesome, I would have never stumbled upon it by chance, I guess I will have to do a bit of research on FLASK and REST!!
I also had to do some Google searches myself, so anyone wanting to try the query for the first example in the browser...
Posting JSON is a bit finicky, I am using Insomnia for testing querys, since the Postman plugin for Chrome is no longer supported...
You need to set Insomnia to POST and the body to JSON, with the following content!
JSON is always messy to deal with, and slow...but I am also by no ways a coder, so it comes in handy at times!
I would really recommend to use EZ-Robot HDD Servos for your project, since they are very easy to use, but in this project we will be using Serial Bus Servos!
I will make a detailed example soon, but for now you can just send a string to the Super EZ ARC REST Server like this...
http://127.0.0.1:5000/set_positions/[500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]
And see your robot move...
All you need in ARC is this script, and change your COM port to the port your BusLinker board is connected to!!
But of course it is also working with the ARC Servo.setPosition(), as I showed in the facemask tutorial for ARC!!
Its just one line of code to make it work with EZ-Robot HDD servos!
If your robot uses LewanSoul servos. Then all you have to do is add the LewanSoul robot skill and configure the servo ID's to respective Vx ports. Then, your PHP code merely needs to Servo.setPosition(V0, 50); or whatever...
The advantage of using the existing Robot Skills as servo drivers allows your code to seamlessly interact with all other robot skills. When a servo position is modified in ARC, other robot skills can interact with that position change. By talking to the servo directly through your PHP code, you lose that ability for people to merge it with the ARC framework. It loses the ability to be able to work with other robot skills.
So I was also thinking of another REST Server solution...
You're already using the .net System.web.extensions and serializer. So all your program is quite basic. Again, if you're calling this from unity, not sure why you're just not using the camera servo server
I'll have to make a demo for you