NEP+ Docs
  • NEP+ middleware documentation
  • Developer Tools
    • NEP CLI
  • User interfaces
    • Install NEP+ App (Windows)
    • Install NEP+ App (macOS)
    • NEP+ App (0.0.4) - Deprecated
  • Concepts for developers
    • Message Format
    • Tutorials for developers
      • Connecting Multiple Scripts on the Same Computer using NEP+ Tools: A Step-by-Step Tutorial
      • Connecting 2 scripts in a local network (e.g., two computers on the same Wifi network)
      • Connecting ROS to non-ROS nodes using NEP+ tools
  • Programming enviroments
    • Python
    • C# (Unity)
    • C# (Visual Studio)
    • Javascript (Node.js)
    • Java/Kotlin (Android Studio)
    • Java (Netbeans)
    • C++ (Visual Studio)
  • Other tutorials
    • Pepper & NAO robots
      • Using Pepper without Pepper in Choregraphe
      • Install Pepper/NAO SDK
  • Code examples
    • Sending images from Python and Opencv
Powered by GitBook
On this page
  • Direct method
  • Bridge NEP Publishers to ROS Subscribers in Python
  • Bridge ROS Publishers to NEP Subscribers in Python
  1. Concepts for developers
  2. Tutorials for developers

Connecting ROS to non-ROS nodes using NEP+ tools

Last updated 2 years ago

We will explore three different methods:

Method
When is recommended?
Comments

Direct

When your software architecture uses mainly ROS and is only needed to connect a single node/computer that does not support ROS

It can be annoying to deal with IP addresses and port numbers for NEP nodes. You manually create the bridge between NEP and ROS

nep-cli

When one or more modules not supporting ROS need to be connected with a ROS architecture

You need to use the same IP address for all your NEP nodes.

Nep+ App

If you don't want to code at all the bridges between NEP and ROS

Can be more complex to use at the beginning, still in a beta version

Direct method

Before following this tutorial, read

Bridge NEP Publishers to ROS Subscribers in Python

Let's imagine that Computer B, defined in tutorial , has Ubuntu and ROS installed and that it is required to send the data produced in the NEP Publisher to a ROS Subscriber.

For this example, we will use ROS Standart String messages to link a NEP Publisher with ROS. We will define a bridge script that creates a NEP Subscriber and ROS Publisher.

The code of the bridge script is shown below.

import nep
import time
import rospy
from std_msgs.msg import String

ros_pub = rospy.Publisher('chatter', String, queue_size=10)
rospy.init_node('talker', anonymous=True)

# Create a new nep node
node = nep.node("receiver")     
# Set a direct connection using port <3000> and in <'one2many'> mode
# Important: 	You need to change the IP address <'127.0.0.1'> by 
# 		the IP address of you PC running the publisher node                                                   
conf = node.direct(ip = "127.0.0.1", port =  3000, mode ="one2many")                         
# Create a new nep subscriber with the topic <'test'>
sub = node.new_sub("test_subcriber", "json", conf) 

while True:
    # Read data in a non-blocking mode
    s, msg = sub.listen() 
    # if s == True, then there is data in the socket      
    if s:                       
        print(msg)
        # msg is a python dictionary
        # we convert the value of msg["result"] to string 
        ros_pub.publish(str(msg["result"]))
    else:
        # An small sleep will reduce computational load
        time.sleep(.0001)

Using correctly rospy.Rate will require more complex code, we will update an example soon.

Bridge ROS Publishers to NEP Subscribers in Python

Soon..

Connecting 2 scripts in a local network (e.g., two computers on the same Wifi network)
Connecting 2 scripts in a local network (e.g., two computers on the same Wifi network)
Main idea behind connecting NEP Publishers and ROS Subscribers in a direct method