mirror of
https://github.com/elephantrobotics/mycobot_ros.git
synced 2026-07-05 19:47:04 +00:00
fix: Service cannot process error.
This commit is contained in:
parent
6d368d1c07
commit
21731507cf
7 changed files with 34 additions and 6 deletions
|
|
@ -25,6 +25,7 @@ add_service_files(FILES
|
|||
GetCoords.srv
|
||||
SetCoords.srv
|
||||
GripperStatus.srv
|
||||
PumpStatus.srv
|
||||
)
|
||||
|
||||
## Generate added messages and services
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ def create_services():
|
|||
rospy.Service('set_joint_coords', SetCoords, set_coords)
|
||||
rospy.Service('get_joint_coords', GetCoords, get_coords)
|
||||
rospy.Service('switch_gripper_status', GripperStatus, switch_status)
|
||||
rospy.Service('switch_pump_status', PumpStatus, toggle_pump)
|
||||
rospy.loginfo('ready')
|
||||
rospy.spin()
|
||||
|
||||
|
|
@ -42,6 +43,8 @@ def set_angles(req):
|
|||
if mc:
|
||||
mc.send_angles(angles, sp)
|
||||
|
||||
return SetAnglesResponse(True)
|
||||
|
||||
|
||||
def get_angles(req):
|
||||
if mc:
|
||||
|
|
@ -63,6 +66,8 @@ def set_coords(req):
|
|||
|
||||
if mc:
|
||||
mc.send_coords(coords, sp, mod)
|
||||
|
||||
return SetCoordsResponse(True)
|
||||
|
||||
|
||||
def get_coords(req):
|
||||
|
|
@ -78,6 +83,20 @@ def switch_status(req):
|
|||
else:
|
||||
mc.set_gripper_state(1, 80)
|
||||
|
||||
return GripperStatusResponse(True)
|
||||
|
||||
|
||||
def toggle_pump(req):
|
||||
if mc:
|
||||
if req.Status:
|
||||
mc.set_basic_output(2, 0)
|
||||
mc.set_basic_output(5, 0)
|
||||
else:
|
||||
mc.set_basic_output(2, 1)
|
||||
mc.set_basic_output(5, 1)
|
||||
|
||||
return PumpStatusResponse(True)
|
||||
|
||||
|
||||
robot_msg = '''
|
||||
MyCobot Status
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
---
|
||||
|
||||
float32 joint_1
|
||||
float32 joint_2
|
||||
float32 joint_3
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
bool Status
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
bool Flag
|
||||
5
srv/PumpStatus.srv
Normal file
5
srv/PumpStatus.srv
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
bool Status
|
||||
|
||||
---
|
||||
|
||||
bool Flag
|
||||
|
|
@ -7,4 +7,6 @@ float32 joint_6
|
|||
|
||||
int8 speed
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
bool Flag
|
||||
|
|
@ -8,4 +8,6 @@ float32 rz
|
|||
int8 speed
|
||||
int8 model
|
||||
|
||||
---
|
||||
---
|
||||
|
||||
bool Flag
|
||||
Loading…
Add table
Reference in a new issue