Some issues about Haptix project
I am very interested in Haptix project, when I using this project, I met some problems. 1) How to get the position (x,y,z coordinates) of the arm and the cube with some programming languages, maybe C language ? I have searched related information, I guess I can implement this by using _hxsModel struct, but I do not know how to connect the arm and cube with this struct. 2) How to control the whole arm with C API ? As introduced in C API, I can use C language to control the arm, but I can only control the motors. However, wiith keyboard, I can control the whole arm by pressing 'W' 'S' 'A' 'D'. Can I write C codes to implement this kind of control ?
Asked by shin on 2017-05-06 08:29:56 UTC
Answers
I'm assuming that you want to use the HAPTIX protocol.
1) How to get the position (x,y,z coordinates) of the arm and the cube with some programming languages, maybe C language ?
The HAPTIX protocol is defined in two header files: haptix.h
and haptix_sim.h
. haptix_sim.h
contains specific simulation aids that are useful for debugging and controlling the arm in simulation only. haptix.h
contains the functions for controlling the motors of the arm and accessing its sensors both for simulated and real arms. In your case, you can use haptix_sim.h
as you're interested in simulation. The function hxs_sim_info()
returns a C struct with all the information that you need: models and their position and orientation in the global world coordinate. This tutorial explains all the functions included in haptix_sim.h
.
2) How to control the whole arm with C API ?
As I mentioned before, you can use the functions included in haptix.h
. Here's the corresponding tutorial. As you noticed, this will control the motors of the arm in the same way you'd do it with the real arm. If you want to move the entire arm as the keyboard teleoperation is doing, you can use the functions hxs_set_linear_velocity()
and hxs_set_angular_velocity()
from haptix_sim.h
.
Here are all the HAPTIX tutorials in case you need extra help.
Asked by Carlos Agüero on 2017-05-07 22:45:50 UTC
Comments
Thank you very much ! By your instructions, I can use my C codes to control the arm as I want. However, I find that the function hxs_set_linear_velocity() just move the arm for a few seconds, then the arm will go back instead of staying at its new position, how can I deal with this case ?
Asked by shin on 2017-05-08 09:31:27 UTC
Does it happen with other models? E.g.: the cube.
Asked by Carlos Agüero on 2017-05-08 19:23:53 UTC
I am sorry to reply you for a long delay, it seems that I have found another function to solve this problem , but I have another problem to bother you. According to the description in the head file, it seems that function hxs_set_camera_transform() can be used to set perspective of gazebo, after I set the perspective, how can I get the image from this perspective ? Is there an interface in gazebo or haptix ?
Asked by shin on 2017-05-12 19:47:15 UTC
No with any Haptix header file but you can use Gazebo for that. The easiest way is to subscribe to the user camera topic and consume the images from your callback. Here's a related question:
http://answers.gazebosim.org/question/14619/how-to-convert-gazebos-constimagestamped-to-cvmat/
Asked by Carlos Agüero on 2017-05-15 11:51:54 UTC
Thank you very much, I have made it! But here comes a new problem, I use C API to control the arm, then it would move with random directions, but after several seconds, it shows that "hx_update() Service call timed out." Is there any points I should care about when using this function?
Asked by shin on 2017-05-19 09:36:18 UTC
Comments