Bye Bye Moore

PoCソルジャーな零細事業主が作業メモを残すブログ

xArmにROS環境をつくる その3:rospy

実際のところ

$ rosservice list
/rosout/get_loggers
/rosout/set_logger_level
・・・
/xarm/vacuum_gripper_set
/xarm/velo_move_joint
/xarm/velo_move_line
/xarm/xarm_driver/get_loggers
/xarm/xarm_driver/set_logger_level
$ rosservice type /xarm/move_joint
xarm_msgs/Move
$ rossrv show xarm_msgs/Move
float32[] pose
float32 mvvelo
float32 mvacc
float32 mvtime
float32 mvradii
---
int16 ret
string message
#!/usr/bin/env python
import rospy
from xarm_msgs.srv import Move

rospy.wait_for_service('/xarm/move_joint')
response = rospy.ServiceProxy('/xarm/move_joint', Move)

res = response( [0,   0,   0,0,0,0], 0.35, 7, 0, 0 )
res = response( [0.1, 0,   0,0,0,0], 0.35, 7, 0, 0 )
res = response( [0.1, 0.1, 0,0,0,0], 0.35, 7, 0, 0 )
res = response( [0,   0,   0,0,0,0], 0.35, 7, 0, 0 )

print(res)

以上ではメンテ性が悪すぎるのでパラメータをバラします

#!/usr/bin/env python

import rospy
from xarm_msgs.srv import Move

rospy.wait_for_service('/xarm/move_joint')

payload = Move
payload.pose     = [0.0,0,0,0,0,0]
payload.mvvelo   = 0.35
payload.mvacc    = 7
payload.mvtime   = 0
payload.mvradii  = 0

response = rospy.ServiceProxy('/xarm/move_joint', Move)

res = response(payload.pose, payload.mvvelo, payload.mvacc, payload.mvtime, payload.mvradii)


payload.pose = [0.1, 0, 0,0,0,0]
res = response(payload.pose, payload.mvvelo, payload.mvacc, payload.mvtime, payload.mvradii)

payload.pose[1] = 0.1
res = response(payload.pose, payload.mvvelo, payload.mvacc, payload.mvtime, payload.mvradii)

print(res)