RobotsIO
Loading...
Searching...
No Matches
SpatialVelocity.cpp
1/*
2 * Copyright (C) 2020 Istituto Italiano di Tecnologia (IIT)
3 *
4 * This software may be modified and distributed under the terms of the
5 * BSD 3-Clause license. See the accompanying LICENSE file for details.
6 */
7
8#include <RobotsIO/Utils/SpatialVelocity.h>
9
10using namespace Eigen;
11using namespace RobotsIO::Utils;
12
13
14SpatialVelocity::~SpatialVelocity()
15{}
16
17
18Eigen::Vector3d SpatialVelocity::angular_velocity()
19{
20 return twist().segment<3>(3);
21}
22
23
24Eigen::Vector3d SpatialVelocity::linear_velocity_origin()
25{
26 return twist().head<3>();
27}
28
29
30Eigen::Vector3d SpatialVelocity::linear_velocity_screw()
31{
32 double angular_norm = twist().segment<3>(3).norm();
33
34 if (angular_norm > 1e-4)
35 return twist().head<3>() + twist().segment<3>(3).cross(twist().segment<3>(3).cross(twist().head<3>())) / std::pow(angular_norm, 2);
36
37 return twist().head<3>();
38}
39
40
41Eigen::Vector3d SpatialVelocity::screw_position()
42{
43 double angular_norm = twist().segment<3>(3).norm();
44
45 if (angular_norm > 1e-4)
46 return twist().segment<3>(3).cross(twist().head<3>()) / std::pow(angular_norm, 2);
47
48 return Vector3d::Zero();
49}
50
51
52bool SpatialVelocity::is_screw_degenerate()
53{
54 return (twist().segment<3>(3).norm() <= 1e-4);
55}