Functional self-awareness and metacontrol for underwater robot autonomy