Skip to content

Commit f646d44

Browse files
authored
Merge pull request #174 from resibots/tiago_diff_drive
[tiago]: add differential drive
2 parents 173e62f + 30c3443 commit f646d44

File tree

5 files changed

+64
-19
lines changed

5 files changed

+64
-19
lines changed

src/examples/tiago.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
int main()
99
{
10-
double dt = 0.01;
10+
double dt = 0.001;
1111
robot_dart::RobotDARTSimu simu(dt);
12-
simu.set_collision_detector("fcl");
12+
// this is important for wheel collision; with FCL it does not work well
13+
simu.set_collision_detector("bullet");
1314

1415
size_t freq = 1. / dt;
1516
auto robot = std::make_shared<robot_dart::robots::Tiago>(freq);
@@ -29,14 +30,15 @@ int main()
2930
simu.add_robot(robot);
3031

3132
simu.set_control_freq(100);
32-
std::vector<std::string> dofs = {"arm_1_joint",
33+
std::vector<std::string> wheel_dofs = {"wheel_right_joint", "wheel_left_joint"};
34+
std::vector<std::string> arm_dofs = {"arm_1_joint",
3335
"arm_2_joint",
3436
"arm_3_joint",
3537
"arm_4_joint",
3638
"arm_5_joint",
3739
"torso_lift_joint"};
3840

39-
Eigen::VectorXd init_positions = robot->positions(dofs);
41+
Eigen::VectorXd init_positions = robot->positions(arm_dofs);
4042

4143
auto start = std::chrono::steady_clock::now();
4244
while (simu.scheduler().next_time() < 20. && !simu.graphics()->done()) {
@@ -48,8 +50,11 @@ int main()
4850
sin(simu.scheduler().current_time() * 2.),
4951
sin(simu.scheduler().current_time() * 2.),
5052
sin(simu.scheduler().current_time() * 2.);
51-
Eigen::VectorXd commands = (init_positions + delta_pos) - robot->positions(dofs);
52-
robot->set_commands(commands, dofs);
53+
Eigen::VectorXd commands = (init_positions + delta_pos) - robot->positions(arm_dofs);
54+
robot->set_commands(commands, arm_dofs);
55+
Eigen::VectorXd cmd(wheel_dofs.size());
56+
cmd << 0., 5.;
57+
robot->set_commands(cmd, wheel_dofs);
5358
}
5459

5560
simu.step_world();

src/python/robot.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,20 @@ namespace robot_dart {
535535
py::arg("frequency") = 1000,
536536
py::arg("urdf") = "tiago/tiago_steel.urdf",
537537
py::arg("packages") = std::vector<std::pair<std::string, std::string>>({{"tiago_description", "tiago/tiago_description"}}))
538-
.def("ft_wrist", &Tiago::ft_wrist, py::return_value_policy::reference);
538+
.def("ft_wrist", &Tiago::ft_wrist, py::return_value_policy::reference)
539+
.def("caster_joints", &Tiago::caster_joints)
540+
.def("set_actuator_types", &Tiago::set_actuator_types,
541+
py::arg("type"),
542+
py::arg("joint_names") = std::vector<std::string>(),
543+
py::arg("override_mimic") = false,
544+
py::arg("override_base") = false,
545+
py::arg("override_caster") = false)
546+
.def("set_actuator_type", &Tiago::set_actuator_type,
547+
py::arg("type"),
548+
py::arg("joint_name"),
549+
py::arg("override_mimic") = false,
550+
py::arg("override_base") = false,
551+
py::arg("override_caster") = false);
539552

540553
py::class_<ICub, Robot, std::shared_ptr<ICub>>(m, "ICub")
541554
.def(py::init<size_t, const std::string&, const std::vector<std::pair<std::string, std::string>>&>(),

src/robot_dart/robots/tiago.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,31 @@ namespace robot_dart {
1010
skeleton()->setPosition(2, M_PI / 2.);
1111
skeleton()->setPosition(5, 0.01);
1212
set_position_enforced(true);
13+
// We use servo actuators, but not for the caster joints
1314
set_actuator_types("servo");
1415
}
1516

17+
void Tiago::set_actuator_types(const std::string& type, const std::vector<std::string>& joint_names, bool override_mimic, bool override_base, bool override_caster)
18+
{
19+
auto jt = joint_names;
20+
if (!override_caster) {
21+
if (joint_names.size() == 0)
22+
jt = Robot::joint_names();
23+
for (const auto& jnt : caster_joints()) {
24+
auto it = std::find(jt.begin(), jt.end(), jnt);
25+
if (it != jt.end()) {
26+
jt.erase(it);
27+
}
28+
}
29+
}
30+
Robot::set_actuator_types(type, jt, override_mimic, override_base);
31+
}
32+
33+
void Tiago::set_actuator_type(const std::string& type, const std::string& joint_name, bool override_mimic, bool override_base, bool override_caster)
34+
{
35+
set_actuator_types(type, {joint_name}, override_mimic, override_base, override_caster);
36+
}
37+
1638
void Tiago::_post_addition(RobotDARTSimu* simu)
1739
{
1840
// We do not want to add sensors if we are a ghost robot

src/robot_dart/robots/tiago.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ namespace robot_dart {
1313

1414
const sensor::ForceTorque& ft_wrist() const { return *_ft_wrist; }
1515

16+
std::vector<std::string> caster_joints() const { return {"caster_back_left_2_joint", "caster_back_left_1_joint", "caster_back_right_2_joint", "caster_back_right_1_joint", "caster_front_left_2_joint", "caster_front_left_1_joint", "caster_front_right_2_joint", "caster_front_right_1_joint"}; }
17+
18+
void set_actuator_types(const std::string& type, const std::vector<std::string>& joint_names = {}, bool override_mimic = false, bool override_base = false, bool override_caster = false);
19+
void set_actuator_type(const std::string& type, const std::string& joint_name, bool override_mimic = false, bool override_base = false, bool override_caster = false);
20+
1621
protected:
1722
std::shared_ptr<sensor::ForceTorque> _ft_wrist;
1823
void _post_addition(RobotDARTSimu* simu) override;

utheque/tiago/tiago_steel.urdf

+12-12
Original file line numberDiff line numberDiff line change
@@ -311,12 +311,12 @@
311311
<dynamics damping="100"/>
312312
<safety_controller k_position="0" k_velocity="10" soft_lower_limit="-0.005" soft_upper_limit="0.005"/>
313313
</joint>
314-
<joint name="wheel_right_joint" type="revolute">
314+
<joint name="wheel_right_joint" type="continuous">
315315
<parent link="suspension_right_link"/>
316316
<child link="wheel_right_link"/>
317317
<origin rpy="-1.57079632679 0 0" xyz="0 -0.2022 0"/>
318318
<axis xyz="0 0 1"/>
319-
<limit effort="6.0" velocity="10.152284264" lower="-1.7976931348623157e+308" upper="1.7976931348623157e+308"/>
319+
<limit effort="6.0" velocity="10.152284264"/>
320320
</joint>
321321
<transmission name="wheel_right_trans">
322322
<type>transmission_interface/SimpleTransmission</type>
@@ -368,12 +368,12 @@
368368
<dynamics damping="100"/>
369369
<safety_controller k_position="0" k_velocity="10" soft_lower_limit="-0.005" soft_upper_limit="0.005"/>
370370
</joint>
371-
<joint name="wheel_left_joint" type="revolute">
371+
<joint name="wheel_left_joint" type="continuous">
372372
<parent link="suspension_left_link"/>
373373
<child link="wheel_left_link"/>
374374
<origin rpy="-1.57079632679 0 0" xyz="0 0.2022 0"/>
375375
<axis xyz="0 0 1"/>
376-
<limit effort="6.0" velocity="10.152284264" lower="-1.7976931348623157e+308" upper="1.7976931348623157e+308"/>
376+
<limit effort="6.0" velocity="10.152284264"/>
377377
</joint>
378378
<transmission name="wheel_left_trans">
379379
<type>transmission_interface/SimpleTransmission</type>
@@ -425,14 +425,14 @@
425425
</geometry>
426426
</collision>
427427
</link>
428-
<joint name="caster_front_right_1_joint" type="fixed">
428+
<joint name="caster_front_right_1_joint" type="continuous">
429429
<parent link="base_link"/>
430430
<child link="caster_front_right_1_link"/>
431431
<origin rpy="0 0 0" xyz="0.1695 -0.102 -0.0335"/>
432432
<axis xyz="0 0 1"/>
433433
<dynamics damping="0.005" friction="0.0"/>
434434
</joint>
435-
<joint name="caster_front_right_2_joint" type="fixed">
435+
<joint name="caster_front_right_2_joint" type="continuous">
436436
<parent link="caster_front_right_1_link"/>
437437
<child link="caster_front_right_2_link"/>
438438
<origin rpy="-1.57079632679 0 0" xyz="-0.016 0.0000 -0.040"/>
@@ -478,14 +478,14 @@
478478
</geometry>
479479
</collision>
480480
</link>
481-
<joint name="caster_front_left_1_joint" type="fixed">
481+
<joint name="caster_front_left_1_joint" type="continuous">
482482
<parent link="base_link"/>
483483
<child link="caster_front_left_1_link"/>
484484
<origin rpy="0 0 0" xyz="0.1695 0.102 -0.0335"/>
485485
<axis xyz="0 0 1"/>
486486
<dynamics damping="0.005" friction="0.0"/>
487487
</joint>
488-
<joint name="caster_front_left_2_joint" type="fixed">
488+
<joint name="caster_front_left_2_joint" type="continuous">
489489
<parent link="caster_front_left_1_link"/>
490490
<child link="caster_front_left_2_link"/>
491491
<origin rpy="-1.57079632679 0 0" xyz="-0.016 0.0000 -0.040"/>
@@ -531,14 +531,14 @@
531531
</geometry>
532532
</collision>
533533
</link>
534-
<joint name="caster_back_right_1_joint" type="fixed">
534+
<joint name="caster_back_right_1_joint" type="continuous">
535535
<parent link="base_link"/>
536536
<child link="caster_back_right_1_link"/>
537537
<origin rpy="0 0 0" xyz="-0.1735 -0.102 -0.0335"/>
538538
<axis xyz="0 0 1"/>
539539
<dynamics damping="0.005" friction="0.0"/>
540540
</joint>
541-
<joint name="caster_back_right_2_joint" type="fixed">
541+
<joint name="caster_back_right_2_joint" type="continuous">
542542
<parent link="caster_back_right_1_link"/>
543543
<child link="caster_back_right_2_link"/>
544544
<origin rpy="-1.57079632679 0 0" xyz="-0.016 0.0000 -0.040"/>
@@ -584,14 +584,14 @@
584584
</geometry>
585585
</collision>
586586
</link>
587-
<joint name="caster_back_left_1_joint" type="fixed">
587+
<joint name="caster_back_left_1_joint" type="continuous">
588588
<parent link="base_link"/>
589589
<child link="caster_back_left_1_link"/>
590590
<origin rpy="0 0 0" xyz="-0.1735 0.102 -0.0335"/>
591591
<axis xyz="0 0 1"/>
592592
<dynamics damping="0.005" friction="0.0"/>
593593
</joint>
594-
<joint name="caster_back_left_2_joint" type="fixed">
594+
<joint name="caster_back_left_2_joint" type="continuous">
595595
<parent link="caster_back_left_1_link"/>
596596
<child link="caster_back_left_2_link"/>
597597
<origin rpy="-1.57079632679 0 0" xyz="-0.016 0.0000 -0.040"/>

0 commit comments

Comments
 (0)