I have done the Robot Dynamics and Control Course with success. I noticed that in the last example there is damping parameter in the torque equation. This parameter is also specified in the URDF robot’s model, but in URDF one can also set the friction parameter. The friction issue is not mention in the course, and I would like to learn how to include friction in calculating torques. How to do it in the simplest way? Or, is the damping enough for moving properly with friction.
Secondly, from equations, it occurs that for huge damping values (e.g. while calculating lower_link_torque_vector), the b * omega_1 term can be bigger then tau_1 and movement will be in the opposite direction - that is not correct.
Energy dissipation in a joint can be produced by several elements: friction, and diverse types of damping. For this chapter we have done a first approximation to the problem of energy dissipation and assumed that all dissipation is modelled by a damping effect. This approximation usually works for most cases as indicated in Eduard Wilson’s Book
Three Dimensional Static and Dynamic Analysis of Structures (chapter 19 free download).
You can extend anytime the precision of the Lagrange equation by adding elements of non-conservative forces like friction. For that, have a look a section 13.4.3 of the amazing book Planning Algorithms (free download) by Steven LaValle. Check it out and let me know if it is clear for you.
About your second question, it is understood that you cannot set a damping coefficient bigger than the torque. In case the damping is very big (let’s say the joint is inside a box of sand) then the joint would just not move. You need to interpret that, and may be include a check in your program that prevents moving thee joint when that part of the equation is negative (in the same sense as we check for zero divisions).