-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathex_gravity_compensation.cpp
More file actions
66 lines (50 loc) · 1.83 KB
/
Copy pathex_gravity_compensation.cpp
File metadata and controls
66 lines (50 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* This file is a barebones skeleton of how to setup an arm for use.
* It demonstrates gravity compensation behavior by commanding torques
* equal to the force from gravity on the links and joints of an arm.
* Note that this only approximately balances out gravity, as imperfections in
* the torque sensing and modeled system can lead to "drift". Also, the
* particular choice of PID control gains can affect the performance of this
* demo.
*/
// #include "lookup.hpp"
// #include "group.hpp"
#include "group_command.hpp"
#include "group_feedback.hpp"
#include "robot_model.hpp"
#include "arm/arm.hpp"
#include <chrono>
using namespace hebi;
using namespace experimental;
int main(int argc, char* argv[])
{
//////////////////////////
///// Arm Setup //////////
//////////////////////////
arm::Arm::Params params;
// Setup Module Family and Module Names
params.families_ = {"Arm"}; //[change back]
params.names_ = {"J1_base", "J2_shoulder", "J3_elbow", "J4_wrist1", "J5_wrist2", "J6_wrist3"};
// Read HRDF file to seutp a RobotModel object for the 6-DoF Arm
params.hrdf_file_ = "kits/arm/hrdf/A-2085-06.hrdf";
// Create the Arm Object
auto arm = arm::Arm::create(params);
while (!arm) {
arm = arm::Arm::create(params);
}
// Load the gains file that is approriate to the arm
arm -> loadGains("kits/arm/gains/A-2085-06.xml");
//////////////////////////
//// Main Control Loop ///
//////////////////////////
while(arm->update())
{
// When no goal is set, the arm automatically returns to grav-comp mode.
// Thus, when we have an empty control loop, the arm is in grav-comp
// awaiting further instructions.
// Send the latest loaded commands to the arm. If no changes are made,
// it will send the last loaded command when arm->update was last called
arm->send();
}
return 0;
}