-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
115 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
import os | ||
import sys | ||
import socket | ||
import rospy | ||
from robotiq_control.cmodel_base import RobotiqCModel, ComModbusRtu | ||
from robotiq_msgs.msg import CModelCommand, CModelStatus | ||
|
||
def mainLoop(device): | ||
# Gripper is a C-Model with a TCP connection | ||
gripper = RobotiqCModel() | ||
gripper.client = ComModbusRtu() | ||
# We connect to the device name received as an argument | ||
rospy.loginfo("Connecting to device " + str(device)) | ||
gripper.client.connectToDevice(device) | ||
# The Gripper status | ||
pub = rospy.Publisher('status', CModelStatus, queue_size=3) | ||
# The Gripper command | ||
rospy.Subscriber('command', CModelCommand, gripper.refreshCommand) | ||
|
||
while not rospy.is_shutdown(): | ||
# Get and publish the Gripper status | ||
status = gripper.getStatus() | ||
pub.publish(status) | ||
# Wait a little | ||
rospy.sleep(0.05) | ||
# Send the most recent command | ||
gripper.sendCommand() | ||
# Wait a little | ||
rospy.sleep(0.05) | ||
|
||
if __name__ == '__main__': | ||
rospy.init_node('cmodel_rtu_driver') | ||
# Run the main loop | ||
try: | ||
mainLoop(sys.argv[1]) | ||
except rospy.ROSInterruptException: pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters