Reading Coordinates in Java

Frequent questions asked online, offline, in forums are answered here
DimoUzunov
Posts: 2
Joined: Wed Aug 07, 2019 9:49 am

Reading Coordinates in Java

Postby DimoUzunov » Wed Aug 07, 2019 9:57 am

Hello, Marvelmind,

We're trying for quite some time to read data properly in Java. We're using the DLL file in Java but this is quite unstable.
With this code:

mming.PNG

Problem is the coordinates are not read properly. For example 1 beacon is positioned at 0,6000, 1000 (in mm) but we receive 0, 60000, 1000) So only y coordinate is wrong :(


Do you have a working example in Java / C# / JavaScript / Python in which you're reading and printing the current Hedge and Beacons coordinates.

Regards,
Dimo

smoker77
Posts: 243
Joined: Sat Feb 06, 2016 4:03 pm

Re: Reading Coordinates in Java

Postby smoker77 » Thu Aug 08, 2019 8:01 pm

Hello,

Do you read coordinates from modem with sending request according to this protocol
https://marvelmind.com/pics/modem_usb_protocol.pdf ?
Or you are reading streaming data from mobile beacon or modem according to protocol
https://marvelmind.com/pics/marvelmind_ ... rfaces.pdf ?

For first case the API with C example is available in 'API' folder of software pack.

For streaming data there are C and Python examples. Here is Python example:
https://github.com/MarvelmindRobotics/m ... master.zip

The code on your screenshot looks like modem protocol implementation, but not fully correct.
As you can see in section 1 of the modem protocol, x, y, z coordinates go immediately after address, so you should read X with offset 1, not 2.
Also 'ofs+= 16' should be instead 'ofs+=18', because size of coordinates record is 16 bytes in this data frame.

smoker77
Posts: 243
Joined: Sat Feb 06, 2016 4:03 pm

Re: Reading Coordinates in Java

Postby smoker77 » Thu Aug 08, 2019 8:24 pm

Sorry, now I understood that your code is Java port of the C example interface to API library dashapi.dll
In this case 'ofs+=18' and offset 2 for coordinates are correct.

Maybe the error is caused by incorrect transformation of negative Y value ( -6000 mm).
Try remove (' &0xFFFF ') from coordinates parsing. This operation cuts low 16 bits from 32-bit integer value.

DimoUzunov
Posts: 2
Joined: Wed Aug 07, 2019 9:49 am

Re: Reading Coordinates in Java

Postby DimoUzunov » Fri Aug 09, 2019 11:28 am

smoker77 wrote:Sorry, now I understood that your code is Java port of the C example interface to API library dashapi.dll
In this case 'ofs+=18' and offset 2 for coordinates are correct.

Maybe the error is caused by incorrect transformation of negative Y value ( -6000 mm).
Try remove (' &0xFFFF ') from coordinates parsing. This operation cuts low 16 bits from 32-bit integer value.


Thanks a lot for the fast reply! It fixes the problem for us.

Regards,
Dimo


Return to “FAQ”

Who is online

Users browsing this forum: No registered users and 4 guests