Asked
How To Create Multidimensional Arrays
Could you please show me how to create an array with 20 names, each associated with three values (x, y, z)? Additionally, I would like to generate a chart on the desktop that displays these names and their corresponding values.
Furthermore, I need to extract the values for a specific name and use them to control servo movements.
This assistance would be greatly appreciated.
Thank you, Don
This is a good place to start: https://www.w3schools.com/js/js_arrays.asp
and this is another: https://www.programiz.com/javascript/multidimensional-array
Ok I got it and understand it, what would the best way to incorporate this script within Blockly?
Actually a perfect fit will be the new block that you made for Javascript which will come out in next update. While you are making the block if it is possible to actually change the name of the block as you go would be very nice. In the meantime how could this be done?
This past weekend I had my bot to locate an edge with high accuracy and pickup with a 5'' suction cup a piece of walnut wood. Next up is to pick up a sheet of 3/4 plywood and place it wherever it is needed, but this will take a bit because I need to add the second 6' arm which was already figured in the planning. Also will be adding more suction cups over a wider surface. It has already picked up 100 lbs with one arm.
I really enjoy learning from the second one https://www.programiz.com/javascript/multidimensional-array and I can experiment with running the code in various ways
Have the multidimensional array working nicely in typical Javascript console but realized things are set up a bit differently in ARC, could you please clarify some of these items let itemToFind = 'cookies'; is this ok? setVar("$itemToFind", getVar("cookies")); added question is ' ok or do I have to put " ? Is let ok in ARC? let stock = [{item:'cookies', xvalue: 22, yvalue: 33, zvalue: 44}, {etc}]; is this ok? setVar("$stock",[{item:'cookies', xvalue: 22, yvalue: 33, zvalue: 44}, {etc}]); let Wall = stock.find((s) => s.item === itemToFind); is this ok? setVar("$Wall", stock.find((s) => s.item === getVar("$itemToFind); let xposition = Wall.xvalue; is this ok? setVar($"xposition", "$Wall".xvalue); I tried inputing all of these but I get Unexpected end of input a sample multidimensional array in ARC would also help Thanks, Don
I have an idea for you but it'll take a few days for the next ARC update. stay tuned
Wonderful, thanks As I dig into some of these items I can really understand and appreciate how there is a ton of knowledge needed by you and your team to make these things all work together.
I downloaded the update for ARC and noticed the new Javascript Block -thanks. Still trying to get the multidimensional array working do you have some sample code that I can look over and see how you transitioned from typical Javascript with let etc to script that works within ARC?
From the manual: https://synthiam.com/Support/javascript-api/javascript-overview
setVarObject( variableName, value ) Sets the value from Arc’s public global variable storage of the object. This allows the variable to be available to other robot skills or scripts using getVar(). (Read More). This differs from setVar() because it sets the value as an object without translation. So you can pass entire objects, such as functions, classes, or multidimensional arrays.
{variableName} - The name of the global variable as a string {value} - The object value that you wish to store in the global variable
Example:
So, after setting the array object to the global variable store, it can be accessed by any other robot skill. Another robot skill can retrieve the array object into its localized variable scope.