lebai-motion-control  3.1.6
lebai motion control C interface
example_urdf_group.cc
Go to the documentation of this file.
1 #include "motion_control/lmc_group.h"
2 #include <math.h>
3 #include <iostream>
4 
16 int main(int argc, char **argv)
17 {
18  lmc_group_model_t *group_model = lmc_group_model_new();
19  char filename[] = "urdf/lm3.urdf";
20  lmc_group_model_init_from_urdf_file(group_model, filename);
21 
22  lmc_group_joint_info_t joint_info;
23  lmc_group_model_get_joint_info(group_model, &joint_info);
24 
25  lmc_group_state_t *group_state = lmc_group_state_new();
26  lmc_group_state_init(group_state, group_model);
27 
28  lmc_group_state_collide(group_state, NULL, NULL);
29 
30  double joint_pos[6] = {-11.0 / 180.0 * M_PI, 157.0 / 180.0 * M_PI, -209.0 / 180.0 * M_PI, 88.0 / 180.0 * M_PI, 100.0 / 180.0 * M_PI, -76.0 / 180.0 * M_PI};
31  lmc_group_state_set_jnt_pos(group_state, joint_pos);
32 
33  lmc_group_state_update(group_state, group_model);
34 
35  lmc_group_collide_req_t req;
36  lmc_group_collide_resp_t resp;
37  req.enable_contact = 1;
38  req.num_max_contacts = 2;
39  lmc_group_state_collide(group_state, &req, &resp);
40  for(size_t i = 0; i < resp.num_contacts; ++i)
41  {
42  std::cout<<"contact pair: "<<resp.contacts[i].link_a<<" "<<resp.contacts[i].link_b<<"\n";
43  }
44  // EXPECT_STREQ("link_6", resp.contacts[0].link_a);
45  // EXPECT_STREQ("link_2", resp.contacts[0].link_b);
46  // EXPECT_STREQ("link_6", resp.contacts[1].link_a);
47  // EXPECT_STREQ("link_2", resp.contacts[1].link_b);
48  lmc_group_state_delete(&group_state);
49  lmc_group_model_delete(&group_model);
50  return 0;
51 }
int main(int argc, char **argv)
Example of urdf group usage.