本文整理汇总了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()