1919
2020namespace rcs {
2121namespace hw {
22- Franka::Franka (const std::string & ip,
22+ Franka::Franka (const std::string& ip,
2323 std::optional<std::shared_ptr<common::Kinematics>> ik,
24- const std::optional<FrankaConfig> & cfg)
24+ const std::optional<FrankaConfig>& cfg)
2525 : robot(ip), m_ik(ik) {
2626 // set collision behavior and impedance
2727 this ->set_default_robot_behavior ();
@@ -35,7 +35,7 @@ Franka::Franka(const std::string &ip,
3535Franka::~Franka () {
3636 try {
3737 this ->stop_control_thread ();
38- } catch (const franka::Exception & e) {
38+ } catch (const franka::Exception& e) {
3939 std::cerr << " Exception in ~Franka(): " << e.what () << std::endl;
4040 }
4141}
@@ -45,7 +45,7 @@ Franka::~Franka() {
4545 * @param cfg The configuration for the robot, it should be a FrankaConfig type
4646 * otherwise the call will fail
4747 */
48- bool Franka::set_config (const FrankaConfig & cfg) {
48+ bool Franka::set_config (const FrankaConfig& cfg) {
4949 this ->cfg = cfg;
5050 this ->cfg .speed_factor = std::min (std::max (cfg.speed_factor , 0.0 ), 1.0 );
5151
@@ -66,16 +66,16 @@ bool Franka::set_config(const FrankaConfig &cfg) {
6666 return true ;
6767}
6868
69- FrankaConfig * Franka::get_config () {
69+ FrankaConfig* Franka::get_config () {
7070 // copy config to heap
71- FrankaConfig * cfg = new FrankaConfig ();
71+ FrankaConfig* cfg = new FrankaConfig ();
7272 *cfg = this ->cfg ;
7373 return cfg;
7474}
7575
76- FrankaState * Franka::get_state () {
76+ FrankaState* Franka::get_state () {
7777 // dummy state until we define a prober state
78- FrankaState * state = new FrankaState ();
78+ FrankaState* state = new FrankaState ();
7979 return state;
8080}
8181
@@ -105,7 +105,7 @@ common::Pose Franka::get_cartesian_position() {
105105 return x;
106106}
107107
108- void Franka::set_joint_position (const common::VectorXd & q) {
108+ void Franka::set_joint_position (const common::VectorXd& q) {
109109 if (this ->cfg .async_control ) {
110110 this ->controller_set_joint_position (q);
111111 return ;
@@ -134,7 +134,7 @@ void Franka::set_guiding_mode(bool x, bool y, bool z, bool roll, bool pitch,
134134 this ->robot .setGuidingMode (activated, elbow);
135135}
136136
137- void PInverse (const Eigen::MatrixXd & M, Eigen::MatrixXd & M_inv,
137+ void PInverse (const Eigen::MatrixXd& M, Eigen::MatrixXd& M_inv,
138138 double epsilon = 0.00025 ) {
139139 Eigen::JacobiSVD<Eigen::MatrixXd> svd (
140140 M, Eigen::ComputeFullU | Eigen::ComputeFullV);
@@ -153,7 +153,7 @@ void PInverse(const Eigen::MatrixXd &M, Eigen::MatrixXd &M_inv,
153153 M_inv = Eigen::MatrixXd (svd.matrixV () * S_inv * svd.matrixU ().transpose ());
154154}
155155
156- void TorqueSafetyGuardFn (std::array<double , 7 > & tau_d_array, double min_torque,
156+ void TorqueSafetyGuardFn (std::array<double , 7 >& tau_d_array, double min_torque,
157157 double max_torque) {
158158 for (size_t i = 0 ; i < tau_d_array.size (); i++) {
159159 if (tau_d_array[i] < min_torque) {
@@ -164,7 +164,7 @@ void TorqueSafetyGuardFn(std::array<double, 7> &tau_d_array, double min_torque,
164164 }
165165}
166166
167- void Franka::controller_set_joint_position (const common::Vector7d & desired_q) {
167+ void Franka::controller_set_joint_position (const common::Vector7d& desired_q) {
168168 // from deoxys/config/osc-position-controller.yml
169169 double traj_interpolation_time_fraction = 1.0 ; // in s
170170 // form deoxys/config/charmander.yml
@@ -199,7 +199,7 @@ void Franka::controller_set_joint_position(const common::Vector7d &desired_q) {
199199}
200200
201201void Franka::osc_set_cartesian_position (
202- const common::Pose & desired_pose_EE_in_base_frame) {
202+ const common::Pose& desired_pose_EE_in_base_frame) {
203203 // from deoxys/config/osc-position-controller.yml
204204 double traj_interpolation_time_fraction = 1.0 ;
205205 // form deoxys/config/charmander.yml
@@ -293,7 +293,7 @@ void Franka::osc() {
293293 joint_min_ << -2.8973 , -1.7628 , -2.8973 , -3.0718 , -2.8973 , -0.0175 , -2.8973 ;
294294 avoidance_weights_ << 1 ., 1 ., 1 ., 1 ., 1 ., 10 ., 10 .;
295295
296- this ->robot .control ([&](const franka::RobotState & robot_state,
296+ this ->robot .control ([&](const franka::RobotState& robot_state,
297297 franka::Duration period) -> franka::Torques {
298298 std::chrono::high_resolution_clock::time_point t1 =
299299 std::chrono::high_resolution_clock::now ();
@@ -484,7 +484,7 @@ void Franka::joint_controller() {
484484 joint_max_ << 2.8978 , 1.7628 , 2.8973 , -0.0698 , 2.8973 , 3.7525 , 2.8973 ;
485485 joint_min_ << -2.8973 , -1.7628 , -2.8973 , -3.0718 , -2.8973 , -0.0175 , -2.8973 ;
486486
487- this ->robot .control ([&](const franka::RobotState & robot_state,
487+ this ->robot .control ([&](const franka::RobotState& robot_state,
488488 franka::Duration period) -> franka::Torques {
489489 std::chrono::high_resolution_clock::time_point t1 =
490490 std::chrono::high_resolution_clock::now ();
@@ -570,7 +570,7 @@ void Franka::zero_torque_controller() {
570570 {{100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 }});
571571
572572 this ->controller_time = 0.0 ;
573- this ->robot .control ([&](const franka::RobotState & robot_state,
573+ this ->robot .control ([&](const franka::RobotState& robot_state,
574574 franka::Duration period) -> franka::Torques {
575575 this ->interpolator_mutex .lock ();
576576 this ->curr_state = robot_state;
@@ -613,7 +613,7 @@ void Franka::double_tap_robot_to_continue() {
613613 auto last_time_something_happened = std::chrono::system_clock::now ();
614614 auto last_time_something_touched = std::chrono::system_clock::now ();
615615 start_force << s.O_F_ext_hat_K [0 ], s.O_F_ext_hat_K [1 ], s.O_F_ext_hat_K [2 ];
616- this ->robot .read ([&](const franka::RobotState & robot_state) {
616+ this ->robot .read ([&](const franka::RobotState& robot_state) {
617617 Eigen::Vector3d force;
618618 force << robot_state.O_F_ext_hat_K [0 ], robot_state.O_F_ext_hat_K [1 ],
619619 robot_state.O_F_ext_hat_K [2 ];
@@ -663,7 +663,7 @@ std::optional<std::shared_ptr<common::Kinematics>> Franka::get_ik() {
663663 return this ->m_ik ;
664664}
665665
666- void Franka::set_cartesian_position (const common::Pose & x) {
666+ void Franka::set_cartesian_position (const common::Pose& x) {
667667 // pose is assumed to be in the robots coordinate frame
668668 if (this ->cfg .async_control ) {
669669 this ->osc_set_cartesian_position (x);
@@ -691,7 +691,7 @@ void Franka::set_cartesian_position(const common::Pose &x) {
691691 }
692692}
693693
694- void Franka::set_cartesian_position_ik (const common::Pose & pose) {
694+ void Franka::set_cartesian_position_ik (const common::Pose& pose) {
695695 if (!this ->m_ik .has_value ()) {
696696 throw std::runtime_error (
697697 " No inverse kinematics was provided. Cannot use IK to set cartesian "
@@ -714,14 +714,14 @@ common::Pose Franka::get_base_pose_in_world_coordinates() {
714714 : common::Pose ();
715715}
716716
717- void Franka::set_cartesian_position_internal (const common::Pose & pose,
717+ void Franka::set_cartesian_position_internal (const common::Pose& pose,
718718 double max_time,
719719 std::optional<double > elbow,
720720 std::optional<double > max_force) {
721721 // TODO: use speed factor instead of max_time
722722 common::Pose initial_pose = this ->get_cartesian_position ();
723723
724- auto force_stop_condition = [&max_force](const franka::RobotState & state,
724+ auto force_stop_condition = [&max_force](const franka::RobotState& state,
725725 const double progress) {
726726 Eigen::Vector3d force;
727727 force << state.O_F_ext_hat_K [0 ], state.O_F_ext_hat_K [1 ],
@@ -737,7 +737,7 @@ void Franka::set_cartesian_position_internal(const common::Pose &pose,
737737 this ->robot .control (
738738 [&force_stop_condition, &initial_elbow, &elbow, &max_force, &time,
739739 &max_time, &initial_pose, &should_stop,
740- &pose](const franka::RobotState & state,
740+ &pose](const franka::RobotState& state,
741741 franka::Duration time_step) -> franka::CartesianPose {
742742 time += time_step.toSec ();
743743 if (time == 0 ) {
0 commit comments