This paper presents the framework of a physics-informed neural network (PINN) with a boundary condition-embedded approximation function (BCAF) for solving common problems encountered in flexible mechatronics and soft robotics; both forward and inverse problems are considered. Unlike conventional PINNs that minimize a lumped loss function including the errors contributed by the initial or boundary conditions (ICs or BCs), the BCAF-PINN completely satisfies the ICs and/ or BCs while minimizing a loss function for parameter identification and boundary force estimation, overcoming a common erroneous-convergence problem due to unbalanced gradients in training a PINN. The formulation and implementation of a BCAF-PINN are illustrated with three practical applications, including a nonlinear system where solutions are available for numerical verification and for comparing with conventional PINNs, and a biomechanical system where a BCAF-PINN uses multiple cycles of natural foot flexion to identify its dynamic parameters experimentally. While overcoming several problems associated with traditional studies based on perturbation models with certain level of muscle contraction, the damping ratio identified by the BCAF-PINN indicates that the ankle joint is an overdamped system during flexion, consistent with that observed in published experiments.