Previously, I implemented current force in Gazebo by modifying an example plugin. The example plugin, ModelPush, sounds like it does what I need. It makes the robot travel with an arbitrary velocity. I just had to set the velocity using the magntiude and direction of the current at the robot’s location. During execution, the time lapsed in simulation was used to ensure that the currents were up-to-date with the time interval.
However, this method proved to be a problem while working on the waypoint follower. My expectation was that the robot would have a force exerted upon it and also propel itself with a motive force. The resulting velocity should be the robot movement impaired by water currents. However, the velocities would replace each other instead of sum. Naturally, the robot just wiggled rapidly in place as the two velocity commands constantly overrode each other.
What I found is that, even though the plugin is called “ModelPush”, it does not really push the model in the way I expected. It just sends velocity commands to every part of the robot. My waypoint following Python code does essentially the same.
I found that Gazebo also supports force and torque commands. These are what you want to use to get an actual external force applied to the robot. Then, the robot’s motor movement is independent and both the external force and robot motors operate simultaneously.