Detect environment
Am I running on a robot?
You can determine whether your script is actually running on a robot using something like this.
$ [[ `hostname` == miropi ]] && echo "This script is running on board a robot" || echo "No it isn't"
This script is running on board a robot
$ [[ `hostname` == miropi ]] && echo "This script is running on board a robot" || echo "No it isn't"
No it isn't
Am I talking to a robot?
ROS control clients will generally work on the robot or the simulator, but at times you may want to know which you are working with.
To determine if the target you are talking to on the ROS interface is a robot (or a simulator), look for the flag MIRO_PLATFORM_U_FLAG_SIMULATOR
(miro.constants.PLATFORM_U_FLAG_SIMULATOR
) in the ROS topic sensors/flags.
You can access this, and other tests, through RobotInterface() in Python, as follows.
import miro2 as miro
i = miro.lib.RobotInterface()
print i.target_supports("is_running_on_robot")
print i.target_supports("is_robot")