I have a problem plotting a trajectory in the openGL scene.
My project is a robot simulator (more exactly simulator for Fanuc M-6iB 2HS serial robot). I made the robot components (joints) using opengl lists. The robot has 6 rotations (q1 - q6) and I intend to draw the end-effector trajectory (with small spheres). The problem is that i have no clue how to do it. The display lists are called in paintGL() and I thought a possible solution could be to create dynamically a display list of spheres in the paintGL. I dont know if this is possible. In other words, I want to save somehow the current position (absolute position) of the end-effector (last display list) and redisplay it next iteration… and so on, until robot stops moving. I dont know if there any other algorithms for this. I would appreciate any idea/help.
I think I progressed a little bit but I dont know if this is a recommended solution. Here is the mechanism I use:
- all the lists are created in initializeGL (I’m using Qt under linux), including one list for the trajectory (small spheres). Initially, the trajectory list contains 1 sphere.
- The motion/animation is controlled by a thread. For each step of the animation the thread calls a particular function from the opengl scene class (i named it setNewQs). In this function I delete the trajectory list, update the array which holds all the positions (all related to previous position) and recreate the trajectory list. The function which creates the trajectory list contains a for loop and for each position in the position array creates a small sphere. At the end of setNewQs function I use updateGL to redraw the scene.
I this a good algorithm to use in generating trajectories? Any help would be appreciated.