Robotics StackExchange | Archived questions

Turtlebot does not publish velocity node. The bot doesnt move

I am new to ROS and am following tutorials.Everything has worked perfectly fine till the turtlebot bringup. However when I am running a simple python code to draw a square(see below) import rospy from geometry_msgs.msg import Twist from math import radians

class DrawASquare():

def __init__(self):
    # initiliaze
    rospy.init_node('drawasquare', anonymous=False)

    # What to do you ctrl + c    
    rospy.on_shutdown(self.shutdown)

    self.cmd_vel = rospy.Publisher('cmd_vel_mux/input/navi', Twist, queue_size=10)
# 5 HZ
    r = rospy.Rate(5);
# create two different Twist() variables.  One for moving forward.  One for turning 45 degrees.

    # let's go forward at 0.2 m/s
    move_cmd = Twist()
    move_cmd.linear.x = 0.2
# by default angular.z is 0 so setting this isn't required

    #let's turn at 45 deg/s
    turn_cmd = Twist()
    turn_cmd.linear.x = 0
    turn_cmd.angular.z = radians(45); #45 deg/s in radians/s // 1.5708 radians(45)

#two keep drawing squares.  Go forward for 2 seconds (10 x 5 HZ) then turn for 2 second
count = 0
    while (not (rospy.is_shutdown()) and count < 5):
        rospy.loginfo("Going Straight")
        for x in range(0,20):
           self.cmd_vel.publish(move_cmd)
           r.sleep()  
    # turn 90 degrees
    rospy.loginfo("Turning")
        for x in range(0,10): # time has non linear transform . Angle= rate * angle per second
           self.cmd_vel.publish(turn_cmd)
           r.sleep() 
    count = count + 1
    if(count % 4==0): 
           rospy.loginfo("TurtleBot should be close to the original starting position (but it's probably way off)")


def shutdown(self):
    # stop turtlebot
    rospy.loginfo("Stop Drawing")
    self.cmd_vel.publish(Twist())
    rospy.sleep(1)

if name == 'main': try: DrawASquare() except: rospy.loginfo("node terminated.")

the terminal is giving me the output correct output

[INFO] [WallTime: 1464972316.780542] Going Straight [INFO] [WallTime: 1464972320.780868] Turning [INFO] [WallTime: 1464972323.180919] Going Straight ^C[INFO] [WallTime: 1464972326.380775] Stop Drawing [INFO] [WallTime: 1464972328.126076] Turning ^Cturtlebot@turtlebot1:~/turtlebot$ python drawasquare.py [INFO] [WallTime: 1464974923.646459] Going Straight [INFO] [WallTime: 1464974927.646840] Turning [INFO] [WallTime: 1464974930.046803] Going Straight [INFO] [WallTime: 1464974934.046856] Turning [INFO] [WallTime: 1464974936.446891] Going Straight [INFO] [WallTime: 1464974940.446869] Turning [INFO] [WallTime: 1464974942.846905] Going Straight [INFO] [WallTime: 1464974946.846854] Turning [INFO] [WallTime: 1464974949.246856] TurtleBot should be close to the original starting position (but it's probably way off) [INFO] [WallTime: 1464974949.247515] Going Straight [INFO] [WallTime: 1464974953.246847] Turning [INFO] [WallTime: 1464974955.647318] Stop Drawing turtlebot@turtlebot1:~/turtlebot$ python drawasquare.py [INFO] [WallTime: 1464974985.363926] Going Straight [INFO] [WallTime: 1464974989.364275] Turning [INFO] [WallTime: 1464974991.764251] Going Straight [INFO] [WallTime: 1464974995.764257] Turning [INFO] [WallTime: 1464974998.164311] Going Straight [INFO] [WallTime: 1464975002.164276] Turning [INFO] [WallTime: 1464975004.564348] Going Straight [INFO] [WallTime: 1464975008.564305] Turning [INFO] [WallTime: 1464975010.964148] TurtleBot should be close to the original starting position (but it's probably way off) [INFO] [WallTime: 1464975010.964686] Going Straight [INFO] [WallTime: 1464975014.964331] Turning [INFO] [WallTime: 1464975017.364785] Stop Drawing turtlebot@turtlebot1:~/turtlebot$ python drawasquare.py [INFO] [WallTime: 1464975280.145368] Going Straight [INFO] [WallTime: 1464975284.145799] Turning [INFO] [WallTime: 1464975286.545749] Going Straight [INFO] [WallTime: 1464975290.545725] Turning ^C[INFO] [WallTime: 1464975291.530313] Stop Drawing

however the bot is not moving. I tried reintalling ubuntu and directly running the code from the laptop on top of the turtlebot(to make sure that he issue is not regarding the network config). I have trying out a few solutions I found online(http://answers.ros.org/question/173516/turtlebot-is-not-moving-with-published-messages-on-cmd_vel/) ,I realized that the bot is not publishing the velocity information. Could anybody please guide me and tell me how to fix it.

turtlebot@turtlebot1:~/turtlebot$ rostopic list /capabilityserver/bonds /capabilityserver/events /cmdvelmux/active /cmdvelmux/input/navi /cmdvelmux/input/safetycontroller /cmdvelmux/input/teleop /cmdvelmux/parameterdescriptions /cmdvelmux/parameterupdates /diagnostics /diagnosticsagg /diagnosticstoplevelstate /gateway/forceupdate /gateway/gatewayinfo /hello /info /interactions/interactiveclients /interactions/pairing /jointstates /mobilebase/commands/controllerinfo /mobilebase/commands/digitaloutput /mobilebase/commands/externalpower /mobilebase/commands/led1 /mobilebase/commands/led2 /mobilebase/commands/motorpower /mobilebase/commands/resetodometry /mobilebase/commands/sound /mobilebase/commands/velocity /mobilebase/controllerinfo /mobilebase/debug/rawcontrolcommand /mobilebase/debug/rawdatacommand /mobilebase/debug/rawdatastream /mobilebase/events/bumper /mobilebase/events/button /mobilebase/events/cliff /mobilebase/events/digitalinput /mobilebase/events/powersystem /mobilebase/events/robotstate /mobilebase/events/wheeldrop /mobilebase/sensors/bumperpointcloud /mobilebase/sensors/core /mobilebase/sensors/dockir /mobilebase/sensors/imudata /mobilebase/sensors/imudataraw /mobilebase/versioninfo /mobilebasenodeletmanager/bond /odom /rosout /rosoutagg /tf /tfstatic /turtlebot/incompatiblerapplist /turtlebot/rapplist /turtlebot/status /zeroconf/lostconnections /zeroconf/newconnections turtlebot@turtlebot1:~/turtlebot$ rostopic echo /turtlebotnode/cmdvelmux WARNING: topic [/turtlebotnode/cmdvelmux] does not appear to be published yet turtlebot@turtlebot1:~/turtlebot$ rostopic echo /cmdvelmux WARNING: topic [/cmdvelmux] does not appear to be published yet ^Cturtlebot@turtlebot1:~/turtlebot$ rosnode list /appmanager /bumper2pointcloud /capabilityserver /capabilityservernodeletmanager /cmdvelmux /diagnosticaggregator /interactions /master /mobilebase /mobilebasenodeletmanager /robotstatepublisher /rosout /rostopic165621464971930537 /zeroconf/zeroconf turtlebot@turtlebot1:~/turtlebot$ rostopic list /capabilityserver/bonds /capabilityserver/events /cmdvelmux/active /cmdvelmux/input/navi /cmdvelmux/input/safetycontroller /cmdvelmux/input/teleop /cmdvelmux/parameterdescriptions /cmdvelmux/parameterupdates /diagnostics /diagnosticsagg /diagnosticstoplevelstate /gateway/forceupdate /gateway/gatewayinfo /hello /info /interactions/interactiveclients /interactions/pairing /jointstates /mobilebase/commands/controllerinfo /mobilebase/commands/digitaloutput /mobilebase/commands/externalpower /mobilebase/commands/led1 /mobilebase/commands/led2 /mobilebase/commands/motorpower /mobilebase/commands/resetodometry /mobilebase/commands/sound /mobilebase/commands/velocity /mobilebase/controllerinfo /mobilebase/debug/rawcontrolcommand /mobilebase/debug/rawdatacommand /mobilebase/debug/rawdatastream /mobilebase/events/bumper /mobilebase/events/button /mobilebase/events/cliff /mobilebase/events/digitalinput /mobilebase/events/powersystem /mobilebase/events/robotstate /mobilebase/events/wheeldrop /mobilebase/sensors/bumperpointcloud /mobilebase/sensors/core /mobilebase/sensors/dockir /mobilebase/sensors/imudata /mobilebase/sensors/imudataraw /mobilebase/versioninfo /mobilebasenodeletmanager/bond /odom /rosout /rosoutagg /tf /tfstatic /turtlebot/incompatiblerapplist /turtlebot/rapplist /turtlebot/status /zeroconf/lostconnections /zeroconf/newconnections

Asked by arpit901 on 2016-06-03 13:06:36 UTC

Comments

Answers