Asked — Edited
Resolved Resolved by Rich!

Sizeof Array

Does anyone know if its possible and how to recreate the Sizeof command from Arduino processing in EZ-Script.

I am trying to port some code to EZ-Script but not quite sure how to accomplish this.

Arduino Sizeof command

Here is what I am really trying to port:

Lets say you have a array of values:

int sequence[] = {0, 2, 4, 6, 8, 10, 9, 7, 5, 3, 1};

You calculate how many degrees each value represents. (Each value in the array means a certain number of degrees or servo position.

// Pre-calculate degrees per adjustment of turret servo. const int degreesTurret = 180/(sizeof(sequence)/sizeof(int)-1);

You use this value to move the servo that many degrees

theta = sequence[i] * degreesTurret;

Note: i gets incremented using i++;

Also what does the value from getping represent. Is that a raw value from the sensor or does that value have another meaning like distance in cm and inches.

Thanks


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

#1  

Looks like another math problem for Rich;)

#3  

@Mel... Justin who? Are you talking about JustinRatliff? yeah, he don't like math Mel... Unless you were trying to be funny.... I don't like math either.... I do it when I have, however....

#4  

To duplicate that arduino command I think the first question is this. Is their an ez - script command to determine how many elements is in a array.

United Kingdom
#5  

To tackle the "what does the getping represent", it's raw data from the ping sensor, with 255 being it's furthest away and 0 being closest. The resolution of the sensor will determine how far each unit represents. The ping sensor in the EZ-Robot kit has a 255" range which makes it easy, 1 = 1" however if it was a different one and a value of 100 was given at 1M away this would be as easy as working out the ratio. 1000mm / 100 units = 10mm per unit.

As for the array, I'd have to check the script manual etc. since I've not used arrays yet. I'd also have to read the OP properly to find out what is actually trying to be accomplished. I always find it easier to start from a blank slate than to try porting over complex Arduino code, often it's much simpler in EZ-Script than Arduino so porting can overcomplicate matters.

#6  

I've been reading the EZ script manual heavily and it does not have many of the function (like math) you might find in an arduino....my suspicion is that many of those math functions are not needed.

In the example code shown the array is used to move a servo in a pan motion. You could use RADAR for that or you could use an Auto Position control and store the movements in a sequence then call up the sequence via a script. The arduino you need the heavy math to do something simple....in EZ-Robot you don't need the math...you just need to point, click and configure (for most things).

That is assuming you wanted to pan a servo like a turret?

I'm starting to believe, to get things to move or take sensor readings, you don't need a lot of match with EZ-Robot. Basic math, greater then, less then, +, -, =, is probably the most common math functions 99% of us would use. (feel free to point I'm wrong on that).

For the A.I. math and the 1%ers out there...I'm leaning towards an open source 3rd party app like EZ-Face to perform those math functions and return results to ARC. Any thoughts on that?

United Kingdom
#7  

What math commands do you think are needed but not available?

#8  

I am not sure that the math is really the question here though it may play a role in the grand scheme of things.

If we put aside the math aspect of this the basic question I need answered is this.

How would I iterate through the elements of an array, get the contents of each element, store the contents in a variable and do it in a way that I don't have to rewrite code the same code throughout my app?

This array would be used multiple times.

Thanks for all the help.