make_circle.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # Software License Agreement (BSD License)
3 #
4 # Copyright (c) 2017 Svenzva Robotics
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above
14 # copyright notice, this list of conditions and the following
15 # disclaimer in the documentation and/or other materials provided
16 # with the distribution.
17 # * Neither the name of University of Arizona nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 
34 
35 import rospy
36 import rospkg
37 import math
38 from sensor_msgs.msg import JointState
39 from geometry_msgs.msg import Twist
40 
41 """
42 This demonstration controls the end effector to move in a circle through cartesian velocity commands
43 To control the end effector through cartesian velocity, the robot must be in velocity mode.
44 
45 """
46 
48  global vel_pub
49  i = 0
50  angle_resolution = 5
51  d_angle = angle_resolution*3.14/180
52  angle= 0
53  radius = 10
54  x_center = 0
55  y_center = 0
56  twst_cmd = Twist()
57  rospy.loginfo("Sending velocity commands.")
58  while i < (360/angle_resolution):
59  angle+= d_angle;
60  ee_x = x_center + radius*math.cos(angle);
61  ee_y = y_center + radius* math.sin(angle);
62  twst_cmd.linear.x = ee_x
63  twst_cmd.linear.z = ee_y
64  vel_pub.publish(twst_cmd)
65  rospy.loginfo(twst_cmd)
66  rospy.sleep(0.05)
67  i+=1
68  vel_pub.publish(Twist())
69 
70 def setup():
71  global vel_pub
72  rospy.init_node('revel_circular_eef', anonymous=False)
73 
74  vel_pub = rospy.Publisher('/revel/eef_velocity', Twist, queue_size=1)
75  #joint_states_sub = rospy.Subscriber('/joint_states', JointState, js_cb, queue_size=1)
76 
77  rospy.loginfo("Setting up Revel Circle Movement program")
78 
79 if __name__ == '__main__':
80  try:
81  setup()
83  except rospy.ROSInterruptException:
84  pass
def send_movement_cmds()
Definition: make_circle.py:47
def setup()
Definition: make_circle.py:70


svenzva_demo
Author(s): Max Svetlik
autogenerated on Wed Oct 28 2020 03:31:24