Closed DejanDj79 closed 9 months ago
Why would you want to do it that way? I'm not sure whether I understand. As far as I understand, you have a gripper that is being controlled by setting digital_output[0]
to 0 or 1 respectively.
You could directly set the digital output using the service /ur_hardware_interface/set_io
. From the command line this would be
rosservice call /ur_hardware_interface/set_io "fun: 1
pin: 0
state: 1.0"
With this, you could obviously still create a function called openAndCliseGripper()
that sets the output once to 0 and then to 1.
Whel I contacted onrobot regarding issues that I have and they told me that they dont have anything developed for ROS regarding gripper, and also suggest that I can control gripper by creating thread on teach pendant and then activate/deactivate thread by sending signals to digital_out pins. For me it is not important how I will achieve that, only important thing is to control gripper from ROS and python without using teach pendant so if there is another way you can suggest it. It is also important to do it in a way that will not kill main program so the gripper can close and open between each position.
@masterdeki As far as I understand, calling the set_io
service as explained above would be sufficient in your use case right?
@masterdeki As far as I understand, calling the
set_io
service as explained above would be sufficient in your use case right?
It is, for setting digital out to 1, but still remains question how to activate thread from python.
@masterdeki your thread made on the UR teach pendant is started when you start the robot program. In addition, it by default also runs in a while loop, unless you have disabled it.
Here is an example:
This results in the following urscript code: (when you save the program, it also saves a .script files)
You can see run Thread_1()
is called to start the thread, right after the thread is defined.
The sync()
call makes the while loop sleep until next time step. This prevents it spinning multiple rounds within one time step. You can also use a wait node.
Hope this helps you forward.
I created program on teach pendant like you show me, but what's next? Should I send this .script file to robot controller over python? When i run program on teach pendant i get error that it cant connect to laptops ip address.There is also a error that gripperState is not initialized in variable setup. What value should gripperState have in initialization?
To add on to what @fmauch was saying: I am not quite sure why you want to use urscript to control the gripper. If you only need to toggle two I/Os to control the gripper you can do that without problems with the set_io
service and don't need to make any changes on the urscript side.
As to your errors:
gripperState
variable in the variables setup. Typically i would expect the gripper to open on startup (so True
) and add a set_standard_digital_out(3, True)
to the beginning of the thread (making sure that you are in the correct state at the beginning of the program), but this depends on what you want.To add on to what @fmauch was saying: I am not quite sure why you want to use urscript to control the gripper. If you only need to toggle two I/Os to control the gripper you can do that without problems with the
set_io
service and don't need to make any changes on the urscript side.As to your errors:
- Did you start the ros driver beforehand? You need to start the ros driver before the program on the teach pendant so this error would be expected.
- You need to setup the
gripperState
variable in the variables setup. Typically i would expect the gripper to open on startup (soTrue
) and add aset_standard_digital_out(3, True)
to the beginning of the thread (making sure that you are in the correct state at the beginning of the program), but this depends on what you want.
Hi all. I'm trying to control UR5e from python and I managed to make python script that controls arm in a way that arm goes to 3 positions. Now I need to add functionality to control gripper, close and open, between each position. I made a thread on teach pendant that closes and opens a gripper when digital_out[0] is HI. Now my problem is how to call that thread from python script and then when I send command set_digital_out(0, True) from python script then gripper closes and opens.
This is thread that I created on teach pendant
In python script I have this functions defined