Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set_wp does not handle negative longitude #2

Open
FabianSchwartau opened this issue Feb 9, 2020 · 1 comment
Open

set_wp does not handle negative longitude #2

FabianSchwartau opened this issue Feb 9, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@FabianSchwartau
Copy link

The title basically says it all. I get:

Traceback (most recent call last):
File "rc.py", line 8, in
copter.set_wp(1, 1, 50.9103311, -10.5349744, 0, 10, 0, 0, 0)
File "MSP.py", line 194, in set_wp
payload += int(lon * 10000000).to_bytes(4, byteorder='little')#lon
OverflowError: can't convert negative int to unsigned

@nik012003
Copy link
Owner

nik012003 commented Feb 9, 2020

Hi, thanks for pointing out this issue.

typedef struct {
uint8_t action;
int32_t lat;
int32_t lon;
int32_t alt;
int16_t p1, p2, p3;
uint8_t flag;
} navWaypoint_t;

lat, lon, alt variables are signed int but in the OpenGS code they are treated as unsigned.
You'd need to add signed=True in the to_bytes function.Like this:

payload += int(lon * 10000000).to_bytes(4, byteorder='little', signed=True)

I hope this fixes your problem. Unfortunately I cannot test it/ upload new code now as I won't be home for a few days.

@nik012003 nik012003 added the bug Something isn't working label Feb 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants