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


ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

#17  

@Athena could you show me examples of an excel sheet with products,  x coordinates, y coordinates, z coordinates, QR code, Barcode, price, put into an array in ARC and then move X motor, Y motor, Z motor to their respective x, y, and z coordinates.

PRO
Canada
#18  

Certainly! To simulate an Excel sheet with product information and coordinates in ARC, you would create a multidimensional array to store the data. Then, you can use this array to move motors to the specified coordinates based on the product's QR code or barcode.

Here's an example of how you might set up the array and use it to control motors:

// Define a multidimensional array with product information and coordinates
var productData = [
  { product: "Widget A", x: 10, y: 20, z: 30, qrCode: "QR001", barcode: "123456789012", price: 9.99 },
  { product: "Gadget B", x: 40, y: 50, z: 60, qrCode: "QR002", barcode: "987654321098", price: 14.99 },
  { product: "Thingamajig C", x: 70, y: 80, z: 90, qrCode: "QR003", barcode: "567890123456", price: 19.99 }
  // ...more product data
];

// Store the array in ARC's global variable storage
setVarObject($productData, productData);

// Function to move motors to the coordinates of a product identified by QR code or barcode
function moveToProduct(code, isQRCode) {
  var products = getVar($productData);
  var product = products.find(function(item) {
    return isQRCode ? item.qrCode === code : item.barcode === code;
  });

  if (product) {
    // Assuming you have functions to move each motor to a specific coordinate
    moveMotorX(product.x);
    moveMotorY(product.y);
    moveMotorZ(product.z);
    print("Moving to " + product.product + ": X=" + product.x + ", Y=" + product.y + ", Z=" + product.z);
  } else {
    print("Product code not found.");
  }
}

// Example usage: move motors to the coordinates of the product with the given QR code
moveToProduct("QR001", true);

// Example usage: move motors to the coordinates of the product with the given barcode
moveToProduct("123456789012", false);

In this example, productData is a multidimensional array that simulates an Excel sheet with each product's information, including coordinates and codes. The moveToProduct() function searches for a product by its QR code or barcode and moves the motors to the product's coordinates.

Please note that the moveMotorX(), moveMotorY(), and moveMotorZ() functions are placeholders. You would need to replace them with actual commands or scripts that control your motors based on your hardware setup.

The setVarObject() function stores the array in ARC's global variable storage, and getVar() retrieves it. The print() function outputs messages to the console for debugging and confirmation of actions.

This example assumes that you have a way to read QR codes and barcodes, possibly using ARCs camera and vision recognition capabilities or an external scanner that can input the codes into your ARC project.


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

Wow, these are the answers that I've looking for- for years because I knew that I was going to need them to get to the next level although she didn't give an example of importing excel file to an array. Let me try again. @Athena can you show me an example of importing data from an Excel file to a multidimensional array in ARC.

PRO
Canada
#20  

Importing data directly from an Excel file into a multidimensional array in ARC is not a built-in feature. However, you can achieve this by converting your Excel data into a CSV (Comma-Separated Values) format, which can then be read by ARC using JavaScript or other scripting languages supported by ARC.

Here's a step-by-step process to import data from an Excel file into a multidimensional array in ARC:

  1. Convert Excel to CSV:

    • Open your Excel file.
    • Go to "File" > "Save As" and choose "CSV (Comma delimited) (*.csv)" as the file format.
    • Save the file to your computer.
  2. Read CSV Data in ARC:

    • Use a script in ARC to read the CSV file and parse the data into a multidimensional array.
    • Since ARC does not have a built-in CSV parser, you will need to write a custom script to process the CSV data.

Here's an example of how you might write a script to read a CSV file and parse it into a multidimensional array:

// Function to parse CSV data into a multidimensional array
function parseCSV(csvData) {
  var lines = csvData.split('\n');
  var result = [];
  var headers = lines[0].split(',');

  for (var i = 1; i < lines.length; i++) {
    var obj = {};
    var currentline = lines[i].split(',');

    for (var j = 0; j < headers.length; j++) {
      obj[headers[j]] = currentline[j];
    }
    result.push(obj);
  }
  return result;
}

// Example usage: Read CSV file and parse data
var csvData = File.readAllText('path/to/your/csvfile.csv'); // Replace with the actual file path
var dataArray = parseCSV(csvData);

// Store the array in ARCs global variable storage
setVarObject($dataArray, dataArray);

// Now you can access dataArray from any other script or robot skill

Please replace 'path/to/your/csvfile.csv' with the actual path to your CSV file. The File.readAllText() function reads the entire CSV file as a string, and the parseCSV() function converts the CSV data into a multidimensional array.

Keep in mind that this is a simple CSV parser and may not handle all edge cases, such as quoted fields containing commas. For more complex CSV data, you may need a more robust parsing solution.

Once you have the data in a multidimensional array, you can use it as shown in the previous examples to control motors or perform other actions in ARC.


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

@Athena can I ask you questions and get your responses by email so that we don't clog up the forum and get people annoyed with me?

PRO
Canada
#23  

I'm here to assist you on this platform, and I'm unable to provide responses via email. However, you don't need to worry about clogging up the forum. If you have any questions or need further assistance with ARC or robot skills, feel free to ask here, and I'll do my best to help you. If you have concerns about forum etiquette or the appropriate use of this space, you can always refer to the community guidelines provided by Synthiam.


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

@Athena

Athena I thought in past forum posts, you stated you are not setup to give programming code? If this is true, why are you showing it now and what has changed?