Skip to content

Commit b615ead

Browse files
committed
style: cpp and py format
1 parent d61db2a commit b615ead

9 files changed

Lines changed: 33 additions & 23 deletions

File tree

extensions/rcs_fr3/src/hw/Franka.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
namespace rcs {
2121
namespace hw {
2222
Franka::Franka(const std::string &ip,
23-
std::optional<std::shared_ptr<common::Kinematics>> ik,
24-
const std::optional<FrankaConfig> &cfg)
23+
std::optional<std::shared_ptr<common::Kinematics>> ik,
24+
const std::optional<FrankaConfig> &cfg)
2525
: robot(ip), m_ik(ik) {
2626
// set collision behavior and impedance
2727
this->set_default_robot_behavior();
@@ -123,7 +123,7 @@ common::VectorXd Franka::get_joint_position() {
123123
}
124124

125125
void Franka::set_guiding_mode(bool x, bool y, bool z, bool roll, bool pitch,
126-
bool yaw, bool elbow) {
126+
bool yaw, bool elbow) {
127127
std::array<bool, 6> activated = {x, y, z, roll, pitch, yaw};
128128
this->robot.setGuidingMode(activated, elbow);
129129
}
@@ -586,7 +586,9 @@ void Franka::move_home() {
586586
this->robot.control(motion_generator);
587587
}
588588

589-
void Franka::automatic_error_recovery() { this->robot.automaticErrorRecovery(); }
589+
void Franka::automatic_error_recovery() {
590+
this->robot.automaticErrorRecovery();
591+
}
590592

591593
void Franka::reset() {
592594
this->stop_control_thread();
@@ -707,9 +709,9 @@ common::Pose Franka::get_base_pose_in_world_coordinates() {
707709
}
708710

709711
void Franka::set_cartesian_position_internal(const common::Pose &pose,
710-
double max_time,
711-
std::optional<double> elbow,
712-
std::optional<double> max_force) {
712+
double max_time,
713+
std::optional<double> elbow,
714+
std::optional<double> max_force) {
713715
// TODO: use speed factor instead of max_time
714716
common::Pose initial_pose = this->get_cartesian_position();
715717

extensions/rcs_fr3/src/hw/Franka.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ struct PandaConfig : FrankaConfig {
4949
common::RobotType robot_type = common::RobotType::Panda;
5050
};
5151

52-
5352
struct FrankaState : common::RobotState {};
5453

5554
class Franka : public common::Robot {
@@ -70,8 +69,8 @@ class Franka : public common::Robot {
7069

7170
public:
7271
Franka(const std::string &ip,
73-
std::optional<std::shared_ptr<common::Kinematics>> ik = std::nullopt,
74-
const std::optional<FrankaConfig> &cfg = std::nullopt);
72+
std::optional<std::shared_ptr<common::Kinematics>> ik = std::nullopt,
73+
const std::optional<FrankaConfig> &cfg = std::nullopt);
7574
~Franka() override;
7675

7776
bool set_config(const FrankaConfig &cfg);

extensions/rcs_fr3/src/hw/FrankaMotionGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void setDefaultBehavior(franka::Robot& robot) {
2424
}
2525

2626
FrankaMotionGenerator::FrankaMotionGenerator(double speed_factor,
27-
const common::Vector7d q_goal)
27+
const common::Vector7d q_goal)
2828
: q_goal_(q_goal) {
2929
dq_max_ *= speed_factor;
3030
ddq_max_start_ *= speed_factor;

extensions/rcs_fr3/src/pybind/rcs.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ PYBIND11_MODULE(_core, m) {
4343

4444
py::object robot_state =
4545
(py::object)py::module_::import("rcs").attr("common").attr("RobotState");
46-
py::class_<rcs::hw::FrankaState>(hw, "FrankaState", robot_state).def(py::init<>());
46+
py::class_<rcs::hw::FrankaState>(hw, "FrankaState", robot_state)
47+
.def(py::init<>());
4748
py::class_<rcs::hw::FrankaLoad>(hw, "FrankaLoad")
4849
.def(py::init<>())
4950
.def_readwrite("load_mass", &rcs::hw::FrankaLoad::load_mass)
@@ -99,7 +100,8 @@ PYBIND11_MODULE(_core, m) {
99100

100101
py::object robot =
101102
(py::object)py::module_::import("rcs").attr("common").attr("Robot");
102-
py::class_<rcs::hw::Franka, std::shared_ptr<rcs::hw::Franka>>(hw, "Franka", robot)
103+
py::class_<rcs::hw::Franka, std::shared_ptr<rcs::hw::Franka>>(hw, "Franka",
104+
robot)
103105
.def(py::init<const std::string &,
104106
std::optional<std::shared_ptr<rcs::common::Kinematics>>>(),
105107
py::arg("ip"), py::arg("ik") = std::nullopt)
@@ -117,9 +119,11 @@ PYBIND11_MODULE(_core, m) {
117119
&rcs::hw::Franka::osc_set_cartesian_position,
118120
py::arg("desired_pos_EE_in_base_frame"))
119121
.def("controller_set_joint_position",
120-
&rcs::hw::Franka::controller_set_joint_position, py::arg("desired_q"))
122+
&rcs::hw::Franka::controller_set_joint_position,
123+
py::arg("desired_q"))
121124
.def("stop_control_thread", &rcs::hw::Franka::stop_control_thread)
122-
.def("automatic_error_recovery", &rcs::hw::Franka::automatic_error_recovery)
125+
.def("automatic_error_recovery",
126+
&rcs::hw::Franka::automatic_error_recovery)
123127
.def("double_tap_robot_to_continue",
124128
&rcs::hw::Franka::double_tap_robot_to_continue)
125129
.def("set_cartesian_position_internal",

extensions/rcs_fr3/src/rcs_fr3/desk.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,11 @@ class FCI(ContextManager):
527527
"""
528528

529529
def __init__(
530-
self, desk: Desk, unlock: bool = False, lock_when_done: bool = True, guiding_mode_when_done: bool = True
530+
self,
531+
desk: Desk,
532+
unlock: bool = False,
533+
lock_when_done: bool = True,
534+
guiding_mode_when_done: bool = True,
531535
):
532536
self.desk = desk
533537
self.unlock = unlock

python/rcs/_core/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ from __future__ import annotations
1515

1616
from . import common, sim
1717

18-
__all__ = ["common", "sim"]
18+
__all__: list[str] = ["common", "sim"]
1919
__version__: str = "0.5.2"

python/rcs/_core/common.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import typing
99
import numpy
1010
import pybind11_stubgen.typing_ext
1111

12-
__all__ = [
12+
__all__: list[str] = [
1313
"BaseCameraConfig",
1414
"FR3",
1515
"FrankaHandTCPOffset",
@@ -134,9 +134,6 @@ class Kinematics:
134134
self, pose: Pose, q0: numpy.ndarray[tuple[M], numpy.dtype[numpy.float64]], tcp_offset: Pose = ...
135135
) -> numpy.ndarray[tuple[M], numpy.dtype[numpy.float64]] | None: ...
136136

137-
class Pin(Kinematics):
138-
def __init__(self, path: str, frame_id: str = "fr3_link8", urdf: bool = True) -> None: ...
139-
140137
class Pose:
141138
def __getstate__(self) -> typing.Annotated[list[float], pybind11_stubgen.typing_ext.FixedSize(16)]: ...
142139
@typing.overload
@@ -316,6 +313,9 @@ class RobotType:
316313
@property
317314
def value(self) -> int: ...
318315

316+
class Pin(Kinematics):
317+
def __init__(self, path: str, frame_id: str = "fr3_link8", urdf: bool = True) -> None: ...
318+
319319
def FrankaHandTCPOffset() -> numpy.ndarray[tuple[typing.Literal[4], typing.Literal[4]], numpy.dtype[numpy.float64]]: ...
320320
def IdentityRotMatrix() -> numpy.ndarray[tuple[typing.Literal[3], typing.Literal[3]], numpy.dtype[numpy.float64]]: ...
321321
def IdentityRotQuatVec() -> numpy.ndarray[tuple[typing.Literal[4]], numpy.dtype[numpy.float64]]: ...

python/rcs/_core/sim.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import typing
99
import numpy
1010
import rcs._core.common
1111

12-
__all__ = [
12+
__all__: list[str] = [
1313
"CameraType",
1414
"FrameSet",
1515
"GuiClient",

src/sim/test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ int test_sim() {
147147
"robot should not be moving at the end of a step");
148148
}
149149
if (not state->is_arrived) {
150-
throw std::runtime_error("robot should be arrived at the end of a step");
150+
throw std::runtime_error(
151+
"robot should be arrived at the end of a step");
151152
}
152153
/* According to fact sheet, pose repeatability within iso cube is 0.1
153154
* millimeters, i.e. 0.0001 meters.

0 commit comments

Comments
 (0)