frankaemika / libfranka

C++ library for Franka research robots
https://frankaemika.github.io
Apache License 2.0
232 stars 156 forks source link

Reading RobotState while a controller is running #81

Closed a-z-e-r-i-l-a closed 1 year ago

a-z-e-r-i-l-a commented 4 years ago

I have an implementation of a controller which uses the control method of franka_hw to move the robot.

I have written another node that connects to the robot by franka::Robot robot(robot_ip); and uses robot.readOnce() to see the current state of the robot. However, I noticed that I can't run both of these codes at the same time and a franka::NetworkException´ and ´libfranka: UDP receive: Timeout is raised if I do so.

Is there any way however to read the robot's state while a controller is already running?

LinJianjie commented 1 year ago

ask the same question

marcbone commented 1 year ago

As you said the readOnce cannot be called while controlling the robot. When a controller is running you get the RobotState in the control callback. You can pass it to another thread by protecting it with a mutex. See the joint_impedance_example