Ask Your Question
0

publishing to /cmd_vel gives error

asked 2018-11-14 06:50:53 -0500

girpon gravatar image

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

edit retag flag offensive close merge delete

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.

PeteBlackerThe3rd gravatar imagePeteBlackerThe3rd ( 2018-11-14 08:30:17 -0500 )edit

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.

Delb gravatar imageDelb ( 2018-11-15 03:11:53 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-14 07:43:48 -0500

dhindhimathai gravatar image

updated 2018-11-14 07:46:15 -0500

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-11-14 06:50:53 -0500

Seen: 69 times

Last updated: Nov 14 '18