Rahul,
If you have a set of desired link angles (lets call them q = [q1, q2]'
where q1 and q2 are the link 1 and link 2 joint angles respectively)
and you have or can calculate the desired joint velocities and
accelerations (qp and qpp respectively), then the joint torques can be
calculated with:
tau = M(q) * qpp + V(q,qp) + G(q) + F(qp)
where M(q) is your robot's inertia matrix and V(q,qp) is a vector of
the coriolis forces, G(q) is a vector of the gravity forces and F(qp)
is a vector of fiction forces.
There are numerous software packages out there to do this calculation
for you. For instance, ROBOOP (
http://www.cours.polymtl.ca/roboop/) is
a open source C++ library for almost all things robot.. well at least
manipulator robotics. But if you don't like ROBOOP, you can also dig
up a very efficient algorithm published for computing the equation
above (google something like 'recursive Newton-Euler formulation').
In your case, it sounds like you have the positions but would have to
numerically differentiate to find the desired velocities and
accelerations. That can be a little tricky with measured data since
numerical methods amplify noise. But this is all implementation
details - easily addressed with standard filtering and/or fitting
techniques. Personally I prefer fitting real data with a cubic or
quintic spline and then computing the derivative of the spline
analytically. If you don't know the actual joint positions but instead
know the desired Cartesian positions, then you probably also need to
google 'inverse kinematics'... something else ROBOOP can do for you.
This, IMHO, is the 'correct' way to do the calculation you asked for.
Using something like a physics engine to do this isn't wrong exactly,
just kinda circuitous.