# Pincer Attachment

### Using platform2 pincer attachment

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

![image](https://user-images.githubusercontent.com/47371441/236552674-41450e72-5fad-4752-8a4d-e8debf7c2a85.png)

### 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.

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

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

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.

### Full example of the pincer class

```
#!/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))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://campus-rover.gitbook.io/lab-notebook/fiiva/pincer_use.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
