-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_trajectory.py
51 lines (45 loc) · 1.64 KB
/
send_trajectory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from IPython import embed
from geometry_msgs.msg import PoseArray
from geometry_msgs.msg import Pose
from tf_conversions import posemath
import PyKDL
import rospy
from dvrk import psm
import numpy as np
import ipdb
posePub = rospy.Publisher(name = 'set_continuous_palpation_trajectory',
data_class = PoseArray,
queue_size = 1)
def send_trajectory(positions, robot):
'''
SEND_TRAJECTORY Sends a trajectory message to a continuous palpation node
Positions is a list of PyKDL vectors. The current orientation is kept
constant.
'''
msg = PoseArray()
msg.header.stamp = rospy.Time.now()
for idx in range(0,len(positions)):
pose = posemath.toMsg(robot.get_current_position())
pose.position.x = positions[idx].x()
pose.position.y = positions[idx].y()
pose.position.z = positions[idx].z()
msg.poses.append(pose)
posePub.publish(msg)
def send_trajectory_relative(positions, robot):
'''
SEND_TRAJECTORY Sends a trajectory message to a continuous palpation node
Positions is a list of PyKDL vectors. The current orientation is kept
constant.
'''
msg = PoseArray()
msg.header.stamp = rospy.Time.now()
for idx in range(0,len(positions)):
pose = posemath.toMsg(robot.get_current_position())
pose.position.x = pose.position.x + positions[idx].x()
pose.position.y = pose.position.y + positions[idx].y()
pose.position.z = pose.position.z + positions[idx].z()
msg.poses.append(pose)
posePub.publish(msg)
if __name__ == '__main__':
robot = psm("PSM1")
embed()