Tackling sparse cost in safe reinforcement learning for obstacle avoidance