We consider the problem of finding the optimal shape of a force-sensing element which is integrated into a tubular structure. The goal is to make the sensor element sensitive to specific forces and insensitive to other forces. The problem is stated as a PDE-constrained minimization program with both nonconvex objective and nonconvex constraints. The optimization problem depends on uncertain parameters, because the manufacturing process of the structures underlies uncertainty, which causes unwanted deviations in the sensory properties. In order to maintain the desired properties of the sensor element even in the presence of uncertainty, we apply a robust optimization method to solve the uncertain program.The objective and constraint functions are continuous but not differentiable with respect to the uncertain parameters, so that existing methods for robust optimization cannot be applied. Therefore, we consider the nonsmooth robust counterpart formulated in terms of the worst-case functions, and show that subgradients can be computed efficiently. We solve the problem with a BFGS--SQP method for nonsmooth problems recently proposed by Curtis, Mitchell and Overton.