Skip to content

Commit

Permalink
ROS2 patch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Facundo Garcia committed Jan 15, 2024
1 parent 4ece541 commit 6dd89eb
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion fixposition_driver_lib/src/gprmc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

namespace fixposition {

// unit transformation constant
// unit conversion constant
static constexpr double knots_to_ms = 1852.0 / 3600.0; //!< convert knots to m/s

/// msg field indices
Expand Down
2 changes: 1 addition & 1 deletion fixposition_driver_ros1/launch/tcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fp_output:
formats: ["ODOMETRY", "LLH", "RAWIMU", "CORRIMU", "GPGGA", "GPZDA", "GPRMC", "TF"]
type: tcp
port: "21000"
ip: "127.0.0.1" # change to VRTK2's IP address in the network
ip: "10.0.2.1" # change to VRTK2's IP address in the network
rate: 200
reconnect_delay: 5.0 # wait time in [s] until retry connection

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class FixpositionDriverNode : public FixpositionDriver {
* @param[in] payload
*/
void BestGnssPosToPublishNavSatFix(const Oem7MessageHeaderMem* header, const BESTGNSSPOSMem* payload);

void PublishNmea(NmeaMessage data);

std::shared_ptr<rclcpp::Node> node_;
rclcpp::Subscription<fixposition_driver_ros2::msg::Speed>::SharedPtr ws_sub_; //!< wheelspeed message subscriber
Expand Down
2 changes: 1 addition & 1 deletion fixposition_driver_ros2/launch/tcp.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fixposition_driver_ros2:
ros__parameters:
fp_output:
formats: ["ODOMETRY", "LLH", "RAWIMU", "CORRIMU", "TF"]
formats: ["ODOMETRY", "LLH", "RAWIMU", "CORRIMU", "GPGGA", "GPZDA", "GPRMC", "TF"]
type: "tcp"
port: "21000"
ip: "10.0.2.1" # change to VRTK2's IP address in the network
Expand Down
9 changes: 3 additions & 6 deletions fixposition_driver_ros2/msg/NMEA.msg
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
####################################################################################################
#
# Copyright (c) 2023 ___ ___
# \\ \\ / /
# \\ \\/ /
# / /\\ \\
# /__/ \\__\\ Fixposition AG
# Copyright (c) 2023
# Fixposition AG
#
####################################################################################################
#
Expand All @@ -25,7 +22,7 @@
# receiver, usually the location of the antenna. This is a
# Euclidean frame relative to the vehicle, not a reference
# ellipsoid.
Header header
std_msgs/Header header

# Latitude [degrees]. Positive is north of equator; negative is south.
float64 latitude
Expand Down
12 changes: 6 additions & 6 deletions fixposition_driver_ros2/src/fixposition_driver_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,23 @@ void FixpositionDriverNode::RegisterObservers() {
} else if (format == "GPGGA") {
dynamic_cast<GpggaConverter*>(a_converters_["GPGGA"].get())->AddObserver([this](const GpggaData& data) {
// GPGGA Observer Lambda
if (nmea_pub_.getNumSubscribers() > 0) {
if (nmea_pub_->get_subscription_count() > 0) {
nmea_message_.gpgga = data;
PublishNmea(nmea_message_);
}
});
} else if (format == "GPZDA") {
dynamic_cast<GpzdaConverter*>(a_converters_["GPZDA"].get())->AddObserver([this](const GpzdaData& data) {
// GPZDA Observer Lambda
if (nmea_pub_.getNumSubscribers() > 0) {
if (nmea_pub_->get_subscription_count() > 0) {
nmea_message_.gpzda = data;
PublishNmea(nmea_message_);
}
});
} else if (format == "GPRMC") {
dynamic_cast<GprmcConverter*>(a_converters_["GPRMC"].get())->AddObserver([this](const GprmcData& data) {
// GPRMC Observer Lambda
if (nmea_pub_.getNumSubscribers() > 0) {
if (nmea_pub_->get_subscription_count() > 0) {
nmea_message_.gprmc = data;
PublishNmea(nmea_message_);
}
Expand All @@ -219,10 +219,10 @@ void FixpositionDriverNode::PublishNmea(NmeaMessage data) {
// If epoch message is complete, generate NMEA output
if (data.checkEpoch()) {
// Generate new message
fixposition_driver_ros1::NMEA msg;
fixposition_driver_ros2::msg::NMEA msg;

// ROS Header
msg.header.stamp = ros::Time::fromBoost(GpsTimeToPtime(data.gpzda.stamp));
msg.header.stamp = GpsTimeToMsgTime(data.gpzda.stamp);
msg.header.frame_id = "LLH";

// Latitude [degrees]. Positive is north of equator; negative is south
Expand Down Expand Up @@ -251,7 +251,7 @@ void FixpositionDriverNode::PublishNmea(NmeaMessage data) {
msg.mode = data.gprmc.mode;

// Publish message
nmea_pub_.publish(msg);
nmea_pub_->publish(msg);
}
}

Expand Down

0 comments on commit 6dd89eb

Please sign in to comment.