ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

move baxter end effector position regardless of orientation

asked 2017-04-10 08:15:52 -0500

Glass_Eater gravatar image

updated 2017-04-11 08:09:01 -0500

I downloaded these codes from the link

first code import argparse import sys

import rospy

from geometry_msgs.msg import (
from std_msgs.msg import Header

from baxter_core_msgs.srv import (

def ik_solve(limb, pos, orient):
    #~ rospy.init_node("rsdk_ik_service_client")
    ns = "ExternalTools/" + limb + "/PositionKinematicsNode/IKService"
    iksvc = rospy.ServiceProxy(ns, SolvePositionIK)
    ikreq = SolvePositionIKRequest()
    print "iksvc: ", iksvc
    print "ikreq: ", ikreq
    hdr = Header(, frame_id='base')
    poses = {
        str(limb): PoseStamped(header=hdr,
            pose=Pose(position=pos, orientation=orient))}

        rospy.wait_for_service(ns, 5.0)
        resp = iksvc(ikreq)
    except (rospy.ServiceException, rospy.ROSException), e:
        rospy.logerr("Service call failed: %s" % (e,))
        return 1
    if (resp.isValid[0]):
        print("SUCCESS - Valid Joint Solution Found:")
        # Format solution into Limb API-compatible dictionary
        limb_joints = dict(zip(resp.joints[0].name, resp.joints[0].position))
        print limb_joints
        return limb_joints
        print("INVALID POSE - No Valid Joint Solution Found.")

    return -1

The second code

import baxter_interface
import baxter_external_devices
import rospy
import ik_solver
from geometry_msgs.msg import (    

# Moves relative to current Position
def moveRel(x,y,z):
    pose = left.endpoint_pose()
    print "current pose: ", pose
    curX = pose["position"].x
    curY = pose["position"].y
        curZ = pose["position"].z
    newX = curX + x
    newY = curY + y
    newZ = curZ + z
    loc = Point(newX,newY,newZ)
    print "loc: ", loc    
    faceDown = Quaternion( 0.0, 0.0, 0.5, 0.0)
    #print "orient: ", faceDown
    limb_joints = ik_solver.ik_solve('left', loc, faceDown)
    prev = loc
    if limb_joints != -1:
        print "limb_joints: ", limb_joints
        print "moving arm to limb_joints joints"

# Takes a Point()
def moveTo(goal):
    loc = goal
    faceDown = Quaternion( 0.0, 0.0, 0.5, 0.0)
    #print "loc: ", loc    
    #print "orient: ", orient[1]
    limb_joints = ik_solver.ik_solve('left', loc, faceDown)
    prev = loc
    if limb_joints != -1:
        #print "limb_joints: ", limb_joints
        #print "moving arm to goal limb_joints joints"
        print "  "
        print "  "
        print "  "

rs = baxter_interface.RobotEnable()

left = baxter_interface.Limb('left')
leftGripper = baxter_interface.Gripper('left')
pose = left.endpoint_pose()
b = True
pos = pose.popitem()
orient = pose.popitem()
prev = pos[1]


print "-----------------------------------"
pose = left.endpoint_pose()
print "current pose: ", pose
s = raw_input("Press q to run ... ")
if s == 'q':
    moveTo(Point(-0.008758931559827073, 0.4037057092838424, 1.1405580898861356))
    print left.endpoint_pose()

The second code has a function moveTo where you put the position of the end effector and it moves there but you also have to put the orientation which is a quaternion. I don’t completely understand how the orientation works so I want to ask if there is a way to only put the position of the I want the end effector to be at without having to use the orientation.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2017-04-10 13:01:14 -0500

Airuno2L gravatar image

It is easier if you input a roll pitch yaw and convert that into a quaternion. The tf.transformations library has the function quaternion_from_euler that does just that.

Being able to input just a position, without an orientation requires a special kind of inverse kinematics solver, I'm not sure what kind they're using so I'm not sure if it's (easily) possible.

edit flag offensive delete link more

answered 2017-04-10 22:35:53 -0500

Try to use the move it planner, and perform a cartesian to robot joint angles transformation. That would give you your destination and origin position as you need in whichever orientation. Alternatively, you can also use the move it planner and simulate your desired location and orientation, and copy the points from there into your program.

It is ideal to use a transformation from cartesian to robot joint angles. If you are sending raw points it will always have every joint moving, and you cannot really isolate each joint movements.

Maybe you can provide your code location ( the link you have given takes me to the brr google group), and then the actual intent of the code could be realized. Also, I would always prefer using moveit library (just a personal choice) as it gives you access to all sorts of planners including IK.

Also what is your application intent?

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-04-10 08:15:52 -0500

Seen: 1,168 times

Last updated: Apr 11 '17