pantor / frankx

High-Level Motion Library for Collaborative Robots
https://pantor.github.io/frankx/
GNU Lesser General Public License v3.0
257 stars 62 forks source link

Get state while moving #32

Open guenhael opened 2 years ago

guenhael commented 2 years ago

Hello,

Is there any way to get information like the pose or the "active waypoint" while the robot is moving? It would be very useful.

I tried to do it with Robot.move_async and then Robot.read_once() but it's not permitted.

Thank you for your help.

yuchen93 commented 2 years ago

Following this! I'd like to be able to record robot poses while it is moving.

Toni-SM commented 2 years ago

Hi, Following this too!

guenhael commented 2 years ago

Hello,

For your information, a solution has been programmed and can be found here : https://github.com/guenhael/frankx/tree/get_O_T_EE_while_moving

A pull request has been done to add this update to the official frankx library.

If you have any suggestion of improvement, let me know.

Toni-SM commented 1 year ago

Hi,

A solution for getting the robot state while moving, for all supported motions types can be found in the pull request https://github.com/pantor/frankx/pull/44

With this modification it is possible to get the state of the robot (stopped or in motion) by calling the original API as follow

robot = Robot("172.16.0.2")

# Get the current state handling the read exception when the robot is in motion
try:
    robot_state = robot.get_state()
except frankx.InvalidOperationException:
    robot_state = robot.get_state(read_once=False)

# Get the current pose handling the read exception when the robot is in motion
try:
    pose = robot.current_pose()
except frankx.InvalidOperationException:
    pose = robot.current_pose(read_once=False)

# Get the current joint positions handling the read exception when the robot is in motion
try:
    joint_positions = robot.current_joint_positions()
except frankx.InvalidOperationException:
    joint_positions = robot.current_joint_positions(read_once=False)

It use has been tested in a reinforcement learning application as exemplified in the skrl - Real-world examples documentation

lushihan commented 1 year ago

Following this!

carloLV commented 1 year ago

I am also following this. It would be nice to know the results of the PRs.