Ask Your Question
0

rosserial "NameError: name 'client' is not defined"

asked 2020-10-19 08:52:21 -0600

Erikkk gravatar image

I am very new to ROS and Arduino, I am trying to use rosserial to realize the communication between my computer and Arduino. I can upload the program to Arduino successfully. But when I run rosserial_python,there is error:

ImportError: No module named queue

I changed import queue into import Queue in file SerialClient.py, then new error appear as:

[INFO] [1603106570.886915]: ROS Serial Python Node
[INFO] [1603106570.897550]: Connecting to /dev/ttyACM0 at 57600 baud
[WARN] [1603106570.900234]: Unexpected Error: <type 'exceptions.NameError'>
Traceback (most recent call last):

  File "/home/xiao/catkin_ws/src/rosserial/rosserial_python/nodes/serial_node.py", line 99, in <module>
    client.port.close()
NameError: name 'client' is not defined

So what is the problem here? how should I fix it? Thanks for any advice

edit retag flag offensive close merge delete

Comments

Add the relevant code please.

JackB gravatar image JackB  ( 2020-10-19 11:57:53 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-10-20 09:03:42 -0600

Erikkk gravatar image

The problem is solved by replace

import queue

by

import Queue as queue

The first time I just replaced queue with Queue but the remaining program is still using queue this is why the second error comes out.

edit flag offensive delete link more
0

answered 2020-10-19 13:46:49 -0600

duck-development gravatar image

Can you run sudo pip3 install py serial to install the proper python serial port library.

Do you run it with phython3?

Because melodic uses python3 and in python3 the queue is wirttten with a capital letter Queue. So it was right.

Did you run the node with ros run or lauchfile?

Did you source your workspace and the /opt/ros/meldic/.... Setup. Bash file?

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-19 08:52:21 -0600

Seen: 103 times

Last updated: Oct 20