Drake
frame_visualizer.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
8 #include "drake/lcmt_viewer_draw.hpp"
11 
12 namespace drake {
13 namespace systems {
14 
15 /**
16  * This is a Drake System block that takes in a state vector, and outputs a
17  * drake::lcmt_viewer_draw message that contains information about the frames
18  * for visualization.
19  *
20  * @ingroup rigid_body_systems
21  */
22 class FrameVisualizer : public LeafSystem<double> {
23  public:
25 
26  /**
27  * Constructor.
28  * @param tree A const pointer to the RigidBodyTree used for doing kinematics.
29  * Its life span must be longer than this.
30  * @param local_transforms A vector of frames to be visualized.
31  * @param lcm A pointer to the object through which LCM messages can be
32  * published. This pointer must remain valid for the duration of this
33  * object.
34  */
36  const std::vector<RigidBodyFrame<double>>& local_transforms,
38 
39  /**
40  * Sets the publishing period of this system. See
41  * LeafSystem::DeclarePublishPeriodSec() for details about the semantics of
42  * parameter `period`.
43  */
44  void set_publish_period(double period) {
45  this->DeclarePeriodicPublish(period);
46  }
47 
48  /**
49  * Sets the LCM channel to which frames are published.
50  */
51  void set_lcm_channel(const std::string& lcm_channel) {
52  lcm_channel_ = lcm_channel;
53  }
54 
55  private:
56  void DoPublish(
57  const systems::Context<double>& context,
58  const std::vector<const PublishEvent<double>*>&) const override;
59 
60  const RigidBodyTree<double>& tree_;
62  const std::vector<RigidBodyFrame<double>> local_transforms_;
63 
64  drake::lcmt_viewer_draw default_msg_{};
65  std::string lcm_channel_{"DRAKE_DRAW_FRAMES"};
66 };
67 
68 } // namespace systems
69 } // namespace drake
void DeclarePeriodicPublish(double period_sec, double offset_sec=0)
Declares a periodic publish event with period = period_sec and offset = offset_sec.
Definition: leaf_system.h:694
Definition: automotive_demo.cc:90
std::vector< double > vector
Definition: translator_test.cc:20
A pure virtual interface that enables LCM to be mocked.
Definition: drake_lcm_interface.h:22
A superclass template that extends System with some convenience utilities that are not applicable to ...
Definition: leaf_system.h:85
void set_lcm_channel(const std::string &lcm_channel)
Sets the LCM channel to which frames are published.
Definition: frame_visualizer.h:51
FrameVisualizer(const FrameVisualizer &)=delete
This is a Drake System block that takes in a state vector, and outputs a drake::lcmt_viewer_draw mess...
Definition: frame_visualizer.h:22
This class represents a publish event.
Definition: event.h:332
#define DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment.
Definition: drake_copyable.h:33
void set_publish_period(double period)
Sets the publishing period of this system.
Definition: frame_visualizer.h:44
Provides careful macros to selectively enable or disable the special member functions for copy-constr...