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

microbot's profile - activity

2023-05-08 08:45:57 -0500 marked best answer rospy.init_node() has already been called with different arguments

Hello,

I have followed the following tutorial link text to create a joint state listener. Although this process is not working for me. I have a robot with 24 joints and I want to write a listener so that I can get joint position of the mentioned joint. The above mentioned link creates a handy server to filter out the required joint positions. I followed the same but I was unable to subsrcribe to the required joint. In order to test where the bug is , I have tried to first create the object from the LatestJointStates class, when I do that I am having the following error,

 File "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 31, in __init__
 rospy.init_node('joint_states_listener')
 File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/client.py", line 274, in init_node
 raise rospy.exceptions.ROSException("rospy.init_node() has already been called with different arguments: 
 "+str(_init_node_args))
 rospy.exceptions.ROSException: rospy.init_node() has already been called with different arguments: 
 ('joint_state_publisher', ['/home/microbot/catkin_ws/src/spider/spider_control/control.py'], True, None, False, False)

For reference I am also posting the code that is present in the link,

class  LatestJointStates:


def __init__(self):
    rospy.init_node('joint_states_listener')
    self.lock = threading.Lock()
    self.name = []
    self.position = []
    self.velocity = []
    self.effort = []
    self.thread = threading.Thread(target=self.joint_States_listener)
    self.thread.start()

    s = rospy.Service('return_joint_states', JointState, self.return_joint_states)
    #thread the function to listen to joint state messages
def joint_states_listener(self):
    rospy.Subscriber('joint_states', JointState, self.joint_states_callback)
    rospy.spin()

    #callback function inorder to save the values when joint_states are available
def joint_States_callback(self, msg):
    self.lock.acquire()
    self.name = msg.name
    self.position = msg.position
    self.velocity = msg.velocity
    self.effort = msg.effort
    self.lock.release()
    #function that returns joint variables for joint names that are given
def return_joint_state(self, joint_name):

        #no messages
    if self.name==[]:
        rospy.logerr("no robot_State messages received \n")
        return 0, 0, 0, 0
        #return info for this joint
    self.lock.acquire()
    if joint_name in self.name:
        index = self.name.index(joint_name)
        position = self.position[index]
        velocity = self.velocity[index]
        effort = self.effort[index]

        #joint name not found
    else:
        rospy.logerr("Joint %s not found", (joint_name))
        self.lock.release()
        return 0, 0, 0, 0
    self.lock.release()
    return 1, position, velocity, effort
    #server callback to return array of position velocity and effort of the called joint names

def return_joint_states(self, req):
    joints_found = []
    positions = []
    velocities = []
    efforts = []
    for joint_name in req.name:
        (found, position, velocity, effort)=self.return_joint_state(joint_name)
        joints_found.append(found)
        positions.append(position)
        velocities.append(velocity)
        efforts.append(effort)
    return ReturnJointStatesResponse(joints_found, positions, velocities, efforts)

This was supposed to be the service node as mentioned in the provided link and its called back as follows

def call_return_joint_states(joint_names):
rospy.wait_for_service("return_joint_states")
try:
    print("bug testing call_return joint states")
    s = rospy.ServiceProxy("return_joint_States", JointState)
    resp = s(joint_names)
except rospy.ServiceException as e:
    print ('error when calling return_joint_states:' + s +'is' + e)
    sys.exit(1)
for (ind, joint_name) in enumerate(joint_names):
    if(not resp.found[ind]):
        print ('joint %s ...
(more)
2021-11-15 01:27:47 -0500 received badge  Famous Question (source)
2021-05-19 10:32:30 -0500 received badge  Famous Question (source)
2021-04-22 08:33:42 -0500 marked best answer Module not found error with rospkg when trying to import roslib

Hello,

I have developed a custom control algorithm for mz robot in gazebo. Untile yesterday I used to use

roslaunch spider_gazebo spider_world.launch

to spawn the robot and load control configurations in gazebo and then in another terminal i used to export ROS_MASTER_URI and then use

rosrun spider_control control.py

to run my custom python plugin. Until yesterday this was working well, but today when I tried to launch again `I am having the following error

    'Traceback (most recent call last):
   File "/home/microbot/catkin_ws/src/spider/spider_control/control.py", line 5, in <module>
     import roslib
   File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/__init__.py", line 50, in <module>
     from roslib.launcher import load_manifest
    File "/opt/ros/melodic/lib/python2.7/dist-packages/roslib/launcher.py", line 42, in <module>
      import rospkg
    ModuleNotFoundError: No module named 'rospkg'

I have also tried the following command to check whether my python path is right or not ,

 'echo $PYTHONPATH'

The output is

  '/home/microbot/catkin_ws/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist- 
    packages:/opt/ros/melodic/share/ros/core/roslib/src

I can not understand whats causing this error. can any one please help me point out the reason. Thanks

2021-03-04 19:07:27 -0500 marked best answer Could not load Joint_state_controller because the type was not specified error while roslaunch

Hello,

I have been trying to launch a robot on a world in gazebo 9 using roslaunch. While doing so I have been facing the following error and can not understand the reason behind it.

[ERROR] [1562704670.507021295, 1.372000000]: Could not load controller 'Joint_state_controller' because the type was 
not specified. Did you load the controller configuration on the parameter server (namespace: 
'/spider/Joint_state_controller')?
[ERROR] [1562704671.508187, 2.241000]: Failed to load Joint_state_controller

Here is my control launch file,

 <launch>

 <!-- Load joint controller configurations from YAML file to parameter server -->
 <rosparam file="$(find spider_control)/config/spider_control.yaml" command="load"/>

 <!-- load the controllers -->
 <node name="controller_spawnner" pkg="controller_manager" type="spawner" respawn="false"
  output="screen" ns="/spider" args="joint_1_1_position_controller
                  joint_1_2_position_controller
                                      joint_1_3_position_controller
                                      joint_2_1_position_controller
                                      joint_2_2_position_controller
                                      joint_2_3_position_controller
                                      joint_3_1_position_controller
                                      joint_3_2_position_controller
                                      joint_3_3_position_controller
                                      joint_4_1_position_controller
                                      joint_4_2_position_controller
                                      joint_4_3_position_controller
                                      joint_5_1_position_controller
                                      joint_5_2_position_controller
                                      joint_5_3_position_controller
                                      joint_6_1_position_controller
                                      joint_6_2_position_controller
                                      joint_6_3_position_controller
                                      joint_7_1_position_controller
                                      joint_7_2_position_controller
                                      joint_7_3_position_controller
                                      joint_8_1_position_controller
                                      joint_8_2_position_controller
                                      joint_8_3_position_controller
                                      Joint_state_controller"/>

    <!-- convert joint states to TF transforms for rviz, etc -->
    <node name="rob_st_pub" pkg="robot_state_publisher" type="robot_state_publisher"
    respawn="false" output="screen">
    <remap from="robot_description" to="robot_description" />
    <remap from="/joint_states" to="/spider/joint_states" />

  </node>

</launch>

I am using ros-melodic with gazebo9. Can anyone please help me in finding the reason behind this error. Thank you.

2021-03-04 19:07:27 -0500 received badge  Nice Answer (source)
2021-02-06 03:20:11 -0500 received badge  Famous Question (source)
2020-12-06 11:46:17 -0500 received badge  Famous Question (source)
2020-11-23 10:43:54 -0500 received badge  Notable Question (source)
2020-10-19 11:18:39 -0500 received badge  Notable Question (source)
2020-10-06 03:37:30 -0500 received badge  Famous Question (source)
2020-09-24 09:54:19 -0500 received badge  Popular Question (source)
2020-09-24 04:00:45 -0500 commented question can not roslaunch canopen_motor_node as it throws an instance

yes, it was a typo. Sorry, i have corrected it now

2020-09-24 04:00:28 -0500 edited question can not roslaunch canopen_motor_node as it throws an instance

can not roslaunch canopen_motor_node as it throws an instance Hello, I am trying to control a synapticon cia402 servo

2020-09-22 07:05:55 -0500 asked a question can not roslaunch canopen_motor_node as it throws an instance

can not roslaunch canopen_motor_node as it throws an instance Hello, I am trying to control a synapticon cia402 servo

2020-09-21 01:11:08 -0500 marked best answer What exactly is causing this error whne compiling the node ?

I am trying to write a simple node that responds with a message when an image from camera is received. I have specific node provided by the ROS for this camera to open it and other to request the data. Now i want to write a simple subscriber that is subscribed to the topic that is being published by the request data node and i want my node to simple acknowledge the image received with a simple message.

Here is the code for my simple node

void imageCallback(const sensor_msgs::ImageConstPtr& msg){
     ROS_INFO("I heard the image");
}

int main(int argc, char **argv){

    ros::init(argc, argv, "test_node_vision");

    ros::NodeHandle nh;
    ros::Subscriber sub = nh.subscribe("image_listener", 1000, imageCallback);

    ros::spin();


    return 0;
}

when trying to ros run this node, there is a syntax error with '(' token near the line where i am defining the imageCallback function. But to me all the syntax looks correct and hence I suspect there is something somewhere else going wrong with this node which then caused a domino effect ended up with this error. Can anyone please help me with this. Thank you.

Here is the error

/home/sganapa/catkin_ws/src/montage-anwendung/montage_roboter/src/ensenso_tutorial.cpp: line 10: syntax error near unexpected token `(' /home/sganapa/catkin_ws/src/montage-anwendung/montage_roboter/src/ensenso_tutorial.cpp: line 10: `void imageCallback(const sensor_msgs::ImageConstPtr& msg){'

2020-09-21 01:10:52 -0500 received badge  Notable Question (source)
2020-08-20 14:20:46 -0500 marked best answer rosrun: unable to locate the node robot_state_publisher

The exact error I am having is

ERROR: cannot launch node of type [robot_state_publisher/state_publisher]: can't locate node [state_publisher] in package [robot_state_publisher]

I have cloned the robot_state_publisher from ros wiki and already had done rosmake.

I have also sourced the terminal to devel before using rosrun aswell as exported all the reqaquired core packages and python path to the terminal before trying to run the robot_state_publisher.

here is the my CmakeList.txt file,

cmake_minimum_required(VERSION 2.8)
project(robot_state_publisher)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")

find_package(orocos_kdl REQUIRED)
find_package(catkin REQUIRED
  COMPONENTS roscpp rosconsole rostime tf tf2_ros tf2_kdl kdl_parser
)
find_package(Eigen3 REQUIRED)

find_package(urdfdom_headers REQUIRED)

catkin_package(
  LIBRARIES ${PROJECT_NAME}_solver
  INCLUDE_DIRS include
  DEPENDS roscpp rosconsole rostime tf2_ros tf2_kdl kdl_parser orocos_kdl urdfdom_headers
)

include_directories(SYSTEM ${EIGEN3_INCLUDE_DIRS})
include_directories(include ${catkin_INCLUDE_DIRS} ${orocos_kdl_INCLUDE_DIRS} ${urdfdom_headers_INCLUDE_DIRS})
link_directories(${orocos_kdl_LIBRARY_DIRS})

add_library(${PROJECT_NAME}_solver
  src/robot_state_publisher.cpp src/treefksolverposfull_recursive.cpp
)
target_link_libraries(${PROJECT_NAME}_solver ${catkin_LIBRARIES} ${orocos_kdl_LIBRARIES})

add_library(joint_state_listener src/joint_state_listener.cpp)
target_link_libraries(joint_state_listener ${PROJECT_NAME}_solver ${orocos_kdl_LIBRARIES})

add_executable(${PROJECT_NAME} src/joint_state_listener.cpp)
target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_solver ${orocos_kdl_LIBRARIES})

# compile the same executable using the old name as well
add_executable(state_publisher src/joint_state_listener.cpp)
target_link_libraries(state_publisher ${PROJECT_NAME}_solver ${orocos_kdl_LIBRARIES})

Can you please help me solve this problem, I am trying to run a robot I have designed using xacro on gazebo and control it with ros. I have already installed ros_control and ros_gazebo packages. Thank you advance,

2020-06-25 02:04:15 -0500 received badge  Famous Question (source)
2020-05-18 05:31:44 -0500 received badge  Popular Question (source)
2020-05-17 08:45:38 -0500 received badge  Famous Question (source)
2020-05-06 12:06:13 -0500 received badge  Famous Question (source)
2020-04-10 12:52:06 -0500 received badge  Notable Question (source)
2020-04-02 08:08:45 -0500 commented answer What exactly is causing this error whne compiling the node ?

yes, the code was right, i am trying to rosrun the cpp file instead of catkin_make binray. All the time looking at that

2020-04-02 08:07:49 -0500 commented answer What exactly is causing this error whne compiling the node ?

yea exactly that was the error. Thank you.

2020-04-02 08:07:16 -0500 received badge  Popular Question (source)
2020-04-02 07:49:18 -0500 received badge  Rapid Responder (source)
2020-04-02 07:49:18 -0500 answered a question What exactly is causing this error whne compiling the node ?

I have solved it, it was just a basic mistake where after catkin_make , instead of trying to run the target i was still

2020-04-02 07:25:44 -0500 commented answer What exactly is causing this error whne compiling the node ?

Hello, I have added the header file and the error still remains same.

2020-04-02 07:12:29 -0500 commented question What exactly is causing this error whne compiling the node ?

Here I have added the error. As said, it says syntax error.

2020-04-02 07:11:55 -0500 edited question What exactly is causing this error whne compiling the node ?

What exactly is causing this error whne compiling the node ? I am trying to write a simple node that responds with a mes

2020-04-02 07:11:17 -0500 edited question What exactly is causing this error whne compiling the node ?

What exactly is causing this error whne compiling the node ? I am trying to write a simple node that responds with a mes

2020-04-02 06:25:10 -0500 asked a question What exactly is causing this error whne compiling the node ?

What exactly is causing this error whne compiling the node ? I am trying to write a simple node that responds with a mes

2020-03-18 06:15:55 -0500 received badge  Famous Question (source)
2020-02-28 04:26:16 -0500 received badge  Famous Question (source)
2019-12-02 02:57:25 -0500 received badge  Famous Question (source)
2019-11-28 01:25:32 -0500 received badge  Notable Question (source)
2019-11-28 01:25:32 -0500 received badge  Popular Question (source)
2019-11-21 00:01:02 -0500 received badge  Popular Question (source)
2019-11-13 05:14:17 -0500 received badge  Famous Question (source)
2019-11-04 18:37:52 -0500 received badge  Notable Question (source)
2019-10-31 16:40:05 -0500 received badge  Famous Question (source)
2019-10-24 05:32:02 -0500 received badge  Famous Question (source)
2019-10-24 05:32:02 -0500 received badge  Notable Question (source)
2019-10-24 05:32:02 -0500 received badge  Popular Question (source)
2019-10-22 11:28:00 -0500 received badge  Popular Question (source)
2019-10-22 11:28:00 -0500 received badge  Notable Question (source)
2019-10-16 03:17:57 -0500 received badge  Famous Question (source)