本文整理汇总了Python中trajectory_msgs.msg.JointTrajectoryPoint.velocities[idx]方法的典型用法代码示例。如果您正苦于以下问题:Python JointTrajectoryPoint.velocities[idx]方法的具体用法?Python JointTrajectoryPoint.velocities[idx]怎么用?Python JointTrajectoryPoint.velocities[idx]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trajectory_msgs.msg.JointTrajectoryPoint
的用法示例。
在下文中一共展示了JointTrajectoryPoint.velocities[idx]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: spin
# 需要导入模块: from trajectory_msgs.msg import JointTrajectoryPoint [as 别名]
# 或者: from trajectory_msgs.msg.JointTrajectoryPoint import velocities[idx] [as 别名]
def spin(self):
r = rospy.Rate(1.0/self.dt)
while not rospy.is_shutdown():
if self.req_pos is None:
r.sleep()
continue
self.lock.acquire()
req_vel = copy.deepcopy(self.joint_req_vel)
last_vel_command = copy.deepcopy(self.last_vel_command)
act_position = copy.deepcopy(self.act_position)
#req_pos = copy.deepcopy(self.req_pos)
now = rospy.Time.now()
if last_vel_command is None:
self.lock.release()
r.sleep()
continue
if (now - last_vel_command) > rospy.Duration(0.5):
print "final positions"
print act_position.positions
self.last_vel_command = None
self.lock.release()
r.sleep()
continue
jt = JointTrajectory()
jt.joint_names = self.joint_names
jtp = JointTrajectoryPoint()
jtp.positions = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
jtp.velocities = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
jtp.accelerations = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
#tl = list(self.req_pos.positions)
for idx in range(0,len(req_vel)):
self.req_pos[idx] = self.req_pos[idx] + (req_vel[idx]*self.dt)
jtp.positions[idx] = self.req_pos[idx]
jtp.velocities[idx] = req_vel[idx]
#jtp.accelerations[idx] = 150.0
jt.header.stamp = now
jt.points.append(jtp)
self.lock.release()
self.pub.publish(jt)
r.sleep()