Flexiv RDK APIs  0.10
Functions
Utility.hpp File Reference
#include <flexiv/Exception.hpp>
#include <Eigen/Eigen>
#include <array>
#include <vector>
Include dependency graph for Utility.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

std::vector< double > flexiv::utility::quat2EulerZYX (const std::vector< double > &quat)
 Convert quaternion to Euler angles with ZYX axis rotations. More...
 
double flexiv::utility::rad2Deg (double rad)
 Convert radians to degrees for a single value.
 
std::vector< double > flexiv::utility::rad2Deg (const std::vector< double > &radVec)
 Convert radians to degrees for a vector.
 
template<typename T >
std::string flexiv::utility::vec2Str (const std::vector< T > &vec, size_t decimal=3, bool trailingSpace=true)
 Convert a std::vector to a string. More...
 
template<typename T , size_t N>
std::string flexiv::utility::arr2Str (const std::array< T, N > &arr, size_t decimal=3, bool trailingSpace=true)
 Convert a std::array to a string. More...
 
bool flexiv::utility::programArgsExistAny (int argc, char **argv, const std::vector< std::string > &refStrs)
 Check if any provided strings exist in the program arguments. More...
 
bool flexiv::utility::programArgsExist (int argc, char **argv, const std::string &refStr)
 Check if one specific string exists in the program arguments. More...
 
std::string flexiv::utility::parsePtStates (const std::vector< std::string > &ptStates, const std::string &parseTarget)
 Parse the value of a specified primitive state from the ptStates string list. More...
 

Detailed Description

Definition in file Utility.hpp.

Function Documentation

◆ arr2Str()

template<typename T , size_t N>
std::string flexiv::utility::arr2Str ( const std::array< T, N > &  arr,
size_t  decimal = 3,
bool  trailingSpace = true 
)
inline

Convert a std::array to a string.

Parameters
[in]arrstd::array of any type and size.
[in]decimalDecimal places to keep for each number in the array.
[in]trailingSpaceWhether to include a space after the last element.
Returns
A string with format "arr[0] arr[1] ... arr[n] ", i.e. each element followed by a space, including the last one if trailingSpace = true.

Definition at line 101 of file Utility.hpp.

◆ parsePtStates()

std::string flexiv::utility::parsePtStates ( const std::vector< std::string > &  ptStates,
const std::string &  parseTarget 
)
inline

Parse the value of a specified primitive state from the ptStates string list.

Parameters
[in]ptStatesPrimitive states string list returned from Robot::getPrimitiveStates().
[in]parseTargetName of the primitive state to parse for.
Returns
Value of the specified primitive state in string format. Empty string is returned if parseTarget does not exist.
Examples
basics3_primitive_execution.cpp, and intermediate7_teach_by_demonstration.cpp.

Definition at line 163 of file Utility.hpp.

◆ programArgsExist()

bool flexiv::utility::programArgsExist ( int  argc,
char **  argv,
const std::string &  refStr 
)
inline

Check if one specific string exists in the program arguments.

Parameters
[in]argcArgument count passed to main() of the program.
[in]argvArgument vector passed to main() of the program, where argv[0] is the program name.
[in]refStrReference string to check against.
Returns
True if the program arguments contain this specific reference string.
Examples
intermediate1_realtime_joint_position_control.cpp, intermediate2_realtime_joint_torque_control.cpp, intermediate4_realtime_cartesian_pure_motion_control.cpp, and intermediate5_realtime_cartesian_motion_force_control.cpp.

Definition at line 149 of file Utility.hpp.

◆ programArgsExistAny()

bool flexiv::utility::programArgsExistAny ( int  argc,
char **  argv,
const std::vector< std::string > &  refStrs 
)
inline

Check if any provided strings exist in the program arguments.

Parameters
[in]argcArgument count passed to main() of the program.
[in]argvArgument vector passed to main() of the program, where argv[0] is the program name.
[in]refStrsReference strings to check against.
Returns
True if the program arguments contain one or more reference strings.
Examples
basics1_display_robot_states.cpp, basics2_clear_fault.cpp, basics3_primitive_execution.cpp, basics4_plan_execution.cpp, basics5_zero_force_torque_sensors.cpp, basics6_gripper_control.cpp, basics7_auto_recovery.cpp, intermediate1_realtime_joint_position_control.cpp, intermediate2_realtime_joint_torque_control.cpp, intermediate3_realtime_joint_floating.cpp, intermediate4_realtime_cartesian_pure_motion_control.cpp, intermediate5_realtime_cartesian_motion_force_control.cpp, intermediate6_robot_dynamics.cpp, and intermediate7_teach_by_demonstration.cpp.

Definition at line 128 of file Utility.hpp.

◆ quat2EulerZYX()

std::vector<double> flexiv::utility::quat2EulerZYX ( const std::vector< double > &  quat)
inline

Convert quaternion to Euler angles with ZYX axis rotations.

Parameters
[in]quatQuaternion input in [w,x,y,z] order.
Returns
Euler angles in [x,y,z] order [rad].
Note
The return value, when converted to degrees, is the same Euler angles used by Move primitives.
Exceptions
InputExceptionif input is of wrong size.
Examples
basics3_primitive_execution.cpp, and intermediate7_teach_by_demonstration.cpp.

Definition at line 25 of file Utility.hpp.

◆ vec2Str()

template<typename T >
std::string flexiv::utility::vec2Str ( const std::vector< T > &  vec,
size_t  decimal = 3,
bool  trailingSpace = true 
)
inline

Convert a std::vector to a string.

Parameters
[in]vecstd::vector of any type and size.
[in]decimalDecimal places to keep for each number in the vector.
[in]trailingSpaceWhether to include a space after the last element.
Returns
A string with format "vec[0] vec[1] ... vec[n] ", i.e. each element followed by a space, including the last one if trailingSpace = true.
Examples
basics3_primitive_execution.cpp, basics5_zero_force_torque_sensors.cpp, intermediate1_realtime_joint_position_control.cpp, intermediate2_realtime_joint_torque_control.cpp, intermediate4_realtime_cartesian_pure_motion_control.cpp, intermediate5_realtime_cartesian_motion_force_control.cpp, and intermediate7_teach_by_demonstration.cpp.

Definition at line 73 of file Utility.hpp.