forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LCM Publish method that both encodes and sends (RobotLocomotion#8425
) PR 7178 had many unfixed defects. This is a first downpayment on fixing them. A virtual method cannot have a default argument per GSG, but that PR added one on Publish. Instead of fixing all of the call sites to pass 0.0 explicitly, we port a major portion of them to some new sugar that both serializes and publishes, which is a nicer approach anyway. This also sets the stage for 8256 where subscription-related sugar methods will be introduced.
- Loading branch information
1 parent
917eccb
commit c570391
Showing
16 changed files
with
101 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include "drake/lcm/drake_lcm_interface.h" | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include "drake/lcm/drake_mock_lcm.h" | ||
#include "drake/lcm/lcmt_drake_signal_utils.h" | ||
#include "drake/lcmt_drake_signal.hpp" | ||
|
||
namespace drake { | ||
namespace lcm { | ||
namespace { | ||
|
||
GTEST_TEST(DrakeLcmInterfaceTest, PublishTest) { | ||
// Publish using the helper function. | ||
DrakeMockLcm lcm; | ||
const std::string name = "NAME"; | ||
lcmt_drake_signal original{}; | ||
original.timestamp = 123; | ||
Publish(&lcm, name, original); | ||
|
||
// Make sure it came out okay. (Manually decode so as to be slightly less | ||
// dependent on the DrakeMockLcm sugar.) | ||
const std::vector<uint8_t>& bytes = lcm.get_last_published_message(name); | ||
lcmt_drake_signal decoded{}; | ||
EXPECT_EQ(decoded.decode(bytes.data(), 0, bytes.size()), bytes.size()); | ||
EXPECT_TRUE(CompareLcmtDrakeSignalMessages(decoded, original)); | ||
} | ||
|
||
} // namespace | ||
} // namespace lcm | ||
} // namespace drake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters