const_dist_move.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #coding=utf-8
3 
4 """
5 This program makes xbot automnomous get the target point in map. The main funcution is testing the base movements of xbot such as moving forward and rotating.
6 Copyright (c) 2016 Peng Wang (Rocwang). All rights reserved.
7 This program is free software; you can redistribute or modify it.
8 More details about xbot robot platform is available in http://wiki.ros.org/Robots/Xbot.
9 """
10 
11 import rospy, sys, termios, tty, math, time, cv2, numpy, PyKDL
12 from geometry_msgs.msg import Twist
13 from std_msgs.msg import String
14 from nav_msgs.msg import Odometry
15 from geometry_msgs.msg import PointStamped,Point
16 from geometry_msgs.msg import Quaternion
17 
18 
19 alfa=0.1
20 beta=0.31415926/5
21 class LoopControl(object):
22  """docstring for LoopControl"""
23  def __init__(self):
24  self.help="""
25 
26  """
27  # if rospy.has_param("~cascPath"):
28  # self.cascPath = rospy.get_param("~cascPath")
29  # else:
30  # rospy.set_param("~cascPath","../scripts/haarcascade_frontalface_default.xml")
31  self.control_pub=rospy.Publisher('/cmd_vel_mux/input/teleop', Twist, queue_size = 1)
32  rospy.Subscriber("odom",Odometry,self.odom_callback)
33  self.target=PointStamped()
34  rospy.spin()
35 
36 
37 
38 
39  def odom_callback(self,odom):
40  cmd=Twist()
41  dx=0-odom.pose.pose.position.x
42  dy=0-odom.pose.pose.position.y
43  cmd.linear.x=alfa*dx
44  cmd.angular.z=0#beta*dy
45  self.control_pub.publish(cmd)
46 
47 
48 
49 
50 
51 
52 
53 
54 if __name__ == '__main__':
55  rospy.init_node('loop_control')
56  try:
57  rospy.loginfo('initialization system for loop control...')
58  LoopControl()
59  print 'process loop control done and quit.'
60  except rospy.ROSInterruptException:
61  rospy.loginfo('node loop_control termindated.')
62 
63 
64 
65 
66 


xbot_tools
Author(s):
autogenerated on Sat Oct 10 2020 03:28:22