Skip to content

Commit 7d43df4

Browse files
committed
temp osc
1 parent 941cba4 commit 7d43df4

File tree

6 files changed

+713
-0
lines changed

6 files changed

+713
-0
lines changed

python/rcsss/_core/hw/__init__.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,19 @@ class FR3(rcsss._core.common.Robot):
5252
def double_tap_robot_to_continue(self) -> None: ...
5353
def get_parameters(self) -> FR3Config: ...
5454
def get_state(self) -> FR3State: ...
55+
def osc2_set_cartesian_position(self, desired_pose_EE_in_base_frame: rcsss._core.common.Pose) -> None: ...
56+
def osc_set_cartesian_position(
57+
self, desired_pos_EE_in_base_frame: numpy.ndarray[typing.Literal[3], numpy.dtype[numpy.float64]]
58+
) -> None: ...
5559
def set_cartesian_position_ik(
5660
self, pose: rcsss._core.common.Pose, max_time: float, elbow: float | None, max_force: float | None = 5
5761
) -> None: ...
5862
def set_cartesian_position_internal(self, pose: rcsss._core.common.Pose) -> None: ...
5963
def set_default_robot_behavior(self) -> None: ...
6064
def set_guiding_mode(self, enabled: bool) -> None: ...
6165
def set_parameters(self, cfg: FR3Config) -> bool: ...
66+
def stop_control_thread(self) -> None: ...
67+
def zero_torque(self) -> None: ...
6268

6369
class FR3Config(rcsss._core.common.RConfig):
6470
controller: IKController

python/rcsss/control/fr3_desk.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ def __init__(self, hostname: str, username: str, password: str) -> None:
161161
"down": False,
162162
"up": False,
163163
}
164+
# Create an SSLContext that doesn't verify certificates
165+
self.ssl_context = ssl.create_default_context()
166+
self.ssl_context.check_hostname = False # Disable hostname verification
167+
self.ssl_context.verify_mode = ssl.CERT_NONE # Disable certificate verification
168+
164169
self.login()
165170

166171
def __enter__(self) -> "Desk":
@@ -322,6 +327,7 @@ def take_control(self, force: bool = False) -> bool:
322327
f"wss://{self._hostname}/desk/api/navigation/events",
323328
server_hostname="robot.franka.de",
324329
additional_headers={"authorization": self._session.cookies.get("authorization")}, # type: ignore[arg-type]
330+
ssl_context=self.ssl_context,
325331
) as websocket:
326332
while True:
327333
event: dict = json_module.loads(websocket.recv(timeout))
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#ifndef DEOXYS_FRANKA_INTERFACE_INCLUDE_UTILS_TRAJ_INTERPOLATORS_POSE_TRAJ_INTERPOLATOR_H_
2+
#define DEOXYS_FRANKA_INTERFACE_INCLUDE_UTILS_TRAJ_INTERPOLATORS_POSE_TRAJ_INTERPOLATOR_H_
3+
#include <Eigen/Dense>
4+
5+
namespace rcs {
6+
namespace common {
7+
8+
class LinearPoseTrajInterpolator {
9+
private:
10+
Eigen::Vector3d p_start_;
11+
Eigen::Vector3d p_goal_;
12+
Eigen::Vector3d last_p_t_;
13+
Eigen::Vector3d prev_p_goal_;
14+
15+
Eigen::Quaterniond q_start_;
16+
Eigen::Quaterniond q_goal_;
17+
Eigen::Quaterniond last_q_t_;
18+
Eigen::Quaterniond prev_q_goal_;
19+
20+
double dt_;
21+
double last_time_;
22+
double max_time_;
23+
double start_time_;
24+
bool start_;
25+
bool first_goal_;
26+
27+
public:
28+
inline LinearPoseTrajInterpolator()
29+
: dt_(0.),
30+
last_time_(0.),
31+
max_time_(1.),
32+
start_time_(0.),
33+
start_(false),
34+
first_goal_(true) {};
35+
36+
inline ~LinearPoseTrajInterpolator() {};
37+
38+
inline void Reset(const double &time_sec, const Eigen::Vector3d &p_start,
39+
const Eigen::Quaterniond &q_start,
40+
const Eigen::Vector3d &p_goal,
41+
const Eigen::Quaterniond &q_goal, const int &policy_rate,
42+
const int &rate,
43+
const double &traj_interpolator_time_fraction) {
44+
dt_ = 1. / static_cast<double>(rate);
45+
last_time_ = time_sec;
46+
max_time_ =
47+
1. / static_cast<double>(policy_rate) * traj_interpolator_time_fraction;
48+
start_time_ = time_sec;
49+
50+
start_ = false;
51+
52+
if (first_goal_) {
53+
p_start_ = p_start;
54+
q_start_ = q_start;
55+
56+
prev_p_goal_ = p_start;
57+
prev_q_goal_ = q_start;
58+
first_goal_ = false;
59+
} else {
60+
// If the goal is already set, use prev goal as the starting point of
61+
// interpolation.
62+
prev_p_goal_ = p_goal_;
63+
prev_q_goal_ = q_goal_;
64+
65+
p_start_ = prev_p_goal_;
66+
q_start_ = prev_q_goal_;
67+
}
68+
69+
p_goal_ = p_goal;
70+
q_goal_ = q_goal;
71+
72+
// Flip the sign if the dot product of quaternions is negative
73+
if (q_goal_.coeffs().dot(q_start_.coeffs()) < 0.0) {
74+
q_start_.coeffs() << -q_start_.coeffs();
75+
}
76+
};
77+
78+
inline void GetNextStep(const double &time_sec, Eigen::Vector3d &p_t,
79+
Eigen::Quaterniond &q_t) {
80+
if (!start_) {
81+
start_time_ = time_sec;
82+
last_p_t_ = p_start_;
83+
last_q_t_ = q_start_;
84+
start_ = true;
85+
}
86+
87+
if (last_time_ + dt_ <= time_sec) {
88+
double t =
89+
std::min(std::max((time_sec - start_time_) / max_time_, 0.), 1.);
90+
last_p_t_ = p_start_ + t * (p_goal_ - p_start_);
91+
last_q_t_ = q_start_.slerp(t, q_goal_);
92+
last_time_ = time_sec;
93+
}
94+
p_t = last_p_t_;
95+
q_t = last_q_t_;
96+
};
97+
};
98+
} // namespace common
99+
} // namespace rcs
100+
#endif // DEOXYS_FRANKA_INTERFACE_INCLUDE_UTILS_TRAJ_INTERPOLATORS_POSE_TRAJ_INTERPOLATOR_H_

0 commit comments

Comments
 (0)