1- #include " FR3 .h"
1+ #include " Panda .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 " PandaMotionGenerator .h"
1818#include " rcs/Pose.h"
1919
2020namespace rcs {
2121namespace hw {
22- FR3::FR3 (const std::string &ip, std::optional<std::shared_ptr<common::IK>> ik,
23- const std::optional<FR3Config > &cfg)
22+ Panda::Panda (const std::string &ip, std::optional<std::shared_ptr<common::IK>> ik,
23+ const std::optional<PandaConfig > &cfg)
2424 : robot(ip), m_ik(ik) {
2525 // set collision behavior and impedance
2626 this ->set_default_robot_behavior ();
@@ -31,14 +31,14 @@ FR3::FR3(const std::string &ip, std::optional<std::shared_ptr<common::IK>> ik,
3131 } // else default constructor
3232}
3333
34- FR3 ::~FR3 () {}
34+ Panda ::~Panda () {}
3535
3636/* *
3737 * @brief Set the parameters for the robot
38- * @param cfg The configuration for the robot, it should be a FR3Config type
38+ * @param cfg The configuration for the robot, it should be a PandaConfig type
3939 * otherwise the call will fail
4040 */
41- bool FR3 ::set_parameters (const FR3Config &cfg) {
41+ bool Panda ::set_parameters (const PandaConfig &cfg) {
4242 this ->cfg = cfg;
4343 this ->cfg .speed_factor = std::min (std::max (cfg.speed_factor , 0.0 ), 1.0 );
4444
@@ -59,20 +59,20 @@ bool FR3::set_parameters(const FR3Config &cfg) {
5959 return true ;
6060}
6161
62- FR3Config * FR3 ::get_parameters () {
62+ PandaConfig * Panda ::get_parameters () {
6363 // copy config to heap
64- FR3Config *cfg = new FR3Config ();
64+ PandaConfig *cfg = new PandaConfig ();
6565 *cfg = this ->cfg ;
6666 return cfg;
6767}
6868
69- FR3State * FR3 ::get_state () {
69+ PandaState * Panda ::get_state () {
7070 // dummy state until we define a prober state
71- FR3State *state = new FR3State ();
71+ PandaState *state = new PandaState ();
7272 return state;
7373}
7474
75- void FR3 ::set_default_robot_behavior () {
75+ void Panda ::set_default_robot_behavior () {
7676 this ->robot .setCollisionBehavior ({{20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 }},
7777 {{20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 , 20.0 }},
7878 {{10.0 , 10.0 , 10.0 , 10.0 , 10.0 , 10.0 , 10.0 }},
@@ -85,7 +85,7 @@ void FR3::set_default_robot_behavior() {
8585 this ->robot .setCartesianImpedance ({{3000 , 3000 , 3000 , 300 , 300 , 300 }});
8686}
8787
88- common::Pose FR3 ::get_cartesian_position () {
88+ common::Pose Panda ::get_cartesian_position () {
8989 common::Pose x;
9090 if (this ->running_controller == Controller::none) {
9191 this ->curr_state = this ->robot .readOnce ();
@@ -98,17 +98,17 @@ common::Pose FR3::get_cartesian_position() {
9898 return x;
9999}
100100
101- void FR3 ::set_joint_position (const common::VectorXd &q) {
101+ void Panda ::set_joint_position (const common::VectorXd &q) {
102102 if (this ->cfg .async_control ) {
103103 this ->controller_set_joint_position (q);
104104 return ;
105105 }
106106 // sync control
107- FR3MotionGenerator motion_generator (this ->cfg .speed_factor , q);
107+ PandaMotionGenerator motion_generator (this ->cfg .speed_factor , q);
108108 this ->robot .control (motion_generator);
109109}
110110
111- common::VectorXd FR3 ::get_joint_position () {
111+ common::VectorXd Panda ::get_joint_position () {
112112 common::Vector7d joints;
113113 if (this ->running_controller == Controller::none) {
114114 this ->curr_state = this ->robot .readOnce ();
@@ -121,7 +121,7 @@ common::VectorXd FR3::get_joint_position() {
121121 return joints;
122122}
123123
124- void FR3 ::set_guiding_mode (bool x, bool y, bool z, bool roll, bool pitch,
124+ void Panda ::set_guiding_mode (bool x, bool y, bool z, bool roll, bool pitch,
125125 bool yaw, bool elbow) {
126126 std::array<bool , 6 > activated = {x, y, z, roll, pitch, yaw};
127127 this ->robot .setGuidingMode (activated, elbow);
@@ -157,7 +157,7 @@ void TorqueSafetyGuardFn(std::array<double, 7> &tau_d_array, double min_torque,
157157 }
158158}
159159
160- void FR3 ::controller_set_joint_position (const common::Vector7d &desired_q) {
160+ void Panda ::controller_set_joint_position (const common::Vector7d &desired_q) {
161161 // from deoxys/config/osc-position-controller.yml
162162 double traj_interpolation_time_fraction = 1.0 ; // in s
163163 // form deoxys/config/charmander.yml
@@ -185,13 +185,13 @@ void FR3::controller_set_joint_position(const common::Vector7d &desired_q) {
185185 // if not thread is running, then start
186186 if (this ->running_controller == Controller::none) {
187187 this ->running_controller = Controller::jsc;
188- this ->control_thread = std::thread (&FR3 ::joint_controller, this );
188+ this ->control_thread = std::thread (&Panda ::joint_controller, this );
189189 } else {
190190 this ->interpolator_mutex .unlock ();
191191 }
192192}
193193
194- void FR3 ::osc_set_cartesian_position (
194+ void Panda ::osc_set_cartesian_position (
195195 const common::Pose &desired_pose_EE_in_base_frame) {
196196 // from deoxys/config/osc-position-controller.yml
197197 double traj_interpolation_time_fraction = 1.0 ;
@@ -221,14 +221,14 @@ void FR3::osc_set_cartesian_position(
221221 // if not thread is running, then start
222222 if (this ->running_controller == Controller::none) {
223223 this ->running_controller = Controller::osc;
224- this ->control_thread = std::thread (&FR3 ::osc, this );
224+ this ->control_thread = std::thread (&Panda ::osc, this );
225225 } else {
226226 this ->interpolator_mutex .unlock ();
227227 }
228228}
229229
230230// method to stop thread
231- void FR3 ::stop_control_thread () {
231+ void Panda ::stop_control_thread () {
232232 if (this ->control_thread .has_value () &&
233233 this ->running_controller != Controller::none) {
234234 this ->running_controller = Controller::none;
@@ -237,7 +237,7 @@ void FR3::stop_control_thread() {
237237 }
238238}
239239
240- void FR3 ::osc () {
240+ void Panda ::osc () {
241241 franka::Model model = this ->robot .loadModel ();
242242
243243 this ->controller_time = 0.0 ;
@@ -450,7 +450,7 @@ void FR3::osc() {
450450 });
451451}
452452
453- void FR3 ::joint_controller () {
453+ void Panda ::joint_controller () {
454454 franka::Model model = this ->robot .loadModel ();
455455 this ->controller_time = 0.0 ;
456456
@@ -544,17 +544,17 @@ void FR3::joint_controller() {
544544 });
545545}
546546
547- void FR3 ::zero_torque_guiding () {
547+ void Panda ::zero_torque_guiding () {
548548 if (this ->running_controller != Controller::none) {
549549 throw std::runtime_error (
550550 " A controller is currently running. Please stop it first." );
551551 }
552552 this ->controller_time = 0.0 ;
553553 this ->running_controller = Controller::ztc;
554- this ->control_thread = std::thread (&FR3 ::zero_torque_controller, this );
554+ this ->control_thread = std::thread (&Panda ::zero_torque_controller, this );
555555}
556556
557- void FR3 ::zero_torque_controller () {
557+ void Panda ::zero_torque_controller () {
558558 // high collision threshold values for high impedance
559559 robot.setCollisionBehavior (
560560 {{100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 , 100.0 }},
@@ -577,26 +577,26 @@ void FR3::zero_torque_controller() {
577577 });
578578}
579579
580- void FR3 ::move_home () {
580+ void Panda ::move_home () {
581581 // sync
582- FR3MotionGenerator motion_generator (
582+ PandaMotionGenerator motion_generator (
583583 this ->cfg .speed_factor ,
584- common::robots_meta_config.at (common::RobotType::FR3 ).q_home );
584+ common::robots_meta_config.at (common::RobotType::Panda ).q_home );
585585 this ->robot .control (motion_generator);
586586}
587587
588- void FR3 ::automatic_error_recovery () { this ->robot .automaticErrorRecovery (); }
588+ void Panda ::automatic_error_recovery () { this ->robot .automaticErrorRecovery (); }
589589
590- void FR3 ::reset () {
590+ void Panda ::reset () {
591591 this ->stop_control_thread ();
592592 this ->automatic_error_recovery ();
593593}
594594
595- void FR3 ::wait_milliseconds (int milliseconds) {
595+ void Panda ::wait_milliseconds (int milliseconds) {
596596 std::this_thread::sleep_for (std::chrono::milliseconds (milliseconds));
597597}
598598
599- void FR3 ::double_tap_robot_to_continue () {
599+ void Panda ::double_tap_robot_to_continue () {
600600 auto s = this ->robot .readOnce ();
601601 int touch_counter = false ;
602602 bool can_be_touched_again = true ;
@@ -650,9 +650,9 @@ double quintic_polynomial_speed_profile(double time, double start_time,
650650 // return (1 - std::cos(M_PI * progress)) / 2.0;
651651}
652652
653- std::optional<std::shared_ptr<common::IK>> FR3 ::get_ik () { return this ->m_ik ; }
653+ std::optional<std::shared_ptr<common::IK>> Panda ::get_ik () { return this ->m_ik ; }
654654
655- void FR3 ::set_cartesian_position (const common::Pose &x) {
655+ void Panda ::set_cartesian_position (const common::Pose &x) {
656656 // pose is assumed to be in the robots coordinate frame
657657 if (this ->cfg .async_control ) {
658658 this ->osc_set_cartesian_position (x);
@@ -680,7 +680,7 @@ void FR3::set_cartesian_position(const common::Pose &x) {
680680 }
681681}
682682
683- void FR3 ::set_cartesian_position_ik (const common::Pose &pose) {
683+ void Panda ::set_cartesian_position_ik (const common::Pose &pose) {
684684 if (!this ->m_ik .has_value ()) {
685685 throw std::runtime_error (
686686 " No inverse kinematics was provided. Cannot use IK to set cartesian "
@@ -698,12 +698,12 @@ void FR3::set_cartesian_position_ik(const common::Pose &pose) {
698698 }
699699}
700700
701- common::Pose FR3 ::get_base_pose_in_world_coordinates () {
701+ common::Pose Panda ::get_base_pose_in_world_coordinates () {
702702 return this ->cfg .world_to_robot .has_value () ? this ->cfg .world_to_robot .value ()
703703 : common::Pose ();
704704}
705705
706- void FR3 ::set_cartesian_position_internal (const common::Pose &pose,
706+ void Panda ::set_cartesian_position_internal (const common::Pose &pose,
707707 double max_time,
708708 std::optional<double > elbow,
709709 std::optional<double > max_force) {
0 commit comments