#!/usr/bin/python3
from anx_interface.anx_interface import AnxInterface
import rclpy
from rclpy.node import Node
from sensor_msgs.msg import Imu
from std_msgs.msg import String
class Anx(Node):
def __init__(self):
super().__init__('anx_interface')
self.imu_pub=self.create_publisher(Imu,'/imu',10)
self.gnss_pub=self.create_publisher(String,'/gnss',10)
self.fps=10
self.anx_ros=AnxInterface()
self.timer=self.create_timer(0.5,self.get_imu)
def imu_cb(imu_data):
print(f'{imu_data}')
def get_imu(self):
self.anx_ros.start_device_imu(fps=self.fps, cb=self.imu_cb)
self.anx_ros.wait()
def main():
rclpy.init()
anx_interface=Anx()
rclpy.spin(anx_interface)
if __name__=="__main__":
main()
This gives me and error telling
Traceback (most recent call last):
File "/root/flo_ws/install/lawn_mower/lib/lawn_mower/anx_interface", line 33, in
sys.exit(load_entry_point('lawn-mower==0.0.0', 'console_scripts', 'anx_interface')())
File "/root/flo_ws/install/lawn_mower/lib/python3.10/site-packages/lawn_mower/anx.py", line 32, in main
rclpy.spin(anx_interface)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/init.py", line 222, in spin
executor.spin_once()
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 713, in spin_once
raise handler.exception()
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in call
self._handler.send(None)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 418, in handler
await call_coroutine(entity, arg)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 332, in _execute_timer
await await_or_execute(tmr.callback)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
return callback(*args)
File "/root/flo_ws/install/lawn_mower/lib/python3.10/site-packages/lawn_mower/anx.py", line 24, in get_imu
self.anx_ros.start_device_imu(fps=self.fps, cb=self.imu_cb)
File "/usr/local/lib/python3.10/dist-packages/anx_interface/anx_interface.py", line 135, in start_device_imu
self._socket_rpc.send_multipart([b"StartDeviceImu", req_bytes])
File "/usr/local/lib/python3.10/dist-packages/zmq/sugar/socket.py", line 595, in send_multipart
self.send(msg, SNDMORE | flags, copy=copy, track=track)
File "/usr/local/lib/python3.10/dist-packages/zmq/sugar/socket.py", line 547, in send
return super(Socket, self).send(data, flags=flags, copy=copy, track=track)
File "zmq/backend/cython/socket.pyx", line 718, in zmq.backend.cython.socket.Socket.send
File "zmq/backend/cython/socket.pyx", line 765, in zmq.backend.cython.socket.Socket.send
File "zmq/backend/cython/socket.pyx", line 247, in zmq.backend.cython.socket._send_copy
File "zmq/backend/cython/socket.pyx", line 242, in zmq.backend.cython.socket._send_copy
File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Operation cannot be accomplished in current state
[ros2run]: Process exited with failure 1
This gives me and error telling
Traceback (most recent call last): File "/root/flo_ws/install/lawn_mower/lib/lawn_mower/anx_interface", line 33, in
sys.exit(load_entry_point('lawn-mower==0.0.0', 'console_scripts', 'anx_interface')())
File "/root/flo_ws/install/lawn_mower/lib/python3.10/site-packages/lawn_mower/anx.py", line 32, in main
rclpy.spin(anx_interface)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/init.py", line 222, in spin
executor.spin_once()
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 713, in spin_once
raise handler.exception()
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/task.py", line 239, in call
self._handler.send(None)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 418, in handler
await call_coroutine(entity, arg)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 332, in _execute_timer
await await_or_execute(tmr.callback)
File "/opt/ros/humble/install/rclpy/local/lib/python3.10/dist-packages/rclpy/executors.py", line 107, in await_or_execute
return callback(*args)
File "/root/flo_ws/install/lawn_mower/lib/python3.10/site-packages/lawn_mower/anx.py", line 24, in get_imu
self.anx_ros.start_device_imu(fps=self.fps, cb=self.imu_cb)
File "/usr/local/lib/python3.10/dist-packages/anx_interface/anx_interface.py", line 135, in start_device_imu
self._socket_rpc.send_multipart([b"StartDeviceImu", req_bytes])
File "/usr/local/lib/python3.10/dist-packages/zmq/sugar/socket.py", line 595, in send_multipart
self.send(msg, SNDMORE | flags, copy=copy, track=track)
File "/usr/local/lib/python3.10/dist-packages/zmq/sugar/socket.py", line 547, in send
return super(Socket, self).send(data, flags=flags, copy=copy, track=track)
File "zmq/backend/cython/socket.pyx", line 718, in zmq.backend.cython.socket.Socket.send
File "zmq/backend/cython/socket.pyx", line 765, in zmq.backend.cython.socket.Socket.send
File "zmq/backend/cython/socket.pyx", line 247, in zmq.backend.cython.socket._send_copy
File "zmq/backend/cython/socket.pyx", line 242, in zmq.backend.cython.socket._send_copy
File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Operation cannot be accomplished in current state
[ros2run]: Process exited with failure 1
and when i check the phone, ANX crashed