Asked

Smooth Start Of The Servo Movements When Starting ARC

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

ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

PRO
Canada
#1  

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:

  1. Open your ARC project and add a new "Script" skill to your project if you don't already have one.

  2. In the script skill, write a script that gradually moves each servo to the desired starting position. You can use the Servo and Sleep commands to create the gradual movement.

# Define your initial positions for each servo
$startingPositionServo1 = 90
$startingPositionServo2 = 90
# ... add more servos as needed

# Define the number of steps and delay between each step
$steps = 10
$delay = 50 # milliseconds

# Gradually move servo 1 to the starting position
$position = Servo.getPosition(D0)
repeat ($i, 0, $steps)
  $position = $position + (($startingPositionServo1 - $position) / ($steps - $i))
  Servo.setPosition(D0, $position)
  Sleep($delay)
endrepeat

# Gradually move servo 2 to the starting position
$position = Servo.getPosition(D1)
repeat ($i, 0, $steps)
  $position = $position + (($startingPositionServo2 - $position) / ($steps - $i))
  Servo.setPosition(D1, $position)
  Sleep($delay)
endrepeat

# ... repeat for additional servos
  1. Save the script and set it to run when the ARC project starts. You can do this by going to the "Project" tab, selecting "Settings," and then adding your script to the "Auto Execute" section.

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.
PRO
Synthiam
#2  

Without knowing the start position it’s impossible to transition from an unknown position. So, no.

PRO
Synthiam
#4  

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.

PRO
Germany
#5   — Edited

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

PRO
Synthiam
#6  

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

PRO
Germany
#7  

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;)

User-inserted image

User-inserted image

Thank you again for your support

PRO
Synthiam
#8   — Edited

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

PRO
Germany
#9  

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.

#10  

@DJ,

Quote:

" It's about ten times faster if the browser is on another computer."
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.

PRO
Synthiam
#11  

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.

  • 3d designer has been removed
  • ezscript removed
  • remote UI has been removed because the entire ARCx is web-based already, so it's redundant

I think that's it. I can't give you a list of new features because the list would be too long.:)

PRO
Germany
#12  

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.

PRO
Synthiam
#13  

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.

PRO
Canada
#14  

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.

PRO
Synthiam
#15   — Edited

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.

User-inserted image

#16  

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:)

PRO
Synthiam
#17  

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:)

#18   — Edited

Quote:

I appreciate EZ-Script is going away
Ya, your going to see a lot of people walking any from ARC or not even trying it once ezscrip is abonded. I know you've wanting to kill it for a while now but my advice {for what it's worth} is that you give the legacy ARC equal platform baced on its ability to use ezscript and help new script writers get into robotics. Why turn your back on them? It's a legitimate computer language. Don't abandon it

PRO
Synthiam
#19   — Edited

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

x = 1;

if (x == 1) {
  print("Hello");
}

EZ-Script

$x = 1

IF ($x = 1) 
  print("Hello");
ENDIF

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

x = 1

if x == 1
  print("Hello")
PRO
Germany
#20  

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

#21  

@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.

PRO
Canada
#22  

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.

PRO
Synthiam
#23   — Edited

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

  • if/elseif/else
  • while/for
  • subroutine/function/method

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

PRO
Canada
#24   — Edited

If I was to write in basic it would be goto or go sub random number.

I just asked same question of chatgpt

// Function to generate a random number between 1 and 5
function generateRandomNumber() {
    return Math.floor(Math.random() * 5) + 1;
}

// Function to print a greeting based on the given number
function printGreeting(number) {
    switch (number) {
        case 1:
            console.log("Hello World");
            break;
        case 2:
            console.log("Bonjour World");
            break;
        case 3:
            console.log("G'day World");
            break;
        case 4:
            console.log("Guten Tag");
            break;
        case 5:
            console.log("Aloha World");
            break;
        default:
            console.log("Invalid number");
    }
}

// Generate a random number
const randomNumber = generateRandomNumber();

// Print the greeting based on the random number
printGreeting(randomNumber);
PRO
Canada
#25  

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:

// Define the greetings as functions
function helloWorld() {
  console.log("Hello World");
}

function bonjourWorld() {
  console.log("Bonjour World");
}

function gdayWorld() {
  console.log("G'day World");
}

function gutenTagWorld() {
  console.log("Guten Tag World");
}

function alohaWorld() {
  console.log("Aloha World");
}

// Create an object that maps numbers to functions
const greetings = {
  1: helloWorld,
  2: bonjourWorld,
  3: gdayWorld,
  4: gutenTagWorld,
  5: alohaWorld
};

// Generate a random number between 1 and 5
function getRandomNumber(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

// Main function to execute the greeting
function executeRandomGreeting() {
  const randomNumber = getRandomNumber(1, 5);
  const greetingFunction = greetings[randomNumber];
  
  if (greetingFunction) {
    greetingFunction(); // Call the corresponding greeting function
  }
}

// Run the program
executeRandomGreeting();

In this program, we define each greeting as a separate function. We then create an object called greetings that maps numbers to these functions. The executeRandomGreeting function generates a random number and uses it to look up and call the corresponding greeting function from the greetings 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.
PRO
Canada
#26  

Basic was such a simple language. My computer only had 1K of RAM so I would have done something like this.

10 gosub int(rnd(5)*100)
20 end
100 print hello world
110 return
200 print gday world
210 return
300 .
PRO
Synthiam
#27   — Edited

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.


while(true) { 

If (x == 1)
  doOne();
else
  doTwo();

}

function doOne(){
 print(one);
}

function doTwo() {
 print(two)
}

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.

PRO
Canada
#28  

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.

PRO
Synthiam
#29  

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

PRO
Canada
#30  

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.

# Correct indentation
if condition:
    # This is a new block of code
    do_something()

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.

x = 10          # An integer assignment
y = "Hello"     # A string assignment

3. If Statements: The if statement is used to test a condition and execute a block of code if the condition is true.

if x < 10:
    print("x is less than 10")
elif x == 10:
    print("x is exactly 10")
else:
    print("x is greater than 10")

4. Loops: Python has two primitive loop commands: for loops and while loops.

  • for loops iterate over a sequence (like a list, tuple, dictionary, set, or string).
# Iterate over a list
for item in [1, 2, 3, 4, 5]:
    print(item)
  • while loops repeat as long as a certain boolean condition is met.
# Continue until x becomes 5
x = 0
while x < 5:
    print(x)
    x += 1

5. Functions: Functions are blocks of reusable code that perform a specific task. You define a function using the def keyword.

# Define a function
def say_hello(name):
    print(f"Hello, {name}!")

# Call the function
say_hello("Alice")

6. Importing Modules: Python has a large standard library, and you can use import to add modules to your script.

import math
print(math.sqrt(16))  # Prints the square root of 16

Remember, Python is case-sensitive, so Variable and variable 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 and except, 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.
#31  

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!

PRO
Synthiam
#32  

Post it in another thread. I wanna see. Wonder if Athena can rewrite it

PRO
Canada
#33   — Edited

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.

if random == 1
 print hello world 
else if random == 2 
 print gday world 
etc.
PRO
Synthiam
#34   — Edited

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.

PRO
Canada
#35  

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 the gosub 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:

// Define functions for each state
function stateOne() {
    console.log("This is State One");
    // Additional code for state one
}

function stateTwo() {
    console.log("This is State Two");
    // Additional code for state two
}

function stateThree() {
    console.log("This is State Three");
    // Additional code for state three
}

// Variable that holds the current state
let currentState = 1;

// Use if statements to determine which function to call
if (currentState === 1) {
    stateOne();
} else if (currentState === 2) {
    stateTwo();
} else if (currentState === 3) {
    stateThree();
}

Alternatively, you can use a switch statement, which can be more readable when you have multiple discrete states:

// Define functions for each state
function stateOne() {
    console.log("This is State One");
    // Additional code for state one
}

function stateTwo() {
    console.log("This is State Two");
    // Additional code for state two
}

function stateThree() {
    console.log("This is State Three");
    // Additional code for state three
}

// Variable that holds the current state
let currentState = 1;

// Use a switch statement to determine which function to call
switch (currentState) {
    case 1:
        stateOne();
        break;
    case 2:
        stateTwo();
        break;
    case 3:
        stateThree();
        break;
    default:
        console.log("Unknown state");
        // Handle unknown state
}

In both examples, you define a function for each state, and then you use either an if statement or a switch statement to call the appropriate function based on the value of currentState. This approach eliminates the need for goto 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.
PRO
Synthiam
#36  

Ya that’s far more readable! And exactly what Dave is asking, I believe.

PRO
Canada
#37  

I think that is pretty close it just didn't capture the random aspect Dave wanted just the line

Let currentState = 1;

would need to say some thing like the following

Let currentState = Math.floor(Math.random() * 5) +1; 

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

const functionName = 'state" + (Math.floor(Math.random() *5) +1);
 functionName(); 

PRO
Synthiam
#38   — Edited

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..

var currentState = Utility.getRandom(0, 5);

switch (currentState) {
    case 1:
  stateOne();
  break;
    case 2:
  stateTwo();
  break;
    case 3:
  stateThree();
  break;
    default:
  console.log("Unknown state");
  // Handle unknown state
}

or even more collapsed. You can remove the variable and switch directly on the return of Utility.getRandom()...

switch (Utility.getRandom(0, 5)) {
case 1:
  stateOne();
  break;
case 2:
  stateTwo();
  break;
case 3:
  stateThree();
  break;
default:
  console.log("Unknown state");
  // Handle unknown state
}
PRO
Canada
#39   — Edited

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).

function stateOne() {
    print("This is State One");
    // Additional code for state one
}

function stateTwo() {
    print("This is State Two");
    // Additional code for state two
}

function stateThree() {
    print("This is State Three");
    // Additional code for state three
}


switch (Utility.getRandom(1,4)) {
case 1:
  stateOne();
  break;
case 2:
  stateTwo();
  break;
case 3:
  stateThree();
  break;
default:
  print("Unknown state");
  // Handle unknown state
}
#40  

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.

PRO
Canada
#41  

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:

# Example  EZ-Script with goto statements
:StateOne
  # Code for State One
  goto(RandomState)

:StateTwo
  # Code for State Two
  goto(RandomState)

:RandomState
  # Random state selection logic
  # ...

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.
#42  

Wow, she's spooky real. I'm looking forward to seeing how she approaches this challenge.

PRO
Germany
#43   — Edited

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.

#44  

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?

PRO
Synthiam
#45  

Yes, programming requires a program like visual studio to make programs.

#46   — Edited

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.

PRO
Synthiam
#47  

You can use any IDE that you want. But Synthiam only supports Visual Studio.

#48  

So then we continue to follow the same skill development instructions going forward?

PRO
Germany
#49  

Is there already a release date for the new ARC or perhaps for a beta version? We're already waiting eagerly for it. love

#51  

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!