publishing to /cmd_vel gives error
hey everyone,
i am trying to let my jackal drive with this custom node :
#! /usr/bin/env python
import rospy
from geometry_msgs.msg import Twist
from sensor_msgs.msg import LaserScan
def callback(msg):
seconds = rospy.get_time()
if int(seconds) % 3 == 0:
move.linear.x = 0
move.linear.y = 1
move.angular.z = 0
elif int(seconds+1) % 3 == 0:
move.linear.x = 0
move.angular.z = -0
else:
move.linear.x = -2
move.angular.z = -2
pub.publish(move)
rospy.init_node('sub_node')
sub = rospy.Subscriber('/kobuki/laser/scan', LaserScan, callback)
pub = rospy.Publisher('/cmd_vel',Twist,queue_size=10)
move = Twist()
rospy.spin()
however it returns the error : /clock not being published
etc. you probably know the error.
but /clock definetely is running, and my jackal isnt moving. rostopic info /cmd_vel does state its subscribing the node i want. maybe its worth it to state that this script DOES work with the turtlebot in gazebo.
greetings girpon
Asked by girpon on 2018-11-14 07:50:53 UTC
Answers
First of all, your code does not seem to be properly indented.
Did you check if the result of rosparam get use_sim_time
is false
? If not please try rosparam set use_sim_time false
and look if it works.
Asked by dhindhimathai on 2018-11-14 08:43:48 UTC
Comments
Rather strangely you code will only publish a cmd_vel message when it receives a LaserScan message. So my first though is that there are no LaserScan messages being published and therefore no cmd_vel Twist messages.
Asked by PeteBlackerThe3rd on 2018-11-14 09:30:17 UTC
I second @PeteBlackerThe3rd about no laser data being published, it probably works with the turtlebot because you subscribe to the topic
/kobuki/something
,kobuki
being the mobile base of the turtlebot but not related to the jackal robot.Asked by Delb on 2018-11-15 04:11:53 UTC