Skip to content

Commit

Permalink
Use DrakeVisualizerd instead of DrakeVisualizer (RobotLocomotion#14547)
Browse files Browse the repository at this point in the history
In the future PR we will templatize DrakeVisualizer class.  This PR makes
sure the code doesn't break, and is compatible with the future templated
DrakeVisualizer class.

Co-authored-by: Jeremy Nimmer <[email protected]>
  • Loading branch information
hongkai-dai and jwnimmer-tri authored Jan 20, 2021
1 parent 2a4723a commit 75364f3
Show file tree
Hide file tree
Showing 48 changed files with 73 additions and 59 deletions.
2 changes: 1 addition & 1 deletion examples/acrobot/run_lqr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(
&builder, acrobot->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto controller = builder.AddSystem(BalancingLQRController(*acrobot));
controller->set_name("controller");
Expand Down
2 changes: 1 addition & 1 deletion examples/acrobot/run_lqr_w_estimator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(
&builder, acrobot_w_encoder->get_output_port(1), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

// Make a Kalman filter observer.
auto observer_acrobot = std::make_unique<AcrobotWEncoder<double>>();
Expand Down
2 changes: 1 addition & 1 deletion examples/acrobot/run_passive.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(
&builder, acrobot->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/acrobot/run_plant_w_lcm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(
&builder, acrobot->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph, lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph, lcm);

// Creates command receiver and subscriber.
auto command_sub = builder.AddSystem(
Expand Down
2 changes: 1 addition & 1 deletion examples/acrobot/run_swing_up.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(
&builder, acrobot->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto controller = builder.AddSystem<AcrobotSpongController>();
builder.Connect(acrobot->get_output_port(0), controller->get_input_port(0));
Expand Down
2 changes: 1 addition & 1 deletion examples/acrobot/test/run_swing_up_traj_optimization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
AcrobotGeometry::AddToBuilder(&builder, plant->get_output_port(0),
scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto diagram = builder.Build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void DoMain() {
plant.Finalize();

// Visualization
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
DRAKE_DEMAND(!!plant.get_source_id());
builder.Connect(
plant.get_geometry_poses_output_port(),
Expand Down
2 changes: 1 addition & 1 deletion examples/allegro_hand/run_allegro_constant_load_demo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void DoMain() {
builder.Connect(scene_graph.get_query_output_port(),
plant.get_geometry_query_input_port());

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
std::unique_ptr<systems::Diagram<double>> diagram = builder.Build();

// Create a context for this system:
Expand Down
2 changes: 1 addition & 1 deletion examples/atlas/atlas_run_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int do_main() {
// Publish contact results for visualization.
ConnectContactResultsToDrakeVisualizer(&builder, plant);

geometry::DrakeVisualizer::AddToBuilder(&builder, pair.scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, pair.scene_graph);
auto diagram = builder.Build();

// Create a context for this system:
Expand Down
2 changes: 1 addition & 1 deletion examples/compass_gait/simulate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
CompassGaitGeometry::AddToBuilder(&builder,
compass_gait->get_floating_base_state_output_port(), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto diagram = builder.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/kinova_jaco_arm/jaco_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int DoMain() {

systems::lcm::LcmInterfaceSystem* lcm =
builder.AddSystem<systems::lcm::LcmInterfaceSystem>();
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph, lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph, lcm);

auto command_sub = builder.AddSystem(
systems::lcm::LcmSubscriberSystem::Make<drake::lcmt_jaco_command>(
Expand Down
2 changes: 1 addition & 1 deletion examples/kuka_iiwa_arm/kuka_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int DoMain() {

// Creates and adds LCM publisher for visualization.
auto lcm = builder.AddSystem<systems::lcm::LcmInterfaceSystem>();
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph, lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph, lcm);

// Since we welded the model to the world above, the only remaining joints
// should be those in the arm.
Expand Down
2 changes: 1 addition & 1 deletion examples/manipulation_station/mock_station_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int do_main(int argc, char* argv[]) {
// #9747.
station->Finalize();

geometry::DrakeVisualizer::AddToBuilder(
geometry::DrakeVisualizerd::AddToBuilder(
&builder, station->GetOutputPort("query_object"));

auto lcm = builder.AddSystem<systems::lcm::LcmInterfaceSystem>();
Expand Down
2 changes: 1 addition & 1 deletion examples/manipulation_station/proof_of_life.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int do_main(int argc, char* argv[]) {
}
station->Finalize();

geometry::DrakeVisualizer::AddToBuilder(
geometry::DrakeVisualizerd::AddToBuilder(
&builder, station->GetOutputPort("query_object"));
multibody::ConnectContactResultsToDrakeVisualizer(
&builder, station->get_mutable_multibody_plant(),
Expand Down
2 changes: 1 addition & 1 deletion examples/mass_spring_cloth/run_cloth_spring_model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int DoMain() {
auto* scene_graph = builder.AddSystem<geometry::SceneGraph>();
ClothSpringModelGeometry::AddToBuilder(&builder, *cloth_spring_model,
scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();
auto context = diagram->CreateDefaultContext();
auto simulator =
Expand Down
2 changes: 1 addition & 1 deletion examples/multibody/acrobot/passive_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ int do_main() {
acrobot.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(acrobot.get_source_id().value()));

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
auto diagram = builder.Build();

// Create a context for this system:
Expand Down
2 changes: 1 addition & 1 deletion examples/multibody/acrobot/run_lqr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int do_main() {
acrobot.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(acrobot.get_source_id().value()));

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ int do_main() {
cart_pole.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(cart_pole.get_source_id().value()));

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
auto diagram = builder.Build();

// Create a context for this system:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int do_main() {
plant.get_geometry_query_input_port());

DrakeLcm lcm;
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph, &lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph, &lcm);

// This is the source of poses for the visualizer.
builder.Connect(
Expand Down
2 changes: 1 addition & 1 deletion examples/multibody/four_bar/passive_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int do_main() {
// We are done defining the model. Finalize and build the diagram.
four_bar.Finalize();

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
auto diagram = builder.Build();

// Create a context for this system and sub-context for the four bar system.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int do_main() {
if (FLAGS_time_step > 0)
ConnectContactResultsToDrakeVisualizer(&builder, plant);

geometry::DrakeVisualizer::AddToBuilder(&builder, pair.scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, pair.scene_graph);
auto diagram = builder.Build();

// Create a context for this system:
Expand Down
2 changes: 1 addition & 1 deletion examples/multibody/pendulum/passive_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int do_main() {
pendulum.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(pendulum.get_source_id().value()));

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
auto diagram = builder.Build();

auto diagram_context = diagram->CreateDefaultContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ int do_main() {
scene_graph.get_source_pose_port(plant.get_source_id().value()));

if (FLAGS_visualize) {
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
ConnectContactResultsToDrakeVisualizer(&builder, plant);
}
auto diagram = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion examples/multibody/strandbeest/run_with_motor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ int do_main() {
strandbeest.set_penetration_allowance(FLAGS_penetration_allowance);
strandbeest.set_stiction_tolerance(FLAGS_stiction_tolerance);

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
ConnectContactResultsToDrakeVisualizer(&builder, strandbeest);

// Create a DesiredVelocityMotor where the proportional term is directly
Expand Down
2 changes: 1 addition & 1 deletion examples/particles/uniformly_accelerated_particle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ UniformlyAcceleratedParticle::UniformlyAcceleratedParticle(
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
ParticleGeometry::AddToBuilder(
&builder, particle->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
builder.BuildInto(this);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum/energy_shaping_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
PendulumGeometry::AddToBuilder(
&builder, pendulum->get_state_output_port(), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum/lqr_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
PendulumGeometry::AddToBuilder(
&builder, pendulum->get_state_output_port(), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum/passive_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
PendulumGeometry::AddToBuilder(
&builder, pendulum->get_state_output_port(), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/pendulum/trajectory_optimization_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int DoMain() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
PendulumGeometry::AddToBuilder(
&builder, pendulum_ptr->get_state_output_port(), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/planar_gripper/gripper_brick.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template <>
void AddDrakeVisualizer<double>(
systems::DiagramBuilder<double>* builder,
const geometry::SceneGraph<double>& scene_graph) {
geometry::DrakeVisualizer::AddToBuilder(builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(builder, scene_graph);
}

template <typename T>
Expand Down
2 changes: 1 addition & 1 deletion examples/planar_gripper/planar_gripper_simulation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ int DoMain() {
plant.get_actuation_input_port());
}

geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph, lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph, lcm);

// Publish contact results for visualization.
if (FLAGS_visualize_contacts) {
Expand Down
2 changes: 1 addition & 1 deletion examples/quadrotor/run_quadrotor_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Quadrotor : public systems::Diagram<T> {
systems::DiagramBuilder<T> builder;
auto [plant, scene_graph] =
multibody::AddMultibodyPlantSceneGraph(&builder, 0.0);
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph);
multibody::Parser parser(&plant);
parser.AddModelFromFile(
FindResourceOrThrow("drake/examples/quadrotor/quadrotor.urdf"));
Expand Down
2 changes: 1 addition & 1 deletion examples/quadrotor/run_quadrotor_lqr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int do_main() {
auto scene_graph = builder.AddSystem<geometry::SceneGraph>();
QuadrotorGeometry::AddToBuilder(
&builder, quadrotor->get_output_port(0), scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto diagram = builder.Build();
Simulator<double> simulator(*diagram);
Expand Down
2 changes: 1 addition & 1 deletion examples/rimless_wheel/simulate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ int DoMain() {
RimlessWheelGeometry::AddToBuilder(
&builder, rimless_wheel->get_floating_base_state_output_port(),
scene_graph);
geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);
auto diagram = builder.Build();

systems::Simulator<double> simulator(*diagram);
Expand Down
4 changes: 2 additions & 2 deletions examples/rod2d/rod2d_sim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using Rod2D = drake::examples::rod2d::Rod2D<double>;
using drake::examples::rod2d::Rod2dGeometry;
using drake::geometry::DrakeVisualizer;
using drake::geometry::DrakeVisualizerd;
using drake::geometry::SceneGraph;
using drake::systems::Context;
using drake::systems::DiagramBuilder;
Expand Down Expand Up @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) {
auto& scene_graph = *builder.AddSystem<SceneGraph<double>>();
Rod2dGeometry::AddToBuilder(FLAGS_rod_radius, rod->get_rod_half_length() * 2,
&builder, rod->state_output(), &scene_graph);
DrakeVisualizer::AddToBuilder(&builder, scene_graph);
DrakeVisualizerd::AddToBuilder(&builder, scene_graph);

// Set the names of the systems.
rod->set_name("rod");
Expand Down
4 changes: 2 additions & 2 deletions examples/scene_graph/bouncing_ball_run_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace {

using Eigen::Vector3d;
using Eigen::Vector4d;
using geometry::DrakeVisualizer;
using geometry::DrakeVisualizerd;
using geometry::GeometryInstance;
using geometry::SceneGraph;
using geometry::GeometryId;
Expand Down Expand Up @@ -103,7 +103,7 @@ int do_main() {
bouncing_ball2->get_geometry_query_input_port());

DrakeLcm lcm;
DrakeVisualizer::AddToBuilder(&builder, *scene_graph, &lcm);
DrakeVisualizerd::AddToBuilder(&builder, *scene_graph, &lcm);

if (FLAGS_render_on) {
PerceptionProperties properties;
Expand Down
4 changes: 2 additions & 2 deletions examples/scene_graph/simple_contact_surface_vis.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ using Eigen::Vector4d;
using geometry::Box;
using geometry::ContactSurface;
using geometry::Cylinder;
using geometry::DrakeVisualizer;
using geometry::DrakeVisualizerd;
using geometry::FrameId;
using geometry::FramePoseVector;
using geometry::GeometryFrame;
Expand Down Expand Up @@ -321,7 +321,7 @@ int do_main() {
DrakeLcm lcm;

// Visualize geometry.
DrakeVisualizer::AddToBuilder(&builder, scene_graph, &lcm);
DrakeVisualizerd::AddToBuilder(&builder, scene_graph, &lcm);

// Visualize contacts.
auto& contact_to_lcm =
Expand Down
2 changes: 1 addition & 1 deletion examples/scene_graph/solar_system_run_dynamics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int do_main() {
builder.Connect(solar_system->get_geometry_pose_output_port(),
scene_graph->get_source_pose_port(solar_system->source_id()));

geometry::DrakeVisualizer::AddToBuilder(&builder, *scene_graph);
geometry::DrakeVisualizerd::AddToBuilder(&builder, *scene_graph);

auto diagram = builder.Build();

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_gripper/simple_gripper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ int do_main() {
plant.get_geometry_query_input_port());

DrakeLcm lcm;
geometry::DrakeVisualizer::AddToBuilder(&builder, scene_graph, &lcm);
geometry::DrakeVisualizerd::AddToBuilder(&builder, scene_graph, &lcm);
builder.Connect(
plant.get_geometry_poses_output_port(),
scene_graph.get_source_pose_port(plant.get_source_id().value()));
Expand Down
Loading

0 comments on commit 75364f3

Please sign in to comment.