Skip to content

Class six: simple cartesian controller and creating a ROS package

Ariel Anders edited this page Apr 11, 2017 · 1 revision

You will submit your final projects in a new ros package under the lis_pr2_pkg_experimental repository.

Example of how to create a ros package here: http://wiki.ros.org/ROS/Tutorials/CreatingPackage


Interactive Demo! Creating a simple cartesian controller

roslaunch pr2_controller_configuration pr2_jt_controllers.launch  

See more about jt cartesian controller here: http://wiki.ros.org/robot_mechanism_controllers/JTCartesian%20Controller


  • Create a package "ari_simple_cart" depends on "lis_pr2_pkg" catkin_create_pkg ari_simple_cart lis_pr2_pkg

  • include the launch file for pr2_jt_controllers:

      <include file="$(find pr2_controller_configuration)/pr2_jt_controllers.launch" />
    
  • Write simple program that moves arm in small movements relative to current position

from lis_pr2_pkg.uber_controller import Uber from geometry_msgs.msg import Point,Quaternion,PoseStamped, Pose from std_msgs.msg import Header import rospy

rospy.init_node("relative")

uc= Uber()


arm = 'l'
frame = 'base_link'
pub = rospy.Publisher("l_cart/command_pose", PoseStamped, queue_size=1)


def get_pose():
    return uc.return_cartesian_pose(arm, frame)

def stamp_pose( (pos,quat)):
    ps = PoseStamped( 
	        Header(0,rospy.Time(0),frame),\
	        Pose(Point(*pos),\
	        Quaternion(*quat)))
    return ps

def command_delta(x,y,z):
    pos, quat = get_pose()
    pos[0] += x
    pos[1] += y
    pos[2] += z
    cmd = stamp_pose( (pos,quat))
    pub.publish(cmd)

command_delta( 0,0,.05)
command_delta( 0,0,-.05)

Clone this wiki locally