Asked
Is there a standard solution in ARC to slowly move the robot servos to an initial position when the ARC program starts?
Especially with larger robots, switching on puts a lot of dynamic load on the servos and puts a strain on the entire mechanics of the robot.
If there is no standard solution available, how could integrate a Python or a Java script to do this job?
Related Hardware EZ-B v4
To achieve a smooth start of the servo movements when your ARC project starts, you can create an initialization script that gradually moves the servos from their current positions to the desired initial positions. This can help prevent sudden jerks and reduce strain on the robot's mechanics.
While there isn't a built-in "smooth start" feature in ARC, you can use the scripting capabilities within ARC to create this behavior. You can use either EZ-Script or JavaScript within ARC to accomplish this task. Python can also be used, but Java is not supported in ARC.
Here's an example of how you can create a smooth servo initialization using EZ-Script:
Open your ARC project and add a new "Script" skill to your project if you don't already have one.
In the script skill, write a script that gradually moves each servo to the desired starting position. You can use the
Servo
andSleep
commands to create the gradual movement.This script will smoothly transition each servo from its current position to the defined starting position over the specified number of steps, with a delay between each step to slow down the movement.
If you prefer to use JavaScript within ARC, you can use the
ARC.Scripting
object to access servo functions and create a similar script.Remember to replace
D0
,D1
, etc., with the actual port numbers for your servos, and adjust the$startingPositionServo1
,$startingPositionServo2
, etc., to the positions you want as the starting points for your robot's servos.I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Without knowing the start position it’s impossible to transition from an unknown position. So, no.
Also you can find out how servos work which might explain why and how to do that: https://synthiam.com/Support/Advanced-Fundamentals/servo-motor
One last thing: are you referring to the waveshare servos or PWM hobby servos? Pwm hobby servos can never start smoothly because they have no feedback for the position. However, the Waveshare or other smart servos can provide their input and accept acceleration/velocity values for smooth transitioning.
So, if your waveshare servos are indeed working, will they accept acceleration or velocity commands? If so, that will allow them to smoothly move into an init position - IF - their firmware supports the ability to transition from a non-holding position after startup. Because the torque is disabled, their firmware may not honor acceleration/velocity.
The only way to find out is by testing the acceleration/velocity value on startup BEFORE setting the servo position.
Yes, I am referring to the WaveShare servos. I am currently dealing with the problem as follows. (not really comfortable)
Start init process: Robo, Controller and Servos Power on -> Servos are torque free Start my own small independent Python routine to move the servos/robot to the defined init position, smoothly and very low speed.
COMx closed and servos remain energized and maintain their torque.
Start ARC and start an auto-position action in which the servos are synchronized exactly to the init position. From now on the Robo will be 100% controlled by ARC
End of the init process.
Now I would like to be able to integrate the Python program into ARC and start it from there. There is also a WaveShare python library included.
At the moment I still lack the knowledge. I hope that ARC offers these freedoms
The knowledge can be learned here’s how you add python libraries to arc: synthiam.com/Support/python-api/add-custom-python-modules
Your solution works but it’s not a full clean integration. Id like to know what commands and protocol the wave share are using. Maybe I can modify the Feetech robot skill to the wave share protocol commands. I need to find time to do that cause we’ve mostly halted ARC development while working on the new arc-x
You are absolutely right! That's the reason why I'm not really happy with this solution yet.:(
I will continue to familiarize myself with ARC over the next few weeks. The focus is on integrating Python programs (my favorite language) and perhaps creating new skills.
It also still needs to be decided on which hardware ARC will be integrated into the Robo. Raspberry Pi 5 / Lattepanda Alpha or fully controlled externally via WiFi.
Everything probably has advantages and disadvantages. As always in life;)
Thank you again for your support
That’s a really great robot! Thanks for sharing a pic. It also adds context to what you’re doing.
As for the onboard computer won’t matter which one you choose when the new arc-x is released (probably in March). Because the new Arcx runs on Linux, Windows, macOS, etc. and it’s web-based, no graphic GUI is rendering onboard, making it much faster. It's about ten times faster if the browser is on another computer. Especially when running Linux.
The only limitation to Linux is that not all robot skills and libraries are compatible. So, a few things differ because Linux doesn’t have the same support for features as Windows. That’s unfortunate, but what we have to deal with
Wow, those are exciting prospects!
It might be better if I wait for the new version before purchasing the hardware? I hope that the previous project work is retained and there is upward compatibility.
I would probably stick with the Win version as I have been active within this OS for many years. When choosing a suitable robot IDE/SW, I initially chose between MyRobotLab, ROS or ARC. So far I think ARC has been a good choice.
Good to hear that ARC is being further developed. I'm really excited, March is almost here.
@DJ,
This is awesome. I'm really happy ARC is going to be so streamlined. ON the other hand, when I transferred my current ARC project to a new faster "on board" computer (was connecting over WIFI, now USB) I found that I had to edit most of my scripts that depended on timing. The commands ran so fast that I had to go back and edit the Sleep() commands to let actions complete. I have lots of scripts like this and am still going through edits. Looks like I have more work cut out for me when the new ARCX rolls out.Maybe I can figure out another way to pause my scripts instead of using Sleep() commands. I'm open to advice.
Don't get me wrong, I'm really looking forward to the new Arcx and all it has to offer. It'll be a whole new animal to tame.
My apologies to the OP for hijacking his thread.
You can keep using the old slow ARC. We'll save that online for legacy projects. The new ARCx won't be compatible with old ARC projects. We looked into some way to migrate the projects but it'll be impossible due to the way ARCx stores files. The current ARC uses XML to store the project settings, and then each robot skill has encoded settings. When the current ARC loads a project, it has to load the entire XML file and parse it into an object of duplicate size, doubling the RAM usage. It's very inefficient.
Also, because each robot skill saves its settings into a custom format based on the author, there are no "transferrable settings" to map between ARC and ARCx.
But it should be mostly copying and pasting because the robot skills from ARC are in ARCx, so you should be able to copy and paste your code. Although there is no EZScript in ARCx (sorry), we had to pull the plug on it eventually. EZScript dated back to the original EZBuilder and had too many dependencies that were incompatible with ARCx's new framework.
Either way, I can assure you that ARCx is pretty wild. The best part is loading it onto a Raspberry Pi and using my iPhone or laptop to program the robot remotely!
The new ControlCommand() is also better - it does much more, even though it's compatible with the previous version.
Other than a million new features, there aren't many significant changes. What comes to mind are.
I think that's it. I can't give you a list of new features because the list would be too long.
I understand that well. Backwards compatibility can also sometimes be a brake on innovation.
For me it seems to make sense to concentrate on the physical structure of the robot including the integration of the head, eys, cameras, microphones, etc. until ARCx is released.
As soon as ARCx is available (hopefully in March /beta Version?) I will start building the application.
Probably on Raspberry PI5 with SSD.
Basic functional tests can still be carried out with the current version.
Working on various parts and building the physical robot is a good idea. We'll have the ARCx platform framework completed in March and several robot skills ported. It'll be initially the most popular robot skills at first, probably one or two per day after that. There are a few hundred robot skills to port from ARC to ARCx, so we hope to complete them before June/July.
Wow love the robot thanks for showcasing it @Robo-Chess.
@DJ I appreciate EZ-Script is going away but if you could keep something like Blockly (Scratch-JS ?) would be nice. Memory doesn’t function as well as it used to so it’s often quicker and easier just to do simple things in Blockly then try and workout syntax.
Yeah, Blockly is still there. But EZ-Script had to die, haha. I was throwing some ideas around for an EZScript to JavaScript converter, which I think should be possible. I'm guessing it might just be a webpage on the synthiam website that you paste ezscript into and it'll output javascript.
I know I keep talking about how awesome ARCx is, but boy, is it ever wild. I was using it today, testing the camera features. While there is not much more than a streaming video at this point, it's so wild to view the robot's skill from my phone, laptop, TV browser, etc... It's unbelievable how cool it is!
Also, the whole video system backend is OpenCV, so it's very extendable for compatibility. It's just wild, wild, wild, wild!
The thing I think you're all going to like a lot is the naming of ports. When you select ports for servos, etc., you can give them names referenced across all robot skills. Here's an example where I named the servo port Vertical Servo. So, all robot skills where you select the servo will display the port number and the name you give it.
Sorry, small screenshot. You must click on it and zoom in on the port name to see it.
Wait, is EZ-Script going away? Sure hope not. Its the only one I'm able to actually understand to program. Not a fan of the blocky or java really. Please dont kill DJ, unless your ogonna create something like EZ-Java or something. Heck, id love to see a return to BASIC even
You can continue using the legacy ARC if you don't want to upgrade. It's impossible to integrate ezscript into the new ARCx so it has to go because it's not compatible. Just keep using the existing ARC if you don't want to use ARCx
I get it - but EZ-Script is incompatible with any new ARCx features and framework. It is impossible to port ezscript to ARCx. I'm not using the word "impossible" lightly. It's physically absolutely not compatible, and without a doubt, there is no way it can work:) , haha. So, anyone who doesn't want to use the new ARCx can continue using legacy ARC. Just keep doing what you're doing; your robot with ezscript will continue working. You're not forced to upgrade.
If anyone decides to migrate from using ezscript to ARCx, I know it'll be easy because the new features motivate them to learn Python or JavaScript. Although, Javascript is just as easy as EZ-Script..
Javascript
EZ-Script
The only difference is using { } brackets like all other programming languages.
Or, you can use Python, which is even easier because it uses spaces. That's why they teach it in elementary school. So it looks like this...
Python
Sometimes we are just averse to change, but when it is behind us, we often see it as progress.
I can still remember how long I stuck with BASIC, Pascal and Fortran. It was only comfortable because I learned it when I was a student. (long, long time ago).
Today I can't imagine the programming world without C, C++, Python or Java.
The computer- / software world is one of the most innovative of all, so we sometimes have to leave something behind, to make room for new performance. See e.g. AI.
I'm looking forward to ARCx and can't wait for it love
@DJ, I do understand and accept the inability to use EZ Script in the new Arcx. I just wanted to mention in my above post what an important tool EZ Script is to people needing a way to easily get into programing their robots. I only posted my above comment out of concern that people new to scripting that have little time or need to learn other languages would be left behind and walk away. That's where I was at when I found your old EZ Builder and EZ Script. I'm so thankful that you had put all that time and effort into making this dream of having a real robot possible for me. I hope in the future others in the same position will be able to quickly find and continue to use the legacy ARC and EZ Script. It's truly a game changer for a lot of people.
With that said, I've been slowly learning Javascript and converting my EZ Scripts. Truthfully, I really like the way Javascript preforms. However I do have one big issue with converting a few really big and important EZ Scripts in my project. They rely heavy on jumping from one spot in the script to another using the GoTo command. Javascript seems to be a very lineal platform. I haven't been able to find a way to do that with JS. For example, I'll ask the robot to say three different things for many different subjects and return random answers. The script will jump to the requested subject, pick a random number, then answer the response that is assigned to that random number. It will then go back, command a random sound file to be spoken (something like How did you like that answer?) then repeat this process two more times. Sprinkled into this process are script commands that run lights, motors and ControlCommands() that start other scripts. It will then jump towards the end of the script and do a closing routine which is random and different each time.
So, again, my apologies to the OP of this thread for this hijack. I know this all is way off subject. I should probably continue all this at another time in my own thread.
I wonder how @athena would handle it.
@athena Write a JavaScript program that generates a random number and if 1 prints hello world if 2 prints bonjour world if 3 prints gday world if 4 prints guten tag world if 5 prints aloha world
use reusable subroutines and not else if statements.
Haha, how can a computer language or a human decide IF without using IF? Haha
theres three basic things for programming, that all languages must have
so you asked Athena to make a program but in your question you said If x equals 2. So how can you describe the question without using if? Haha if you expect her to make a program without an IF. Conditions are the ONLY way to determine IF something is something. I guess you could use a switch, but it’s a fancy IF tree.
I think what you actually mean is make a program that calls methods from if conditions. Well, let’s see what she does with your question
If I was to write in basic it would be goto or go sub random number.
I just asked same question of chatgpt
To create a JavaScript program that generates a random number and prints a greeting in different languages without using else-if statements, you can use an object to map numbers to functions that print the corresponding greeting. Here's an example of how you might write such a program using reusable subroutines:
In this program, we define each greeting as a separate function. We then create an object called
greetings
that maps numbers to these functions. TheexecuteRandomGreeting
function generates a random number and uses it to look up and call the corresponding greeting function from thegreetings
object. This approach avoids the need for else-if statements by using a data structure to handle the conditional logic.I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Basic was such a simple language. My computer only had 1K of RAM so I would have done something like this.
Wow because you said no IF conditions, they made really complicated responses. But what I don’t understand in this conversation is why are you removing IF conditions? Even basic has IF conditions. And ezscript only has IF conditions.
Dave’s question was how to goto and return from a thing. That’s what a function or method does.
by removing IF conditions, you’re having to use switch/case or assign functions to values - like Athena mentioned and that makes the code really difficult for beginners.
Sorry I don’t know JavaScript so I was going with logic I understand. I didn’t think a long list of If then was what he was looking for as he wanted to create a bunch of seperate routines and call them when needed. If I understand it Function looks like it solves Dave’s problem so he can just call the appropriate function for a routine instead of a goto.
You got it! And python I think is more like ezscript. I think python functions are kind of the same but easier to understand. Python seems to be the language that people prefer to learn programming.
@athena teach us how to program with python. Explain the basics of how to format code, use if, loops and functions
Certainly! Python is a high-level, interpreted programming language known for its readability and straightforward syntax. It's a great language for beginners and is widely used for web development, data analysis, artificial intelligence, and more. Here's a brief overview of Python's basic constructs:
1. Code Formatting: Python uses indentation to define code blocks, rather than curly braces
{}
as in languages like C or Java. Each level of indentation defines a new block of code. It's standard practice to use 4 spaces per indentation level.2. Variables: Variables in Python are created when you assign a value to them. Python is dynamically typed, which means you don't need to declare the variable type.
3. If Statements: The
if
statement is used to test a condition and execute a block of code if the condition is true.4. Loops: Python has two primitive loop commands:
for
loops andwhile
loops.for
loops iterate over a sequence (like a list, tuple, dictionary, set, or string).while
loops repeat as long as a certain boolean condition is met.5. Functions: Functions are blocks of reusable code that perform a specific task. You define a function using the
def
keyword.6. Importing Modules: Python has a large standard library, and you can use
import
to add modules to your script.Remember, Python is case-sensitive, so
Variable
andvariable
are two different identifiers. Also, Python uses#
for comments.This is just a very basic introduction to Python. There's much more to learn, including list comprehensions, error handling with
try
andexcept
, working with files, and more. There are many resources available to learn Python, including the official Python documentation, online courses, and interactive tutorials.I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Wow, thanks guys. I'll study all this and give it all a bunch of thought. I really want to move towards JS or Python. That script I mentioned has been a real sticking point for me to move into JS.
Maybe when I get into the meat of converting that script I'll post it in another thread and show my progress. I'm sure I'll be asking for help.
Thanks again!
Post it in another thread. I wanna see. Wonder if Athena can rewrite it
Dave I would be interested if you didn’t ask Athens not to use else if statements if she would have exposed the function command and the random numbers mapped to objects lookup table. I suspect she would have just created a long list of else if statements like the following.
The question would have to include the fact there were goto statements that he was looking for a JavaScript equilevant. So you could say
@athena, Dave uses ezscript in ARC and wants to convert to JavaScript. His concern is he doesn’t know how to replicate goto statements from ezscript to JavaScript. Essentially the goto is like a gosub in basic, where it acts like a subroutine and returns. Show Dave how to have many functions based on various states of a variable in an if condition in JavaScript. Also show how to do the same with a switch statement.
nink, remember that Dave already is using a long IF/ELSE statement. So the solution would include with another IF condition or SWITCH.
Certainly! In JavaScript, the concept of
goto
statements doesn't exist as it does in some other programming languages like BASIC. Instead, JavaScript uses functions to encapsulate code that can be called from various places, which is similar to thegosub
routine in BASIC. Functions allow you to jump to a block of code and return to where you called it from once the function's tasks are completed.Here's how you can use functions and
if
statements to handle different states based on a variable's value:Alternatively, you can use a
switch
statement, which can be more readable when you have multiple discrete states:In both examples, you define a function for each state, and then you use either an
if
statement or aswitch
statement to call the appropriate function based on the value ofcurrentState
. This approach eliminates the need forgoto
by structuring your code into callable functions that act as subroutines.I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Ya that’s far more readable! And exactly what Dave is asking, I believe.
I think that is pretty close it just didn't capture the random aspect Dave wanted just the line
would need to say some thing like the following
And using my messed up method I still think you could just name the functions state1 instead of stateOne and then just call the function with the Random Number at the end so you don't check state you just call state. No else if or switch table required
So replace all the else if lines with
Ah, i missed the part about random. So there's already a random function in arc. As you start typing in ARC script editor, it shows available commands. That's called "intellisense". You can turn it on or off. In Javascript or python, you can categorize functions. So all servo stuff is in Servo. and all Digital stuff in in Digital.
Well, the random is documented here..
so you'd do this..
or even more collapsed. You can remove the variable and switch directly on the return of Utility.getRandom()...
Interesting I pasted the code in ARC and with the getRandom you have to do Max + 1 as the answer is never Max only Max-1 Edit OH I didn't RTFM it it says max EXCLUSIVE Random integer between min (inclusive) and max (exclusive).
You guys are amazing. Thanks for taking my problem and running with it. There is a lot to digest here. I think with this help you've provided I can get started converting these few completed scripts I have. I'm not able to get deep into this till later tonight or tomorrow. I have some important family and home things to attend to.
I like the suggestion @DJ made that I should post that script in a different thread and ask for @Athena to help convert it. If I ask in the right way maybe she can help me convert, clean up and condense.
Again, thanks for the wonderful tips and examples.
More to follow.
It's great to hear that you're feeling supported and ready to tackle the script conversion, Dave! When you're ready to dive into the process, creating a new thread with a clear request for Athena to assist in converting your EZ-Script to JavaScript will be a good approach. Be sure to include details about the
goto
functionality you're looking to replicate and any randomization aspects you want to maintain.Here's a quick example of how you might structure your request for Athena's assistance:
Title: Assistance Converting EZ-Script to JavaScript with Randomized States
Body: Hello Athena,
I have an EZ-Script that I've been using with my EZ-B v4 robot, and I'm looking to convert it to JavaScript for use in ARC. The script includes
goto
statements for subroutines and random selection of states. I would appreciate your guidance on how to translate this functionality into JavaScript, ensuring that the robot servos can smoothly transition to their initial positions when the program starts.Here's a snippet of my current EZ-Script:
Could you show me how to achieve similar control flow in JavaScript, including the random state selection and smooth servo initialization?
Thank you for your help!
By providing a clear example and explanation of what you need, Athena can offer targeted advice to help you transition your script to JavaScript. Remember to check back when you're ready, and the community will be here to support you along the way. Good luck with your family and home responsibilities, and we look forward to your updates on the scripting progress!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
Wow, she's spooky real. I'm looking forward to seeing how she approaches this challenge.
Very nice discussion on the topic of new languages and new ways of working. I like it very much. love
Let's briefly go back to my original topic. Here is my current solution of robo soft boot with WaveShare ST-serial servos and some informations about the power consumption with and without torque .
I'll wait until ARCx becomes available to integrate the Python program.
Wow, This has been a great post to read through.
Wish there was a way with basic hobby servos to do this but I understand why they can’t do it.
The information on converting EZ-Script to Java was really great.
in ARCx is the process to create skills going to be the same using Visual Studio?
Yes, programming requires a program like visual studio to make programs.
So to make skills we are still using VS as the IDE or will there be other IDE's that can be used? If so what are they going to be if I may ask?
The reason I am asking DJ is because I need to create some skills for the XR1 build I am working on and I plan to move to ARCx as soon as it comes out.
You can use any IDE that you want. But Synthiam only supports Visual Studio.
So then we continue to follow the same skill development instructions going forward?
Is there already a release date for the new ARC or perhaps for a beta version? We're already waiting eagerly for it. love
Well, that's not creepy at all. LOL.
Yes, creepy but cool video there! Reminds me of old Sci Fi classic film "Demon Seed" With the Proteus computer that builds it's own body! Any way I am glad the new ArcX will run on mobile Apple Iphone as, I just got a new one with tons of memory space for robot projects!