本文整理匯總了Python中geometry_msgs.msg.Twist.x方法的典型用法代碼示例。如果您正苦於以下問題:Python Twist.x方法的具體用法?Python Twist.x怎麽用?Python Twist.x使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類geometry_msgs.msg.Twist
的用法示例。
在下文中一共展示了Twist.x方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: wheel_odom_callback
# 需要導入模塊: from geometry_msgs.msg import Twist [as 別名]
# 或者: from geometry_msgs.msg.Twist import x [as 別名]
def wheel_odom_callback(data):
(x,y) = (data.pose.pose.position.x, data.pose.pose.position.y)
o = data.pose.pose.orientation
yaw = tf.transformations.euler_from_quaternion((o.x, o.y, o.z, o.w))[2]
wheel_odom.append((data.header.stamp,x,y,yaw))
def imu_callback(data):
o = data.orientation
yaw = tf.transformations.euler_from_quaternion((o.x, o.y, o.z, o.w))[2]
imu.append((data.header.stamp,yaw))
if __name__ == '__main__':
rospy.init_node('odometry_debug')
rospy.Subscriber('wheel_odom', Odometry, wheel_odom_callback)
rospy.Subscriber('imu_data', Imu, imu_callback)
rospy.Subscriber('odom', Odometry, odom_callback)
pub_cmd_vel = rospy.Publisher('cmd_vel', Twist)
# move in a straight line forward for one second
print "moving in a straight line forward at .5 m/s for 2 sec"
t = Twist()
t.x = 0.5
for i in range(0,20):
pub_cmd_vel.publish(t)
rospy.sleep(.1)
print_results()