ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error create_subscriber is not a method of Node

asked 2022-03-07 15:36:47 -0600

pablo.arandarod gravatar image

I have been trying to create a node which has the following description:

import sys
import os

import numpy as np

import rclpy
from rclpy.node import Node
from std_msgs.msg import Float32MultiArray
from std_msgs.msg import Bool

dataArray = Float32MultiArray

class controllerNode(Node):
''' Class definition of the controller node'''
def __init__(self):
    super().__init__("controller")

    self.q = np.zeros((6,1))
    self.dq = np.zeros((6,1))
    self.q = np.zeros((6,1))
    self.dq = np.zeros((6,1))
    self.tau = np.zeros((6,1))
    self.first = True

    # Declare publishers and subscribers
    self.input_subscriber = self.create_subscriber(dataArray, 'robot_input', self.input_callback, 10)
    self.reset_subscriber = self.create_subscriber(Bool, 'first_input', self.reset_callback, 10)

    self.action_publisher = self.create_publisher(dataArray, 'action', 10)

When I build the node and try to execute it an error appears with the following description: AttributeError: 'controllerNode' object has no attribute 'create_subscriber'. I cannot think where this error is coming from, since I have another node where I just copied and paste and put different parameters and it is working.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-03-10 18:17:32 -0600

It's create_subscription instead of create_subscriber

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-03-07 15:36:47 -0600

Seen: 547 times

Last updated: Mar 10 '22