Skip to content

Commit 37317a0

Browse files
committed
refactor: rename fr3 to panda
1 parent 79f1dee commit 37317a0

File tree

14 files changed

+131
-856
lines changed

14 files changed

+131
-856
lines changed

extensions/rcs_panda/src/hw/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_library(hw)
2-
target_sources(hw PRIVATE FR3.cpp FrankaHand.cpp FR3MotionGenerator.cpp)
2+
target_sources(hw PRIVATE Panda.cpp FrankaHand.cpp PandaMotionGenerator.cpp)
33
target_link_libraries(
44
hw
55
PUBLIC franka rcs pinocchio::all

extensions/rcs_panda/src/hw/Panda.cpp

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "FR3.h"
1+
#include "Panda.h"
22

33
#include <franka/duration.h>
44
#include <franka/exception.h>
@@ -14,13 +14,13 @@
1414
#include <string>
1515
#include <thread>
1616

17-
#include "FR3MotionGenerator.h"
17+
#include "PandaMotionGenerator.h"
1818
#include "rcs/Pose.h"
1919

2020
namespace rcs {
2121
namespace 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) {

extensions/rcs_panda/src/hw/Panda.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef RCS_FR3_H
2-
#define RCS_FR3_H
1+
#ifndef RCS_Panda_H
2+
#define RCS_Panda_H
33

44
#include <franka/robot.h>
55

@@ -21,7 +21,7 @@ namespace hw {
2121

2222
const double DEFAULT_SPEED_FACTOR = 0.2;
2323

24-
struct FR3Load {
24+
struct PandaLoad {
2525
double load_mass;
2626
std::optional<Eigen::Vector3d> f_x_cload;
2727
std::optional<Eigen::Matrix3d> load_inertia;
@@ -30,24 +30,24 @@ enum IKSolver { franka_ik = 0, rcs_ik };
3030
// modes: joint-space control, operational-space control, zero-torque
3131
// control
3232
enum Controller { none = 0, jsc, osc, ztc };
33-
struct FR3Config : common::RobotConfig {
33+
struct PandaConfig : common::RobotConfig {
3434
// TODO: max force and elbow?
3535
// TODO: we can either write specific bindings for each, or we use python
3636
// dictionaries with these objects
3737
IKSolver ik_solver = IKSolver::franka_ik;
3838
double speed_factor = DEFAULT_SPEED_FACTOR;
39-
std::optional<FR3Load> load_parameters = std::nullopt;
39+
std::optional<PandaLoad> load_parameters = std::nullopt;
4040
std::optional<common::Pose> nominal_end_effector_frame = std::nullopt;
4141
std::optional<common::Pose> world_to_robot = std::nullopt;
4242
bool async_control = false;
4343
};
4444

45-
struct FR3State : common::RobotState {};
45+
struct PandaState : common::RobotState {};
4646

47-
class FR3 : public common::Robot {
47+
class Panda : public common::Robot {
4848
private:
4949
franka::Robot robot;
50-
FR3Config cfg;
50+
PandaConfig cfg;
5151
std::optional<std::shared_ptr<common::IK>> m_ik;
5252
std::optional<std::thread> control_thread = std::nullopt;
5353
common::LinearPoseTrajInterpolator traj_interpolator;
@@ -61,16 +61,16 @@ class FR3 : public common::Robot {
6161
void zero_torque_controller();
6262

6363
public:
64-
FR3(const std::string &ip,
64+
Panda(const std::string &ip,
6565
std::optional<std::shared_ptr<common::IK>> ik = std::nullopt,
66-
const std::optional<FR3Config> &cfg = std::nullopt);
67-
~FR3() override;
66+
const std::optional<PandaConfig> &cfg = std::nullopt);
67+
~Panda() override;
6868

69-
bool set_parameters(const FR3Config &cfg);
69+
bool set_parameters(const PandaConfig &cfg);
7070

71-
FR3Config *get_parameters() override;
71+
PandaConfig *get_parameters() override;
7272

73-
FR3State *get_state() override;
73+
PandaState *get_state() override;
7474

7575
void set_default_robot_behavior();
7676

@@ -117,4 +117,4 @@ class FR3 : public common::Robot {
117117
} // namespace hw
118118
} // namespace rcs
119119

120-
#endif // RCS_FR3_H
120+
#endif // RCS_Panda_H

extensions/rcs_panda/src/hw/PandaMotionGenerator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "FR3MotionGenerator.h"
1+
#include "PandaMotionGenerator.h"
22

33
#include <franka/exception.h>
44
#include <franka/robot.h>
@@ -23,7 +23,7 @@ void setDefaultBehavior(franka::Robot& robot) {
2323
robot.setCartesianImpedance({{3000, 3000, 3000, 300, 300, 300}});
2424
}
2525

26-
FR3MotionGenerator::FR3MotionGenerator(double speed_factor,
26+
PandaMotionGenerator::PandaMotionGenerator(double speed_factor,
2727
const common::Vector7d q_goal)
2828
: q_goal_(q_goal) {
2929
dq_max_ *= speed_factor;
@@ -38,7 +38,7 @@ FR3MotionGenerator::FR3MotionGenerator(double speed_factor,
3838
q_1_.setZero();
3939
}
4040

41-
bool FR3MotionGenerator::calculateDesiredValues(
41+
bool PandaMotionGenerator::calculateDesiredValues(
4242
double t, common::Vector7d* delta_q_d) const {
4343
common::Vector7i sign_delta_q;
4444
sign_delta_q << delta_q_.cwiseSign().cast<int>();
@@ -78,7 +78,7 @@ bool FR3MotionGenerator::calculateDesiredValues(
7878
joint_motion_finished.cend(), [](bool x) { return x; });
7979
}
8080

81-
void FR3MotionGenerator::calculateSynchronizedValues() {
81+
void PandaMotionGenerator::calculateSynchronizedValues() {
8282
common::Vector7d dq_max_reach(dq_max_);
8383
common::Vector7d t_f = common::Vector7d::Zero();
8484
common::Vector7d delta_t_2 = common::Vector7d::Zero();
@@ -123,7 +123,7 @@ void FR3MotionGenerator::calculateSynchronizedValues() {
123123
}
124124
}
125125

126-
franka::JointPositions FR3MotionGenerator::operator()(
126+
franka::JointPositions PandaMotionGenerator::operator()(
127127
const franka::RobotState& robot_state, franka::Duration period) {
128128
time_ += period.toSec();
129129

0 commit comments

Comments
 (0)