odrive liveplotter 报错 “set_wakeup_fd only works in main thread of the main interpreter”

odrive liveplotter 报错 “set_wakeup_fd only works in main thread of the main interpreter”

最近在弄FOC,电脑装的是odrive 0.5.1。在进行实时画图的时候需要运行下面的代码

start_liveplotter(lambda:[odrv0.axis0.encoder.pos_estimate, odrv0.axis0.controller.pos_setpoint])

但是,在运行这行代码的时候爆出如下错误,

In [1]: start_liveplotter(lambda:[odrv0.axis0.encoder.pos_estimate, odrv0.axis0.controller.pos_setpoint])

Out[1]: <fibre.utils.Event at 0x1d511e5fa00>



Installed qt6 event loop hook.

C:\Users\ruiga\.conda\envs\py39\lib\site-packages\odrive\utils.py:154: UserWarning: Starting a Matplotlib GUI outside o.

  fig = plt.figure()

Exception in thread Thread-4:

Traceback (most recent call last):

  File "C:\Users\ruiga\.conda\envs\py39\lib\threading.py", line 980, in _bootstrap_inner

    self.run()

  File "C:\Users\ruiga\.conda\envs\py39\lib\threading.py", line 917, in run

    self._target(*self._args, **self._kwargs)

  File "C:\Users\ruiga\.conda\envs\py39\lib\site-packages\odrive\utils.py", line 162, in plot_data

    fig.canvas.start_event_loop(1/plot_rate)

  File "C:\Users\ruiga\.conda\envs\py39\lib\site-packages\matplotlib\backends\backend_qt.py", line 412, in start_event_p

    with _maybe_allow_interrupt(event_loop):

  File "C:\Users\ruiga\.conda\envs\py39\lib\contextlib.py", line 119, in __enter__

    return next(self.gen)

  File "C:\Users\ruiga\.conda\envs\py39\lib\site-packages\matplotlib\backends\qt_compat.py", line 199, in _maybe_allow_t

    old_wakeup_fd = signal.set_wakeup_fd(wsock.fileno())

ValueError: set_wakeup_fd only works in main thread of the main interpreter

其实解决的方法很简单,只需要先运行

odrivetool

然后在接下来的命令行运行下列命令

In [1]: import matplotlib
In [2]: matplotlib.use('TkAgg')

然后再运行

start_liveplotter(lambda:[odrv0.axis0.encoder.pos_estimate, odrv0.axis0.controller.pos_setpoint])

就可以画图了。ez问题

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值