Skip to content

Commit 7fd66f9

Browse files
committed
format: clang format all cpp files
1 parent 718cf25 commit 7fd66f9

317 files changed

Lines changed: 5236 additions & 5088 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bindings/pydairlib/cassie/cassie_utils_py.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,22 @@ PYBIND11_MODULE(cassie_utils, m) {
1717

1818
using drake::multibody::MultibodyPlant;
1919

20-
m.def("LeftToeFront", &dairlib::LeftToeFront<double>, py::return_value_policy::reference)
21-
.def("RightToeFront", &dairlib::RightToeFront<double>, py::return_value_policy::reference)
22-
.def("LeftToeRear", &dairlib::LeftToeRear<double>, py::return_value_policy::reference)
23-
.def("RightToeRear", &dairlib::RightToeRear<double>, py::return_value_policy::reference)
24-
.def("LeftRodOnThigh", &dairlib::LeftRodOnThigh<double>, py::return_value_policy::reference)
25-
.def("RightRodOnThigh", &dairlib::RightRodOnThigh<double>, py::return_value_policy::reference)
26-
.def("LeftRodOnHeel", &dairlib::LeftRodOnHeel<double>, py::return_value_policy::reference)
27-
.def("RightRodOnHeel", &dairlib::RightRodOnHeel<double>, py::return_value_policy::reference)
20+
m.def("LeftToeFront", &dairlib::LeftToeFront<double>,
21+
py::return_value_policy::reference)
22+
.def("RightToeFront", &dairlib::RightToeFront<double>,
23+
py::return_value_policy::reference)
24+
.def("LeftToeRear", &dairlib::LeftToeRear<double>,
25+
py::return_value_policy::reference)
26+
.def("RightToeRear", &dairlib::RightToeRear<double>,
27+
py::return_value_policy::reference)
28+
.def("LeftRodOnThigh", &dairlib::LeftRodOnThigh<double>,
29+
py::return_value_policy::reference)
30+
.def("RightRodOnThigh", &dairlib::RightRodOnThigh<double>,
31+
py::return_value_policy::reference)
32+
.def("LeftRodOnHeel", &dairlib::LeftRodOnHeel<double>,
33+
py::return_value_policy::reference)
34+
.def("RightRodOnHeel", &dairlib::RightRodOnHeel<double>,
35+
py::return_value_policy::reference)
2836
.def("LeftLoopClosureEvaluator",
2937
&dairlib::LeftLoopClosureEvaluator<double>, py::arg("plant"))
3038
.def("RightLoopClosureEvaluator",

bindings/pydairlib/cassie/controllers_py.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ PYBIND11_MODULE(controllers, m) {
2323

2424
py::class_<OSCRunningControllerDiagram, drake::systems::Diagram<double>>(
2525
m, "OSCRunningControllerFactory")
26-
.def(py::init<drake::multibody::MultibodyPlant<double>&, const std::string&, const std::string&>(),
27-
py::arg("plant"), py::arg("osc_gains_filename"), py::arg("osqp_settings_filename"))
26+
.def(py::init<drake::multibody::MultibodyPlant<double>&,
27+
const std::string&, const std::string&>(),
28+
py::arg("plant"), py::arg("osc_gains_filename"),
29+
py::arg("osqp_settings_filename"))
2830
.def("get_plant", &OSCRunningControllerDiagram::get_plant,
2931
py_rvp::reference_internal)
3032
.def("get_input_port_state",
@@ -45,8 +47,10 @@ PYBIND11_MODULE(controllers, m) {
4547

4648
py::class_<OSCWalkingControllerDiagram, drake::systems::Diagram<double>>(
4749
m, "OSCWalkingControllerFactory")
48-
.def(py::init<drake::multibody::MultibodyPlant<double>&, bool, const std::string&, const std::string&>(),
49-
py::arg("plant"), py::arg("has_double_stance"), py::arg("osc_gains_filename"), py::arg("osqp_settings_filename"))
50+
.def(py::init<drake::multibody::MultibodyPlant<double>&, bool,
51+
const std::string&, const std::string&>(),
52+
py::arg("plant"), py::arg("has_double_stance"),
53+
py::arg("osc_gains_filename"), py::arg("osqp_settings_filename"))
5054
.def("get_plant", &OSCWalkingControllerDiagram::get_plant,
5155
py_rvp::reference_internal)
5256
.def("get_input_port_state",

bindings/pydairlib/cassie/simulators_py.cc

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
#include <pybind11/pybind11.h>
44
#include <pybind11/stl.h>
55

6+
#include "examples/Cassie/diagrams/cassie_sim_diagram.h"
67

78
#include "drake/bindings/pydrake/pydrake_pybind.h"
89

9-
#include "examples/Cassie/diagrams/cassie_sim_diagram.h"
10-
1110
namespace py = pybind11;
1211

1312
namespace dairlib {
@@ -21,18 +20,16 @@ PYBIND11_MODULE(simulators, m) {
2120

2221
using py_rvp = py::return_value_policy;
2322

24-
py::class_<CassieSimDiagram,
25-
drake::systems::Diagram<double>>(m, "CassieSimDiagram")
26-
.def(py::init(
27-
[](drake::multibody::MultibodyPlant<double>& plant,
28-
const std::string& urdf, bool visualize, double mu,
29-
double stiffness, double dissipation_rate) {
30-
return std::make_unique<CassieSimDiagram>(
31-
make_unowned_shared_ptr_from_raw(&plant), urdf, visualize,
32-
mu);
33-
}),
34-
py::arg("plant"), py::arg("urdf"), py::arg("visualize"), py::arg("mu"), py::arg("stiffness"),
35-
py::arg("dissipation_rate"))
23+
py::class_<CassieSimDiagram, drake::systems::Diagram<double>>(
24+
m, "CassieSimDiagram")
25+
.def(py::init([](drake::multibody::MultibodyPlant<double>& plant,
26+
const std::string& urdf, bool visualize, double mu,
27+
double stiffness, double dissipation_rate) {
28+
return std::make_unique<CassieSimDiagram>(
29+
make_unowned_shared_ptr_from_raw(&plant), urdf, visualize, mu);
30+
}),
31+
py::arg("plant"), py::arg("urdf"), py::arg("visualize"),
32+
py::arg("mu"), py::arg("stiffness"), py::arg("dissipation_rate"))
3633
.def("get_plant", &CassieSimDiagram::get_plant,
3734
py_rvp::reference_internal)
3835
.def("get_input_port_actuation",

bindings/pydairlib/common/common_py.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77

88
namespace py = pybind11;
99

10-
namespace dairlib {
10+
namespace dairlib {
1111
namespace pydairlib {
1212

1313
PYBIND11_MODULE(common, m) {
1414
m.doc() = "Bindings for //common:common";
1515

1616
m.def("FindResourceOrThrow", &FindResourceOrThrow,
17-
"Attempts to locate a Dairlib (not Drake) resource named by the given path string. "
18-
"The path refers to the relative path within the repository, "
19-
"e.g., examples/Cassie/urdf/cassie.urdf. Raises an exception "
20-
"if the resource was not found.",
21-
py::arg("resource_path"));
17+
"Attempts to locate a Dairlib (not Drake) resource named by the given "
18+
"path string. "
19+
"The path refers to the relative path within the repository, "
20+
"e.g., examples/Cassie/urdf/cassie.urdf. Raises an exception "
21+
"if the resource was not found.",
22+
py::arg("resource_path"));
2223
}
2324

2425
} // namespace pydairlib

bindings/pydairlib/lcm/lcm_py.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ using dairlib::pydairlib::BindCppSerializers;
1414
// pybind11 trampoline class to permit overriding virtual functions in
1515
// Python.
1616
PYBIND11_MODULE(lcm_py, m) {
17-
// PYDRAKE_PREVENT_PYTHON3_MODULE_REIMPORT(m);
17+
// PYDRAKE_PREVENT_PYTHON3_MODULE_REIMPORT(m);
1818
// Bind C++ serializers.
1919
BindCppSerializers();
2020
}
2121

22-
} // namespace pydrake
23-
} // namespace drake
22+
} // namespace pydairlib
23+
} // namespace dairlib

bindings/pydairlib/lcm/lcm_py_bind_cpp_serializers.cc

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#include "dairlib/lcmt_cassie_out.hpp"
44
#include "dairlib/lcmt_contact.hpp"
55
#include "dairlib/lcmt_osc_output.hpp"
6-
#include "dairlib/lcmt_robot_output.hpp"
76
#include "dairlib/lcmt_osc_qp_output.hpp"
87
#include "dairlib/lcmt_osc_tracking_data.hpp"
8+
#include "dairlib/lcmt_radio_out.hpp"
99
#include "dairlib/lcmt_robot_input.hpp"
10+
#include "dairlib/lcmt_robot_output.hpp"
1011
#include "dairlib/lcmt_saved_traj.hpp"
1112
#include "dairlib/lcmt_timestamped_saved_traj.hpp"
12-
#include "dairlib/lcmt_radio_out.hpp"
1313

1414
#include "drake/bindings/pydrake/systems/lcm_pybind.h"
1515

@@ -19,16 +19,26 @@ namespace pydairlib {
1919
void BindCppSerializers() {
2020
// N.B. At least one type should be bound to ensure the template is defined.
2121
// N.B. These should be placed in the same order as the headers.
22-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_cassie_out>("dairlib");
23-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_contact>("dairlib");
24-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_osc_output>("dairlib");
25-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_robot_output>("dairlib");
26-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_osc_qp_output>("dairlib");
27-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_osc_tracking_data>("dairlib");
28-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_robot_input>("dairlib");
29-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_saved_traj>("dairlib");
30-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_timestamped_saved_traj>("dairlib");
31-
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_radio_out>("dairlib");
22+
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_cassie_out>(
23+
"dairlib");
24+
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_contact>(
25+
"dairlib");
26+
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_osc_output>(
27+
"dairlib");
28+
drake::pydrake::pysystems::pylcm::BindCppSerializer<
29+
dairlib::lcmt_robot_output>("dairlib");
30+
drake::pydrake::pysystems::pylcm::BindCppSerializer<
31+
dairlib::lcmt_osc_qp_output>("dairlib");
32+
drake::pydrake::pysystems::pylcm::BindCppSerializer<
33+
dairlib::lcmt_osc_tracking_data>("dairlib");
34+
drake::pydrake::pysystems::pylcm::BindCppSerializer<
35+
dairlib::lcmt_robot_input>("dairlib");
36+
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_saved_traj>(
37+
"dairlib");
38+
drake::pydrake::pysystems::pylcm::BindCppSerializer<
39+
dairlib::lcmt_timestamped_saved_traj>("dairlib");
40+
drake::pydrake::pysystems::pylcm::BindCppSerializer<dairlib::lcmt_radio_out>(
41+
"dairlib");
3242
}
3343

3444
} // namespace pydairlib

bindings/pydairlib/lcm/lcm_py_bind_cpp_serializers.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ For more usages in Python, see the following in `_lcm_extra.py`:
1515

1616
namespace dairlib {
1717
namespace pydairlib {
18-
//namespace pysystems {
19-
//namespace pylcm {
18+
// namespace pysystems {
19+
// namespace pylcm {
2020

2121
void BindCppSerializers();
2222

2323
//} // namespace pylcm
2424
//} // namespace pysystems
25-
} // namespace pydrake
26-
} // namespace drake
25+
} // namespace pydairlib
26+
} // namespace dairlib

bindings/pydairlib/multibody/multibody_py.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,21 @@ PYBIND11_MODULE(multibody, m) {
2323
.def(py::init<std::string, int, std::string>())
2424
.def(py::init<std::string, int, double, std::string>())
2525
.def(py::init<std::string, int, Eigen::VectorXd, std::string>())
26-
.def("DrawPoses", &MultiposeVisualizer::DrawPoses, py::arg("poses"), py::arg("poses"))
26+
.def("DrawPoses", &MultiposeVisualizer::DrawPoses, py::arg("poses"),
27+
py::arg("poses"))
2728
.def("GetMeshcat", &MultiposeVisualizer::GetMeshcat);
2829

2930
m.def("ConnectTrajectoryVisualizer",
3031
&dairlib::multibody::ConnectTrajectoryVisualizer, py::arg("plant"),
3132
py::arg("builder"), py::arg("scene_graph"), py::arg("trajectory"));
3233

3334
m.def("MakeNameToPositionsMap",
34-
py::overload_cast<const drake::multibody::MultibodyPlant<double>&>(&dairlib::multibody::MakeNameToPositionsMap<double>),
35+
py::overload_cast<const drake::multibody::MultibodyPlant<double>&>(
36+
&dairlib::multibody::MakeNameToPositionsMap<double>),
3537
py::arg("plant"))
3638
.def("MakeNameToVelocitiesMap",
37-
py::overload_cast<const drake::multibody::MultibodyPlant<double>&>(&dairlib::multibody::MakeNameToVelocitiesMap<double>),
39+
py::overload_cast<const drake::multibody::MultibodyPlant<double>&>(
40+
&dairlib::multibody::MakeNameToVelocitiesMap<double>),
3841
py::arg("plant"))
3942
.def("MakeNameToActuatorsMap",
4043
&dairlib::multibody::MakeNameToActuatorsMap<double>,

bindings/pydairlib/systems/framework_py.cc

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
#include <pybind11/pybind11.h>
44
#include <pybind11/stl.h>
55

6+
#include "dairlib/lcmt_robot_output.hpp"
67
#include "systems/framework/lcm_driven_loop.h"
78
#include "systems/framework/output_vector.h"
89
#include "systems/framework/timestamped_vector.h"
910

10-
#include "dairlib/lcmt_robot_output.hpp"
11-
1211
#include "drake/bindings/pydrake/pydrake_pybind.h"
1312

1413
namespace py = pybind11;
@@ -20,53 +19,50 @@ using drake::pydrake::make_unowned_shared_ptr_from_raw;
2019
using LcmOutputDrivenLoop = systems::LcmDrivenLoop<dairlib::lcmt_robot_output>;
2120

2221
PYBIND11_MODULE(framework, m) {
22+
py::class_<LcmOutputDrivenLoop>(m, "LcmOutputDrivenLoop")
23+
.def(py::init([](drake::lcm::DrakeLcm* drake_lcm,
24+
drake::systems::Diagram<double>& diagram,
25+
const drake::systems::LeafSystem<double>* lcm_parser,
26+
const std::string& input_channel,
27+
bool is_forced_publish) {
28+
// The C++ constructor doesn't offer a bare-pointer overload,
29+
// only shared_ptr. Because object lifetime is already
30+
// handled by the ref_cycle annotation below (as required for
31+
// all subclasses of Diagram), we can pass the `plant` as an
32+
// unowned shared_ptr.
33+
// (comment taken from Drakes controllers_py.cc)
34+
return std::make_unique<LcmOutputDrivenLoop>(
35+
drake_lcm, make_unowned_shared_ptr_from_raw(&diagram),
36+
lcm_parser, input_channel, is_forced_publish);
37+
}),
38+
py::arg("drake_lcm"), py::arg("diagram"), py::arg("lcm_parser"),
39+
py::arg("input_channel"), py::arg("is_forced_publish"))
40+
.def("Simulate", &LcmOutputDrivenLoop::Simulate,
41+
py::arg("end_time") = std::numeric_limits<double>::infinity());
2342

24-
py::class_<LcmOutputDrivenLoop>(m, "LcmOutputDrivenLoop")
25-
.def(py::init(
26-
[](drake::lcm::DrakeLcm* drake_lcm,
27-
drake::systems::Diagram<double>& diagram,
28-
const drake::systems::LeafSystem<double>* lcm_parser,
29-
const std::string& input_channel, bool is_forced_publish) {
30-
// The C++ constructor doesn't offer a bare-pointer overload,
31-
// only shared_ptr. Because object lifetime is already
32-
// handled by the ref_cycle annotation below (as required for
33-
// all subclasses of Diagram), we can pass the `plant` as an
34-
// unowned shared_ptr.
35-
// (comment taken from Drakes controllers_py.cc)
36-
return std::make_unique<LcmOutputDrivenLoop>(
37-
drake_lcm, make_unowned_shared_ptr_from_raw(&diagram),
38-
lcm_parser, input_channel, is_forced_publish);
39-
40-
}),
41-
py::arg("drake_lcm"),
42-
py::arg("diagram"), py::arg("lcm_parser"),
43-
py::arg("input_channel"), py::arg("is_forced_publish"))
44-
.def("Simulate", &LcmOutputDrivenLoop::Simulate,
45-
py::arg("end_time") = std::numeric_limits<double>::infinity());
46-
47-
py::class_<systems::TimestampedVector<double>,
48-
drake::systems::BasicVector<double>>(m, "TimestampedVector")
49-
.def(py::init<int>(), py::arg("data_size"))
50-
.def("set_timestamp", &systems::TimestampedVector<double>::set_timestamp,
51-
py::arg("timestamp"))
52-
.def("get_timestamp", &systems::TimestampedVector<double>::get_timestamp)
53-
.def("get_data", &systems::TimestampedVector<double>::get_data)
54-
.def("SetDataVector", &systems::TimestampedVector<double>::SetDataVector,
55-
py::arg("value"));
43+
py::class_<systems::TimestampedVector<double>,
44+
drake::systems::BasicVector<double>>(m, "TimestampedVector")
45+
.def(py::init<int>(), py::arg("data_size"))
46+
.def("set_timestamp", &systems::TimestampedVector<double>::set_timestamp,
47+
py::arg("timestamp"))
48+
.def("get_timestamp", &systems::TimestampedVector<double>::get_timestamp)
49+
.def("get_data", &systems::TimestampedVector<double>::get_data)
50+
.def("SetDataVector", &systems::TimestampedVector<double>::SetDataVector,
51+
py::arg("value"));
5652

57-
py::class_<systems::OutputVector<double>,
58-
drake::systems::BasicVector<double>>(m, "OutputVector")
59-
.def(py::init<int,int,int>(), py::arg("num_positions"),
60-
py::arg("num_velocities"), py::arg("num_efforts"))
61-
.def("SetPositions", &systems::OutputVector<double>::SetPositions,
62-
py::arg("positions"))
63-
.def("SetVelocities", &systems::OutputVector<double>::SetVelocities,
64-
py::arg("velocities"))
65-
.def("SetState", &systems::OutputVector<double>::SetState,
66-
py::arg("state"))
67-
.def("GetPositions", &systems::OutputVector<double>::GetPositions)
68-
.def("GetVelocities", &systems::OutputVector<double>::GetVelocities)
69-
.def("GetState", &systems::OutputVector<double>::GetState);
53+
py::class_<systems::OutputVector<double>,
54+
drake::systems::BasicVector<double>>(m, "OutputVector")
55+
.def(py::init<int, int, int>(), py::arg("num_positions"),
56+
py::arg("num_velocities"), py::arg("num_efforts"))
57+
.def("SetPositions", &systems::OutputVector<double>::SetPositions,
58+
py::arg("positions"))
59+
.def("SetVelocities", &systems::OutputVector<double>::SetVelocities,
60+
py::arg("velocities"))
61+
.def("SetState", &systems::OutputVector<double>::SetState,
62+
py::arg("state"))
63+
.def("GetPositions", &systems::OutputVector<double>::GetPositions)
64+
.def("GetVelocities", &systems::OutputVector<double>::GetVelocities)
65+
.def("GetState", &systems::OutputVector<double>::GetState);
7066
}
7167

7268
} // namespace pydairlib

bindings/pydairlib/systems/primitives_py.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ PYBIND11_MODULE(primitives, m) {
4343

4444
using drake::multibody::MultibodyPlant;
4545

46-
py::class_<systems::SubvectorPassThrough<double>, drake::systems::LeafSystem<double>>(m, "SubvectorPassThrough")
46+
py::class_<systems::SubvectorPassThrough<double>,
47+
drake::systems::LeafSystem<double>>(m, "SubvectorPassThrough")
4748
.def(py::init<int, int, int>());
4849
}
4950

0 commit comments

Comments
 (0)