rosluanch error "process has died".

asked 2022-06-21 08:01:17 -0500

peyman1372 gravatar image

updated 2022-06-21 08:13:40 -0500

GeorgNo gravatar image

when i launch my node in a launch file i receive the below error. the interesting thing is that, whenever i run the node using rosrun it works, bot not working in roslaunch file.

[position_tracker-1] process has died [pid 7103, exit code 1, cmd /home/peyman/catkin-ws/src/just_for_learning/src/pointstamp.py __name:=position_tracker __log:=/home/peyman/.ros/log/8fe715de-f15f-11ec-aa70-a548e85acf05/position_tracker-1.log].
log file: /home/peyman/.ros/log/8fe715de-f15f-11ec-aa70-a548e85acf05/position_tracker-1*.log

here you are the node

#!/usr/bin/env python 
from nav_msgs.msg import Odometry
from visualization_msgs.msg import Marker, MarkerArray

from geometry_msgs.msg import Point
import tf
from tf.transformations import euler_from_quaternion
import numpy as np
import rostopic
import rospy


global mu
mu=[-2,-0.5,0]


def callback(data):
    global mu

    #add_point = Point()
    vel=data.twist.twist.linear.x/odom_hz
    ang=data.twist.twist.angular.z/odom_hz
    x_p=mu[0]+vel*np.cos(mu[2])
    y_p=mu[1]+vel*np.sin(mu[2])
    theta_p=ang+mu[2]
    mu=[x_p,y_p,theta_p]
    #add_point.x = x_p those are for a seet of point 
    #add_point.y = y_p
    #add_point.z = 0
    number_of_particles=100
    marker_arr=MarkerArray()
    marker_arr.markers=[]
    for i in range(number_of_particles):
        marker = Marker()

        marker.header.frame_id = "odom"
        marker.type = marker.SPHERE
        marker.action = marker.ADD
        marker.ns="est_pose_"+str(i)
        marker.id=i

        # marker scale
        marker.scale.x = 0.01
        marker.scale.y = 0.01
        marker.scale.z = 0.01

        # marker color
        marker.color.a = 1.0
        marker.color.r = 1.0
        marker.color.g = 1.0
        marker.color.b = 0.0

        # marker orientaiton
        marker.pose.orientation.x = 0.0
        marker.pose.orientation.y = 0.0
        marker.pose.orientation.z = 0.0
        marker.pose.orientation.w = 1.0

        marker.pose.position.x=np.random.uniform(x_p-0.05,x_p+0.05)
        marker.pose.position.y=np.random.uniform(y_p-0.05,y_p+0.05)
        marker.pose.position.z=0
        marker_arr.markers.append(marker)
        #marker.points.append(add_point)
        # Publish the Marker
    pub_point.publish(marker_arr)





# marker line points
#marker.points = []

if __name__=="__main__":
    global odom_hz
    map_file = rospy.get_param("~map_file")
    odom_topic_name = "odom"
    rospy.init_node('position_tracker')
    time_stamp=rospy.Time.now()
    pub_point = rospy.Publisher('realpoints_marker', MarkerArray, queue_size=1)


    tf_sub=tf.TransformListener()
    r = rostopic.ROSTopicHz(-1)
    s=rospy.Subscriber('/' + odom_topic_name, Odometry, r.callback_hz, callback_args='/odom')
    rospy.sleep(1)
    odom_hz = int(r.get_hz('/' + odom_topic_name)[0])
    s.unregister()
    rospy.Subscriber("/odom",Odometry, callback)

rospy.spin()

here you are the launch file

<launch>

    <node pkg="just_for_learning"  type="pointstamp.py" name="position_tracker">
            <param name="map_file" value="$(find robot_laser_grid_mapping)/maps/map.yaml" />

    </node>
    <node pkg="teleoperat1" type="key_to_twist.py" name="keys_to_twist" ></node>
    <node pkg="teleoperat1" type="keyboard_drive.py" name="keyboard_driver" ></node>

    <include file="$(find turtlebot3_gazebo)/launch/turtlebot3_world.launch" ></include>

    <include file="$(find turtlebot3_bringup)/launch/turtlebot3_model.launch"></include>

</launch>
edit retag flag offensive close merge delete

Comments

retagged it to ROS1 since you are using noetic

rospy.spin() should also be in your main() [have the same intend as the lines above] Have a look at : http://wiki.ros.org/ROS/Tutorials/Wri...

GeorgNo gravatar image GeorgNo  ( 2022-06-21 08:13:58 -0500 )edit