I may have found, the code should be this :
var joint = PinJoint2D.new()
joint.set_node_b() #this is a problem with instance object
The problem comes with the object instances . The argument of " set_node_a " and " set_node_b " functions takes the path to the object.
But how to do when the object is created at runtime (instance()) ?