Skip to content

Commit cb5aadd

Browse files
authored
Merge pull request #165 from resibots/support_ur3e
[robots]: add UR3E with Schunk hand
2 parents 588db92 + a4dadf8 commit cb5aadd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+11033
-4
lines changed

src/examples/ur3e.cpp

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <robot_dart/robot_dart_simu.hpp>
2+
#include <robot_dart/robots/ur3e.hpp>
3+
4+
#include <robot_dart/control/pd_control.hpp>
5+
6+
#ifdef GRAPHIC
7+
#include <robot_dart/gui/magnum/graphics.hpp>
8+
#endif
9+
10+
int main(int argc, char** argv)
11+
{
12+
bool hand = (argc > 1 && std::string(argv[1]) == "--hand") ? true : false;
13+
auto robot = hand ? std::make_shared<robot_dart::robots::Ur3eHand>() : std::make_shared<robot_dart::robots::Ur3e>();
14+
15+
robot->set_actuator_types("torque");
16+
17+
std::vector<std::string> dofs = {"shoulder_pan_joint",
18+
"shoulder_lift_joint",
19+
"elbow_joint",
20+
"wrist_1_joint",
21+
"wrist_2_joint",
22+
"wrist_3_joint"};
23+
24+
auto up = robot->position_upper_limits(dofs);
25+
auto low = robot->position_lower_limits(dofs);
26+
for (size_t i = 0; i < dofs.size(); ++i)
27+
std::cout << "[" << i << "] " << dofs[i]
28+
<< " -> [" << low[i] << ", " << up[i] << "]" << std::endl;
29+
30+
Eigen::VectorXd ctrl = robot_dart::make_vector({0., -M_PI / 4., M_PI / 2., -M_PI / 4., M_PI / 2., 0.});
31+
// add the controller to the robot
32+
auto controller = std::make_shared<robot_dart::control::PDControl>(ctrl, dofs);
33+
robot->add_controller(controller);
34+
35+
controller->set_pd(5000., 50.);
36+
37+
// choose time step of 0.001 seconds
38+
robot_dart::RobotDARTSimu simu(0.001);
39+
simu.set_collision_detector("fcl");
40+
// simu.enable_status_bar(true, 20); // change the font size
41+
42+
#ifdef GRAPHIC
43+
auto graphics = std::make_shared<robot_dart::gui::magnum::Graphics>();
44+
simu.set_graphics(graphics);
45+
#endif
46+
47+
simu.add_checkerboard_floor();
48+
simu.add_robot(robot);
49+
50+
simu.run(10.);
51+
std::cout << "robot->pos: " << robot->positions().transpose() << std::endl;
52+
53+
return 0;
54+
}

src/python/robot.cpp

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <robot_dart/robots/pendulum.hpp>
1616
#include <robot_dart/robots/talos.hpp>
1717
#include <robot_dart/robots/tiago.hpp>
18+
#include <robot_dart/robots/ur3e.hpp>
1819

1920
#include <robot_dart/control/robot_control.hpp>
2021

@@ -565,6 +566,19 @@ namespace robot_dart {
565566
py::arg("frequency") = 1000,
566567
py::arg("urdf") = "talos/talos_fast.urdf",
567568
py::arg("packages") = std::vector<std::pair<std::string, std::string>>({{"talos_description", "talos/talos_description"}}));
569+
570+
py::class_<Ur3e, Robot, std::shared_ptr<Ur3e>>(m, "Ur3e")
571+
.def(py::init<size_t, const std::string&, const std::vector<std::pair<std::string, std::string>>&>(),
572+
py::arg("frequency") = 1000,
573+
py::arg("urdf") = "ur3e/ur3e.urdf",
574+
py::arg("packages") = std::vector<std::pair<std::string, std::string>>({{"ur3e_description", "ur3e/ur3e_description"}}))
575+
.def("ft_wrist", &Ur3e::ft_wrist, py::return_value_policy::reference);
576+
577+
py::class_<Ur3eHand, Ur3e, std::shared_ptr<Ur3eHand>>(m, "Ur3eHand")
578+
.def(py::init<size_t, const std::string&, const std::vector<std::pair<std::string, std::string>>&>(),
579+
py::arg("frequency") = 1000,
580+
py::arg("urdf") = "ur3e/ur3e_with_schunk_hand.urdf",
581+
py::arg("packages") = std::vector<std::pair<std::string, std::string>>({{"ur3e_description", "ur3e/ur3e_description"}}));
568582
}
569583
} // namespace python
570584
} // namespace robot_dart

src/robot_dart/robots/ur3e.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
#include "robot_dart/robots/ur3e.hpp"
3+
#include "robot_dart/robot_dart_simu.hpp"
4+
5+
namespace robot_dart {
6+
namespace robots {
7+
Ur3e::Ur3e(size_t frequency, const std::string& urdf, const std::vector<std::pair<std::string, std::string>>& packages)
8+
: Robot(urdf, packages),
9+
_ft_wrist(std::make_shared<sensor::ForceTorque>(joint("wrist_3-flange"), frequency))
10+
{
11+
fix_to_world();
12+
set_position_enforced(true);
13+
set_color_mode("material");
14+
}
15+
16+
void Ur3e::_post_addition(RobotDARTSimu* simu)
17+
{
18+
// We do not want to add sensors if we are a ghost robot
19+
if (ghost())
20+
return;
21+
simu->add_sensor(_ft_wrist);
22+
}
23+
24+
void Ur3e::_post_removal(RobotDARTSimu* simu)
25+
{
26+
simu->remove_sensor(_ft_wrist);
27+
}
28+
} // namespace robots
29+
} // namespace robot_dart

src/robot_dart/robots/ur3e.hpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef ROBOT_DART_ROBOTS_UR3E_HPP
2+
#define ROBOT_DART_ROBOTS_UR3E_HPP
3+
4+
#include "robot_dart/robot.hpp"
5+
#include "robot_dart/sensor/force_torque.hpp"
6+
7+
namespace robot_dart {
8+
namespace robots {
9+
class Ur3e : public Robot {
10+
public:
11+
Ur3e(size_t frequency = 1000, const std::string& urdf = "ur3e/ur3e.urdf", const std::vector<std::pair<std::string, std::string>>& packages = {{"ur3e_description", "ur3e/ur3e_description"}});
12+
13+
const sensor::ForceTorque& ft_wrist() const { return *_ft_wrist; }
14+
15+
protected:
16+
std::shared_ptr<sensor::ForceTorque> _ft_wrist;
17+
void _post_addition(RobotDARTSimu* simu) override;
18+
void _post_removal(RobotDARTSimu* simu) override;
19+
};
20+
21+
class Ur3eHand : public Ur3e {
22+
public:
23+
Ur3eHand(size_t frequency = 1000, const std::string& urdf = "ur3e/ur3e_with_schunk_hand.urdf", const std::vector<std::pair<std::string, std::string>>& packages = {{"ur3e_description", "ur3e/ur3e_description"}}) : Ur3e(frequency, urdf, packages) {}
24+
};
25+
} // namespace robots
26+
} // namespace robot_dart
27+
#endif

0 commit comments

Comments
 (0)