I’m wondering what is the best way to connect Nengo model and ROS ecosystem.
Both of Nengo and ROS can code in Python, but importing Nengo package in rospy node doesn’t work.
For some major package (i.e. openCV) have ros binding to deal with that, so maybe this is also a way to go.
I’ve implementing a robot system connected the two with standard tcp/ip socket, threading and nengo-gui, this is easy for small set of variable to communicate. I’m looking for a more direct way of doing this.
I’ve seen NengoROS ( https://nengoros.wordpress.com/ ) which looks similar to what i’m talking about, but that is for Nengo-java.
I’ve put together some small examples of a publisher and subscriber using ROS with Nengo. You can find that here.
This version uses the newest Nengo and rospy and is designed to be run within nengo_gui. Some of the other code that you found uses the older Nengo and possibly a Java version of ROS.
Thanks for your response.
May I ask some question about your system setting?
Which version of python your nengo installed in?
I did tried to import nengo in a rospy script, but failed.
The reason of failure I guess is that my nengo is installed in python3.5 and rospy only support python2.7, so of course they couldn’t work together.
But when I open python2 CLI, I can import nengo and rospy at once without error. (which means nengo works in python2 and 3)
And when I run nengo GUI directly , this brings up the pyhton3. (verified with print(sys.version) command.)
How did you run your code?
As you mentioned this code should run with nengo gui, I’ll guess you run command “$nengo script_file.py” directly in terminal, is that right?
This is different from ros node launching process, usually I saw “$rosrun pkg_name script_name”.
I’m using Python 2.7. I haven’t tried it with Python 3 yet but I’m assuming it won’t work without some changes to rospy.
I run it like you said, from the terminal with nengo script_file.py. The nengo I’ve been using has been installed with Python 2.7, which is why it’s been bringing that version up in the GUI for me. I’d suggest to try making a virtual environment with Python 2.7 and see if you can get it to work in there.
I haven’t set it up to be a typical ros package, mostly since it’s easier to do it this way and also to be more easy to use for people who are familiar with python but not necessarily ros.