se2ez
robot.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
3 #include <iostream>
4 
5 #include <se2ez/core.h>
6 
7 using namespace se2ez;
8 
9 int main()
10 {
11  auto f_base = std::make_shared<Frame>("base", Eigen::Vector3d{0, 0, 0}, //
12  Joint::FLOAT, //
13  Eigen::Vector3d{-1, -1, math::pi}, //
14  Eigen::Vector3d{1, 1, -math::pi});
15  auto f_l1 = std::make_shared<Frame>("link_1", Eigen::Vector3d{1, 0, 0}, //
17  auto f_l2 = std::make_shared<Frame>("link_2", Eigen::Vector3d{0, 0, 0}, //
18  Joint::PRISMATIC, 0, 1);
19  auto f_l3 = std::make_shared<Frame>("link_3", Eigen::Vector3d{1, 0, 0}, //
21  auto f_e1 = std::make_shared<Frame>("ee_1", Eigen::Vector3d{0, 0, 0}, Joint::FIXED);
22  auto f_e2 = std::make_shared<Frame>("ee_2", Eigen::Vector3d{0, 0, 0}, Joint::FIXED);
23 
24  auto robot = std::make_shared<Robot>();
25  robot->attachFrame(f_base);
26  robot->attachFrame(f_l1, f_base);
27  robot->attachFrame(f_l2, f_l1);
28 
29  robot->attachFrame(f_l3, f_l1);
30  robot->attachFrame(f_l3, f_l2);
31 
32  robot->attachFrame(f_e1, f_l1);
33  robot->attachFrame(f_e1, f_l3);
34  robot->attachFrame(f_e1, f_l2);
35 
36  robot->attachFrame(f_e2, f_l3);
37  robot->attachFrame(f_e2, f_l2);
38  robot->attachFrame(f_e2, f_l3);
39 
40  robot->compileTree();
41 
42  std::cout << robot->printTree() << std::endl;
43 
44  State s(robot);
45  s.setFloatJoint(robot, "base", Eigen::Vector3d{0, 1, 0});
46  s.setJoint(robot, "link_1", 0);
47  s.setJoint(robot, "link_2", 1);
48  s.setJoint(robot, "link_3", math::pi2);
49 
50  s.fk(robot);
51 
52  std::cout << s.printFrames(robot) << std::endl;
53 }
Revolute joint, rotates. Uses Euclidean metric.
Definition: joint.h:45
static const double pi
Definition: math.h:32
A representation of a state of a Robot.
Definition: state.h:28
T endl(T... args)
Prismatic joint, extends along X-axis.
Definition: joint.h:44
std::string printFrames(const RobotPtr &robot) const
Print out the current value of all frames on the robot.
Definition: state.cpp:113
Fixed joint, just a rigid transformation.
Definition: joint.h:40
void fk(const RobotPtr &robot)
Compute the forward kinematics for all frames in the robot.
Definition: state.cpp:80
int main()
Definition: robot.cpp:9
static const double pi2
Definition: math.h:34
Main namespace.
Definition: collision.h:11
void setJoint(const RobotPtr &robot, const std::string &name, double value)
Sets the value of a frame with one joint parameter.
Definition: state.cpp:39
Floating joint, free movement in SE(2). Uses Euclidean metric.
Definition: joint.h:41
void setFloatJoint(const RobotPtr &robot, const std::string &name, const Eigen::Isometry2d &value)
Sets the value of a frame with a floating joint.
Definition: state.cpp:51