arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Pincer Attachment

How to use pincer attachment on platform2

hashtag
Using platform2 pincer attachment

In order to use the pincer attachment, you must have a way publish to the servo motor.

image

hashtag
Publisher

First, you must import Bool. True will be to open the attachment, and False will be to close the attachment.

from std_msgs.msg import Bool

The following publisher needs to be published to:

rospy.Publisher('/servo', Bool, queue_size=1)

By publishing to the servo motor, you are telling it to either open or close. If you publish True, the pincer will open. If you publish False, the pincer will close.

This has use beyond this pincer itself. By having any custom attachment with a servo motor, this provides an easy way to publish to it.

hashtag
Full example of the pincer class

def open():
    self.pub.publish(Bool(True))

def close():
    self.pub.publish(Bool(False))
#!/usr/bin/env python3

import rospy
from std_msgs.msg import Bool

class Pincer:
    """ Allows pincer to open and close """

    def __init__(self):
        self.pub = rospy.Publisher('/servo', Bool, queue_size=1)

    def open(self):
        self.pub.publish(Bool(True))

    def close(self):
        self.pub.publish(Bool(False))