Size: 2370
Comment:
|
Size: 2306
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from controllers/Tutorials/MakingControllers |
Note: This tutorial assumes that you have completed the previous tutorials: Running a realtime joint controller. |
![]() |
Communicating with a realtime joint controller
Description: This tutorial teaches you how to communicate with a controller over ROS.Tutorial Level: INTERMEDIATE
Next Tutorial: Adding a PID to a realtime joint controller
External Communication
Your controller can communicate with the outside world using ROS. The controller can publish and receive messages like any other node, however, you must be careful to ensure that you do not break realtime nor introduce any race conditions. To achieve this goal, there exist specialized mechanisms for publishing and receiving messages that hide much of the complexity.
The RealtimePublisher provides an easy interface for publishing messages safely from realtime. Call trylock, and then fill in the fields of msg_, and then the message will be published soon after calling unlockAndPublish.
Getting information from received messages into the realtime process is slightly more difficult. You should subscribe to the topic as you would in any node. ROS will pass you the message in a callback (like usual) that runs in the ROS-thread, a non-realtime thread. You can use the RealtimeInfuser to get the message information into the realtime thread. In non-realtime, place the data into the realtime infuser using the set method, and read it out by calling next at the beginning of each realtime iteration.
Tools
Pids
KDL