Skip to content

Gripper : add states and behavior of gripper#1

Open
zhenyan2001 wants to merge 11 commits intomainfrom
yKhaw/gripper_behavior
Open

Gripper : add states and behavior of gripper#1
zhenyan2001 wants to merge 11 commits intomainfrom
yKhaw/gripper_behavior

Conversation

@zhenyan2001
Copy link

add states and behavior of the gripper

@zhenyan2001 zhenyan2001 force-pushed the yKhaw/gripper_behavior branch from ab795df to ea19094 Compare January 31, 2026 18:57
Copy link
Contributor

@MatteoTschesche MatteoTschesche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work, I have some comments

# See the License for the specific language governing permissions and
# limitations under the License.

"""Demonstration state."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

from gigatino_msgs.action import Calibrate
class CalibratetoOrigin(EventState):
"""
This state navigates the robot to the given pose using NavigateToPose messages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not sound like calibrate

-- action_topic Name of action to invoke

Outputs
<= home reached Robot reached pose successful.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does not sound like calibration

"""
def __init__(self, timeout,action_topic='robotinobase2/gigatino/calibrate'):

super().__init__(outcomes=['pose_reached', 'failed', 'canceled', 'timeout'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't the outcome be calibrated instead of pose_reached?


if not self._client.has_result(self._topic):
self._client.cancel(self._topic)
Logger.loginfo('Cancelled active action goal.') No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No newline at end of file

self._return = 'reached'
return self._return
if self._node.get_clock().now().nanoseconds - self._start_time.nanoseconds > self._target_time.nanoseconds:
# Normal completion, do not bother repeating the publish
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf is this comment? xD

User data
># relative set default as false
># target_frame Frame of the goal pose
># x X value of goal pose
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this pose only use the z value?

return self._return

if self._client.has_result(self._topic):
_ = self._client.get_result(self._topic) # The delta result value is not useful here
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments here

self._return = 'reached'
return self._return
if self._node.get_clock().now().nanoseconds - self._start_time.nanoseconds > self._target_time.nanoseconds:
# Normal completion, do not bother repeating the publish
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here again?

try:
self._client.send_goal(self._topic, goal, wait_duration=self._timeout_sec)
Logger.localinfo(f"{goal}")
except Exception as exc: # pylint: disable=W0703
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what thoes this comment mean? Also you can remove the others below

@sambertibus99
Copy link

I think you can merge the GripperCloseState() and the GripperState() to one State. As an input you would give then something like command instead of open or close as key. So you can specify over the value which action should be called.
When I look in the exsting code I guess you can already use one of the states mentioned above and delete the other one. Because you only check if the key exist and not what the value is.
if 'open' not in userdata: self._error = True Logger.logwarn("ExampleActionState requires data") return goal = Gripper.Goal()

So as far as I can see you then just execute the action with the key passed by user:
# Send the goal. try: self._client.send_goal(self._topic, goal, wait_duration=self._timeout_sec) except Exception as exc: # pylint: disable=W0703 # Since a state failure not necessarily causes a behavior failure, # it is recommended to only print warnings, not errors. # Using a linebreak before appending the error log enables the operator to collapse details in the GUI. Logger.logwarn(f"Failed to send the RotateAbsolute command:\n {type(exc)} - {exc}") self._error = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants