Hello guys, I made a node to let de go1 walk in a cricle, however after I kill the node with ctrl-c the robot keeps walking circles. Before I run my node I use roslaunch go1_bringup bringup.launch so my node can publish messages into the cmd_vel topic. this is my code:
#!/usr/bin/env python3 import rospy from geometry_msgs.msg import Twist def clean_shutdown(): #Stop robot when shutting down msg.linear.x = 0.0 msg.angular.z = 0.0 pub.publish(msg) print(pub) print ("Go1 shutting down") if __name__== "__main__": rospy.init_node("walk_circle") rospy.loginfo("walk_circle node has started.") pub = rospy.Publisher("cmd_vel", Twist, queue_size=10) rate = rospy.Rate(2) msg = Twist() while not rospy.is_shutdown(): msg.linear.x = 0.3 msg.angular.z = 1.5 pub.publish(msg) rate.sleep() rospy.loginfo("while loop exit") rospy.signal_shutdown("Shutdown requested.") clean_shutdown()
The clean_shutdown function does actually run when I press ctrl+c, but the updated node doesn’t seem to be being published. What I’m trying to do is make the go1 stop when killing the “walk_circle” node and in the future preferably with a command ofcourse.