Publishing to Initialpose Programmatically on Turtlebot Navigation
I am trying to write a code to set my turtlebot3 in rviz to the initial pose of the robot in gazebo. I've followed the instructions of the Ros wiki : Writing a simple publisher (http://wiki.ros.org/ROS/Tutorials/Wri...) and the two threads on ros/ask: https://answers.ros.org/question/2053... and https://answers.ros.org/question/1146...
This is my code:
!/usr/bin/env python
import rospy from geometry_msgs.msg import PoseWithCovarianceStamped
rospy.init_node('pub_initpose_node' anonymous=True)
pub = rospy.Pub('/initialpose', PoseWithCovarianceStamped, queue_size=10)
initpose_msg = PoseWithCovarianceStamped()
initpose_msg.header.frame_id = "map"
initpose_msg.pose.pose.position.x=0.0
initpose_msg.pose.pose.position.y=0.0
initpose_msg.pose.pose.position.z=0
initpose_msg.pose.covariance=[0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.25, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06853891945200942]
initpose_msg.pose.pose.orientation.w=1.0
rate = rospy.Rate(10) # 10Hz
while not rospy.is_shutdown():
pub.publish(initpose_msg)
rate.sleep()
When I try to run this node with
rosrun turtlebot3_navigation pub_initpose.py
I get the answer:
*[rosrun] Couldn't find executable named pub_initpose.py below /home/lslabon/catkin_ws/src/turtlebot3/turtlebot3_navigation [rosrun] Found the following, but they're either not files, [rosrun] or not executable: [rosrun] /home/lslabon/catkin_ws/src/turtlebot3/turtlebot3_navigation/rviz/pub_initpose.py*
Why is my code not executable? I tried different ones but got always the same message...
Thanks for your help!
PS: I am using ros melodic on Ubunutu 18.