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

Issue runnig the simulator with Ardupilot #1

Open
RadionL opened this issue Nov 2, 2023 · 3 comments
Open

Issue runnig the simulator with Ardupilot #1

RadionL opened this issue Nov 2, 2023 · 3 comments

Comments

@RadionL
Copy link

RadionL commented Nov 2, 2023

Hi, I'm trying run simulate ubx GPS into Ardupilot (4.4.2)
after im running the script Ardupilot detects the GPS as ublox and disconnects.

thats the log from Pycharm terminal

C:\PycharmProjects\GPS\venv\Scripts\python.exe C:\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py -b 115200 -t 2 COM17
Opened serial port 'COM17' with a baudrate of 115200 and serial blocking read timeout of 0.01 seconds. Simulating I/O target #2.

Received VALID message: class 0x06, ID 0x01 w/ payload b'\x01\x06\x01' (length: 3).
CFG-MSG for class 0x01, ID 0x06 (NAV-SOL).
Rate for current target: b'\x01'
Requested rate change: class=0x01, ID=0x06, rate=b'\x01'
<<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x01\x0f8'

Received VALID message: class 0x06, ID 0x00 w/o payload.
Poll the configuration of the used I/O Port.
<<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Received VALID message: class 0x06, ID 0x00 w/o payload.
Poll the configuration of the used I/O Port.
<<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Received VALID message: class 0x06, ID 0x00 w/o payload.
Poll the configuration of the used I/O Port.
<<< Sending ACK-ACK response: b'\xb5b\x05\x01\x02\x00\x06\x00\x0e7'

Traceback (most recent call last):
File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 1051, in
run()
File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 1047, in run
simulator.run()
File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 324, in run
if self.check_cyclic_tx(base_rate_count, msg_class=b'\x01', msg_id=b'\x06'):
File "C:\Users\rudion\Desktop\Projects\פוד\Testing\ubx-gps-simulator-main\ubx_gps_simulator.py", line 764, in check_cyclic_tx
return base_rate_count % self.message_rates[msg_class][msg_id]['rate'] == 0
TypeError: unsupported operand type(s) for %: 'int' and 'bytes'

Process finished with exit code 1

@maehw
Copy link
Owner

maehw commented Nov 3, 2023

Hi @RadionL,

this is the first user feedback. Thanks for creating the ticket here.

Seems to be a type incompatibility around the modulo operator (%): base_rate_count is an integer, self.message_rates[msg_class][msg_id]['rate'] is bytes. I don't have time & a working test setup here to validate this - and I don't know why I've never run into this (maybe I've always had a 0 there). The second one should also be integer.

Maybe, you can do two things:

Add a print statement before the line with modulo:
print(self.message_rates[msg_class][msg_id]['rate'])

Try to convert the bytes to an integer (if it's multi-byte, the following probably won't work - we'll need to specify endianness):
return base_rate_count % int(self.message_rates[msg_class][msg_id]['rate']) == 0

Have a nice weekend!

@RadionL
Copy link
Author

RadionL commented Nov 4, 2023

Hi,
Converted to int and it's working.
Thanks

@maehw
Copy link
Owner

maehw commented Nov 5, 2023

Hi @RadionL,

great to hear! I'd be happy if you made a pull request with your change(s).

Kind regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants