Time optimal control for a nonholonomic system with state constraint