How to Integrate Nengo with ROS

Hi, everyone:

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.

Thanks for your attention.
Edward Chen

how did this work?, I can’t even import nengo within the script located in catkin_ws/src/

@brent is this something you can help with? I know you’ve done multiple projects integrating Nengo with ROS:

how did this work?, I can’t even import nengo within the script located in catkin_ws/src/

From my experience with ROS, compiling it properly can be quite challenging, Are you able to create a new ROS project and import Nengo inside of it?

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.

Let me know if you have any questions!

1 Like

Hi @brent:

Thanks for your response.
May I ask some question about your system setting?

  1. 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.)

  2. 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”.

Thanks for your attention.

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.

I hope that helps!

1 Like