Bad mistake in Arduino library


#1

Hi,

I just tried to write individual programs using mDrawBot Kit with mBlock.
Nothing worked like it should. Analysing the generated Arduino Code I found that there is a Mistake in one of the libraries.

When I, in mBlock, insert the Block "Set Delta to atan of x/y"
it will, in Arduino Code, translate to delta = atan(angle_rad*(y) / (x));

But it should translate to delta = angle_rad*(atan(y) / (x));

I get the same issue using acos and asin functions. Fixing is only possible over the Arduino IDE.

As this is very inconvenient I hope you find a way to update the library.

Regards
Reinhard


#2

Hi @atz,

I’d say it is more likely an error in the code generator (which is responsible for generating the C code for the Arduino environment). Regardless, it does need to be corrected. What version of mBlock are you using and on which operating system? This is information that @tec_support will need to help you.

Best regards,

Chuck


#3

Hi Chuck,

I am using the Windows 3.4.8 Version of mBlock and the 3.4.3 Version on Mac. The mistake is the same.
But I myself made a mistake:

“set a to atan of b” should translate to
a=atan(b); if you want the result in radians and
a=angle_deg*atan(b); if you want the result in degrees.

Meanwhile I also found a workaround in Scratch:
“set a to atan of (b/angle_rad)” or “set a to angle_deg*atan(b/angle_rad)” if you want degrees.

Best regards
Reinhard


#4

Good to hear that you found a workaround, but it’s still a bug in the code generator. Have you tried mBlock 4.0 to see if it still persists?


#5

I tried the function on mBlock 4.01 on my Mac. It is still the same.


#6

Hi atz,

We have provided feedback of this issue to our engineer.
Thanks for your feedback!


#7

not to be a pain but atan is still wrong in arduino mode
it still says:
delta = atan((4)*angle_deg / (2));
while it should be:
delta = atan((4/2))*angle_deg;

maybe usefull to correct it


#8

hello
my name is hans.