1- #include " FR3 .h"
1+ #include " Franka .h"
22
33#include < franka/duration.h>
44#include < franka/exception.h>
1414#include < string>
1515#include < thread>
1616
17- #include " FR3MotionGenerator .h"
17+ #include " FrankaMotionGenerator .h"
1818#include " rcs/Pose.h"
1919
2020namespace rcs {
2121namespace hw {
22- FR3::FR3 (const std::string &ip,
22+ Franka::Franka (const std::string &ip,
2323 std::optional<std::shared_ptr<common::Kinematics>> ik,
24- const std::optional<FR3Config > &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 ();
@@ -32,14 +32,14 @@ FR3::FR3(const std::string &ip,
3232 } // else default constructor
3333}
3434
35- FR3 ::~FR3 () {}
35+ Franka ::~Franka () {}
3636
3737/* *
3838 * @brief Set the parameters for the robot
39- * @param cfg The configuration for the robot, it should be a FR3Config type
39+ * @param cfg The configuration for the robot, it should be a FrankaConfig type
4040 * otherwise the call will fail
4141 */
42- bool FR3 ::set_config (const FR3Config &cfg) {
42+ bool Franka ::set_config (const FrankaConfig &cfg) {
4343 this ->cfg = cfg;
4444 this ->cfg .speed_factor = std::min (std::max (cfg.speed_factor , 0.0 ), 1.0 );
4545
@@ -60,20 +60,20 @@ bool FR3::set_config(const FR3Config &cfg) {
6060 return true ;
6161}
6262
63- FR3Config * FR3 ::get_config() {
63+ FrankaConfig * Franka ::get_config () {
6464 // copy config to heap
65- FR3Config *cfg = new FR3Config ();
65+ FrankaConfig *cfg = new FrankaConfig ();
6666 *cfg = this ->cfg ;
6767 return cfg;
6868}
6969
70- FR3State * FR3 ::get_state() {
70+ FrankaState * Franka ::get_state () {
7171 // dummy state until we define a prober state
72- FR3State *state = new FR3State ();
72+ FrankaState *state = new FrankaState ();
7373 return state;
7474}
7575
76- void FR3 ::set_default_robot_behavior () {
76+ void Franka ::set_default_robot_behavior () {
7777 this ->robot .setCollisionBehavior ({{20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 }},
7878 {{20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 }},
7979 {{10.0 , 10.0 , 10.0 , 10.0 , 10.0 , 10.0 , 10.0 }},
@@ -86,7 +86,7 @@ void FR3::set_default_robot_behavior() {
8686 this ->robot .setCartesianImpedance ({{3000 , 3000 , 3000 , 300 , 300 , 300 }});
8787}
8888
89- common::Pose FR3 ::get_cartesian_position () {
89+ common::Pose Franka ::get_cartesian_position () {
9090 common::Pose x;
9191 if (this ->running_controller == Controller::none) {
9292 this ->curr_state = this ->robot .readOnce ();
@@ -99,17 +99,17 @@ common::Pose FR3::get_cartesian_position() {
9999 return x;
100100}
101101
102- void FR3 ::set_joint_position (const common::VectorXd &q) {
102+ void Franka ::set_joint_position (const common::VectorXd &q) {
103103 if (this ->cfg .async_control ) {
104104 this ->controller_set_joint_position (q);
105105 return ;
106106 }
107107 // sync control
108- FR3MotionGenerator motion_generator (this ->cfg .speed_factor , q);
108+ FrankaMotionGenerator motion_generator (this ->cfg .speed_factor , q);
109109 this ->robot .control (motion_generator);
110110}
111111
112- common::VectorXd FR3 ::get_joint_position () {
112+ common::VectorXd Franka ::get_joint_position () {
113113 common::Vector7d joints;
114114 if (this ->running_controller == Controller::none) {
115115 this ->curr_state = this ->robot .readOnce ();
@@ -122,7 +122,7 @@ common::VectorXd FR3::get_joint_position() {
122122 return joints;
123123}
124124
125- void FR3 ::set_guiding_mode (bool x, bool y, bool z, bool roll, bool pitch,
125+ void Franka ::set_guiding_mode (bool x, bool y, bool z, bool roll, bool pitch,
126126 bool yaw, bool elbow) {
127127 std::array<bool , 6 > activated = {x, y, z, roll, pitch, yaw};
128128 this ->robot .setGuidingMode (activated, elbow);
@@ -158,7 +158,7 @@ void TorqueSafetyGuardFn(std::array<double, 7> &tau_d_array, double min_torque,
158158 }
159159}
160160
161- void FR3 ::controller_set_joint_position (const common::Vector7d &desired_q) {
161+ void Franka ::controller_set_joint_position (const common::Vector7d &desired_q) {
162162 // from deoxys/config/osc-position-controller.yml
163163 double traj_interpolation_time_fraction = 1.0 ; // in s
164164 // form deoxys/config/charmander.yml
@@ -186,13 +186,13 @@ void FR3::controller_set_joint_position(const common::Vector7d &desired_q) {
186186 // if not thread is running, then start
187187 if (this ->running_controller == Controller::none) {
188188 this ->running_controller = Controller::jsc;
189- this ->control_thread = std::thread (&FR3 ::joint_controller, this );
189+ this ->control_thread = std::thread (&Franka ::joint_controller, this );
190190 } else {
191191 this ->interpolator_mutex .unlock ();
192192 }
193193}
194194
195- void FR3 ::osc_set_cartesian_position (
195+ void Franka ::osc_set_cartesian_position (
196196 const common::Pose &desired_pose_EE_in_base_frame) {
197197 // from deoxys/config/osc-position-controller.yml
198198 double traj_interpolation_time_fraction = 1.0 ;
@@ -222,14 +222,14 @@ void FR3::osc_set_cartesian_position(
222222 // if not thread is running, then start
223223 if (this ->running_controller == Controller::none) {
224224 this ->running_controller = Controller::osc;
225- this ->control_thread = std::thread (&FR3 ::osc, this );
225+ this ->control_thread = std::thread (&Franka ::osc, this );
226226 } else {
227227 this ->interpolator_mutex .unlock ();
228228 }
229229}
230230
231231// method to stop thread
232- void FR3 ::stop_control_thread () {
232+ void Franka ::stop_control_thread () {
233233 if (this ->control_thread .has_value () &&
234234 this ->running_controller != Controller::none) {
235235 this ->running_controller = Controller::none;
@@ -238,7 +238,7 @@ void FR3::stop_control_thread() {
238238 }
239239}
240240
241- void FR3 ::osc () {
241+ void Franka ::osc () {
242242 franka::Model model = this ->robot .loadModel ();
243243
244244 this ->controller_time = 0.0 ;
@@ -451,7 +451,7 @@ void FR3::osc() {
451451 });
452452}
453453
454- void FR3 ::joint_controller () {
454+ void Franka ::joint_controller () {
455455 franka::Model model = this ->robot .loadModel ();
456456 this ->controller_time = 0.0 ;
457457
@@ -545,17 +545,17 @@ void FR3::joint_controller() {
545545 });
546546}
547547
548- void FR3 ::zero_torque_guiding () {
548+ void Franka ::zero_torque_guiding () {
549549 if (this ->running_controller != Controller::none) {
550550 throw std::runtime_error (
551551 " A controller is currently running. Please stop it first." );
552552 }
553553 this ->controller_time = 0.0 ;
554554 this ->running_controller = Controller::ztc;
555- this ->control_thread = std::thread (&FR3 ::zero_torque_controller, this );
555+ this ->control_thread = std::thread (&Franka ::zero_torque_controller, this );
556556}
557557
558- void FR3 ::zero_torque_controller () {
558+ void Franka ::zero_torque_controller () {
559559 // high collision threshold values for high impedance
560560 robot.setCollisionBehavior (
561561 {{100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 }},
@@ -578,26 +578,26 @@ void FR3::zero_torque_controller() {
578578 });
579579}
580580
581- void FR3 ::move_home () {
581+ void Franka ::move_home () {
582582 // sync
583- FR3MotionGenerator motion_generator (
583+ FrankaMotionGenerator motion_generator (
584584 this ->cfg .speed_factor ,
585- common::robots_meta_config.at (common::RobotType:: FR3 ).q_home );
585+ common::robots_meta_config.at (this -> cfg . robot_type ).q_home );
586586 this ->robot .control (motion_generator);
587587}
588588
589- void FR3 ::automatic_error_recovery () { this ->robot .automaticErrorRecovery (); }
589+ void Franka ::automatic_error_recovery () { this ->robot .automaticErrorRecovery (); }
590590
591- void FR3 ::reset () {
591+ void Franka ::reset () {
592592 this ->stop_control_thread ();
593593 this ->automatic_error_recovery ();
594594}
595595
596- void FR3 ::wait_milliseconds (int milliseconds) {
596+ void Franka ::wait_milliseconds (int milliseconds) {
597597 std::this_thread::sleep_for (std::chrono::milliseconds (milliseconds));
598598}
599599
600- void FR3 ::double_tap_robot_to_continue () {
600+ void Franka ::double_tap_robot_to_continue () {
601601 auto s = this ->robot .readOnce ();
602602 int touch_counter = false ;
603603 bool can_be_touched_again = true ;
@@ -651,11 +651,11 @@ double quintic_polynomial_speed_profile(double time, double start_time,
651651 // return (1 - std::cos(M_PI * progress)) / 2.0;
652652}
653653
654- std::optional<std::shared_ptr<common::Kinematics>> FR3 ::get_ik () {
654+ std::optional<std::shared_ptr<common::Kinematics>> Franka ::get_ik () {
655655 return this ->m_ik ;
656656}
657657
658- void FR3 ::set_cartesian_position (const common::Pose &x) {
658+ void Franka ::set_cartesian_position (const common::Pose &x) {
659659 // pose is assumed to be in the robots coordinate frame
660660 if (this ->cfg .async_control ) {
661661 this ->osc_set_cartesian_position (x);
@@ -683,7 +683,7 @@ void FR3::set_cartesian_position(const common::Pose &x) {
683683 }
684684}
685685
686- void FR3 ::set_cartesian_position_ik (const common::Pose &pose) {
686+ void Franka ::set_cartesian_position_ik (const common::Pose &pose) {
687687 if (!this ->m_ik .has_value ()) {
688688 throw std::runtime_error (
689689 " No inverse kinematics was provided. Cannot use IK to set cartesian "
@@ -701,12 +701,12 @@ void FR3::set_cartesian_position_ik(const common::Pose &pose) {
701701 }
702702}
703703
704- common::Pose FR3 ::get_base_pose_in_world_coordinates () {
704+ common::Pose Franka ::get_base_pose_in_world_coordinates () {
705705 return this ->cfg .world_to_robot .has_value () ? this ->cfg .world_to_robot .value ()
706706 : common::Pose ();
707707}
708708
709- void FR3 ::set_cartesian_position_internal (const common::Pose &pose,
709+ void Franka ::set_cartesian_position_internal (const common::Pose &pose,
710710 double max_time,
711711 std::optional<double > elbow,
712712 std::optional<double > max_force) {
0 commit comments