son of a captain of the cantabrian cavalry he was trained as a military engineer