I am currently wondering about the architecture of my control loop. I am using a simulated robot (under vrep) for a robot which will be built in real in a few months. Obviously the control is performed using ros_control. I'd like to use the same control architecture (same loop) for my real and my simulated robots. Now I have looked around and found several architectures possible to link ros_control with a robot (simulated or real).
1. Synchronous model: at each simulation step the controller manager is updated and a command is generated and applied to the motors. This is the architecture used by gazebo_ros_control which is actually a gazebo plugin: the communication between the control and the simulator does not use ros communication as it uses gazebo's API, this makes the code rather simple but it cannot be extended to a real robot (as a real robot does not have periodic steps such as the simulation steps).2. Pseudo-synchronous model: the simulator sends the joints state update at each step in a topic which the control loop subscribes to. The controller manager then updates, and the command is sent to the simulator via a topic which the simulator is subscribed to (and applies the command to the motors). The quality of the synchronization between the simulator and control depends on the speed of the spin (i.e. this model does not enforce to have exactely a ros_control step per simulator step). This architecture cannot be extended to a real robot.3. Asynchronous model: setup a timer on the ros_control side which computes a command periodically and independently from the steps of the simulator - we should make sure the control loop runs much faster than the simulator (say 10x?).
With this model there may be more control steps than simulation steps but if we use topics to send the commands, the latest command will overwrite the former ones and things should behave correctly. Control and ros communication run in separate threads. This is the architecture shown on the RosCon 2014 presentation and to my understanding it can be applied straightforwardly on both real and simulated robots.Are there other relevant architectures possible which are not too far-fetched? Now my main question is related to getting a system as close as possible to the real setup. My gut feeling is that model 3. (asynchronous) is certainly closest to what I am going to use on the real robot (as there is no such thing as a synchronous mode on a real robot) and so it is what I should use for the simulator version as well, no?Anyone having a recommendation or advise on the matter?Thanks,Antoine.
--
You received this message because you are subscribed to the Google Groups "ROS/Orocos Robot Control Special Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-robot-co...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
1. Synchronous model: at each simulation step the controller manager is updated and a command is generated and applied to the motors.
2. Pseudo-synchronous model: the simulator sends the joints state update at each step in a topic which the control loop subscribes to.
3. Asynchronous model: setup a timer on the ros_control side which computes a command periodically and independently from the steps of the simulator - we should make sure the control loop runs much faster than the simulator (say 10x?).
You can likely reuse some but not all of the code that makes up a robot backend.The details of the hardware and simulation backends will likely differ in some ways. The most obvious one is the API for accessing hardware (real or virtual). Another one is how the periodic control loop is enforced. When you need to explicitly specify periodic timer events, you can use tools from ros::Rate for no real-time setups (the ROSCON talk example), to high-resolution RTOS primitives. In other circumstances you might embed ros_control into a higher level framework, which takes care of waking you up at a specified frequency. The Gazebo integration is an example of the latter, where you request the simulator to wake you up at a frequency lower or equal than that of the simulation.Summing up, the controller_manager is designed to work with a periodic control loop, which either you set up or must be serviced by the embedding application.
3. Asynchronous model: setup a timer on the ros_control side which computes a command periodically and independently from the steps of the simulator - we should make sure the control loop runs much faster than the simulator (say 10x?).There is no gain in running the control loop faster than the simulation loop because in between simulation updates state readings will not change and computed commands will not be executed. You'll just burn computational resources.
On Sun, Oct 19, 2014 at 2:45 PM, Antoine Rennuit <antoine...@gmail.com> wrote:I'm having trouble understanding why you say the first two aren't applicable to both simulated and real hardware. Also, like Adolfo said, there's no sense in making a controller run faster than the information it's receiving. If anything, you want the simulator running at a higher rate than the controller.1. Synchronous model: at each simulation step the controller manager is updated and a command is generated and applied to the motors.2. Pseudo-synchronous model: the simulator sends the joints state update at each step in a topic which the control loop subscribes to.3. Asynchronous model: setup a timer on the ros_control side which computes a command periodically and independently from the steps of the simulator - we should make sure the control loop runs much faster than the simulator (say 10x?).
With our Barrett WAM arms [1], we use Orocos with a controller manager (ConMan [2]) that has a ROS API similar to that of ros-control, and enforces similar constraints between orocos control components. The entire real-time control infrastructure is completely independent of how we interact with the real or simulated low-level hardware. All of that is determined based on whether we load the WAM orocos component which talks over the CANBus or the WAM orocos component which uses the Gazebo APIs.On the real hardware, this WAM component spins up a dedicated thread for CANBus IO, and uses a pair of lock-free buffers to communicate with the single-threaded control loop managed by ConMan. The way this is implemented, it means that while the (bandwidth-limited) CANBus sending the last command and retrieving the latest state, our control command can be computed. When this is running, it synchronizes the two threads without blocking unless there is no recent state update from the hardware.In simulation, we use the same model, except the scheduling of the whole system is controlled by the Gazebo clock. This simulated orocos clock is managed automatically by the rtt_gazebo [3] packages. This means that you can simulate a given (realistic) control update rate even if your computer can't simulate the world quickly enough. This has the downside, however, of slowing down the simulation because it executes orocos components and the gazebo simulation solver in series. Something I've been meaning to add to the rtt_gazebo packages is a way to parallelize the computation of the simulation step and the control step.
As an aside, what are your experiences using V-REP with ROS?
So what I understand from what you wrote above and from reading this post on another message is that:
- there is no need to have control running faster than simulation (this makes sense)
- if communication and control are asynchronous, control should be an order of magnitude faster than communication (to account for varying delays in transport)
Right?
--
You received this message because you are subscribed to the Google Groups "ROS/Orocos Robot Control Special Interest Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-robot-co...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@Jonathan: my answer below:
Le lundi 20 octobre 2014 18:00:15 UTC+2, Jonathan Bohren a écrit :On Sun, Oct 19, 2014 at 2:45 PM, Antoine Rennuit <antoine...@gmail.com> wrote:I'm having trouble understanding why you say the first two aren't applicable to both simulated and real hardware. Also, like Adolfo said, there's no sense in making a controller run faster than the information it's receiving. If anything, you want the simulator running at a higher rate than the controller.1. Synchronous model: at each simulation step the controller manager is updated and a command is generated and applied to the motors.2. Pseudo-synchronous model: the simulator sends the joints state update at each step in a topic which the control loop subscribes to.3. Asynchronous model: setup a timer on the ros_control side which computes a command periodically and independently from the steps of the simulator - we should make sure the control loop runs much faster than the simulator (say 10x?).In the simulation case you can synchronize the control loop against the simulation step events, but I am not sure I understand which event you can use in the real robot case, to synchronize your control loop against... This cannot be encoders (or robot state) updates, can it?
With our Barrett WAM arms [1], we use Orocos with a controller manager (ConMan [2]) that has a ROS API similar to that of ros-control, and enforces similar constraints between orocos control components. The entire real-time control infrastructure is completely independent of how we interact with the real or simulated low-level hardware. All of that is determined based on whether we load the WAM orocos component which talks over the CANBus or the WAM orocos component which uses the Gazebo APIs.On the real hardware, this WAM component spins up a dedicated thread for CANBus IO, and uses a pair of lock-free buffers to communicate with the single-threaded control loop managed by ConMan. The way this is implemented, it means that while the (bandwidth-limited) CANBus sending the last command and retrieving the latest state, our control command can be computed. When this is running, it synchronizes the two threads without blocking unless there is no recent state update from the hardware.In simulation, we use the same model, except the scheduling of the whole system is controlled by the Gazebo clock. This simulated orocos clock is managed automatically by the rtt_gazebo [3] packages. This means that you can simulate a given (realistic) control update rate even if your computer can't simulate the world quickly enough. This has the downside, however, of slowing down the simulation because it executes orocos components and the gazebo simulation solver in series. Something I've been meaning to add to the rtt_gazebo packages is a way to parallelize the computation of the simulation step and the control step.Very clean! This is far from being the out-of-the-box (or low time-intensive) solution I am aiming at. I keep it in mind for the record (and because it may inspire me in the future). Unfortunately at the time being I cannot invest all the time needed to develop such a clean solution...As an aside, what are your experiences using V-REP with ROS?So far my feeling with vrep is that it rocks! It just works... It is easy to use from the very beginning and scales well to more complex setups. The basic integration with ros is clean, comprehensive and open (the default vrep-ros plugin is easy to modify). I still have my hands dirty on the integration with ros_control. So more on this in the coming days when I struggle a bit less on the matter...
This last point is not implied in the referenced post. What I meant was that if you have two independent threads that:
- share common data,
- update at the same periodic frequency,- but have no mechanism to notify each other when data becomes available,then the shared data you read might be up to one period old.
Having the control loop running faster than your backend, be it simulation or hardware, is a waste of computational resources. If you want to reduce your control cycle delay, there are other alternatives.
It depends on your setup. If you have a meaningful source of time events that you can synchronize against, you can use that; otherwise you should create that source yourself (like the ros::Rate instance in the basic examples). In Gazebo there exists the simulation loop, which takes care of waking up the ros_control plugin periodically. Some robot hardware backends also have some governing structure that takes care of stepping the control loop.
Sounds good. Let us know if at some point in the future you'd be interested in contributing a robot agnostic v-rep backend.