6 this->m_drive_parameters_publisher = this->m_node_handle.advertise<drive_msgs::drive_param>(
TOPIC_DRIVE_PARAM, 1);
7 this->m_last_updated_source = NULL;
9 std::bind(&DriveParametersMultiplexer::onUpdate,
this, std::placeholders::_1, std::placeholders::_2);
19 this->m_drive_mode_subscriber =
21 &DriveParametersMultiplexer::driveModeCallback,
this);
27 ROS_ASSERT_MSG(source !=
nullptr,
"Parameter 'source' must not be null.");
34 return this->m_last_updated_source ==
nullptr 35 || this->m_last_updated_source == source
37 || this->m_last_updated_source->
getDriveMode() != this->m_drive_mode
38 || (!source->
isIdle() && this->m_last_updated_source->
isIdle());
43 const drive_msgs::drive_param::ConstPtr&
message)
45 ROS_ASSERT_MSG(source !=
nullptr,
"Parameter 'source' must not be null.");
46 if (!this->validateSource(source))
50 this->m_drive_parameters_publisher.publish(message);
51 this->m_last_updated_source = source;
54 void DriveParametersMultiplexer::driveModeCallback(
const std_msgs::Int32::ConstPtr& drive_mode_message)
56 this->m_drive_mode = (
DriveMode)drive_mode_message->data;
59 int main(
int argc,
char** argv)
61 ros::init(argc, argv,
"drive_parameters_multiplexer");
constexpr const char * TOPIC_DRIVE_MODE
int main(int argc, char **argv)
constexpr const char * TOPIC_DRIVE_PARAMETERS_KEYBOARD
bool isOutdated()
Returns true if no update was received for a certain time, determined by the timeout variable...
constexpr const char * TOPIC_DRIVE_PARAMETERS_AUTONOMOUS
constexpr const char * TOPIC_DRIVE_PARAMETERS_JOYSTICK
bool isIdle()
Returns true if the last update contained values close to 0 for both steering and throttle...
constexpr const char * TOPIC_DRIVE_PARAM
DriveParametersMultiplexer()
Construct a new DriveParametersMultiplexer object and initialize sources for all publishers of drive ...