Fixed services for parameter adjusting not working
This commit is contained in:
@ -6,6 +6,7 @@
|
||||
#include <rclcpp/service.hpp>
|
||||
#include <string>
|
||||
#include <libserial/SerialStream.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "mg_msgs/srv/set_width.hpp"
|
||||
#include "std_srvs/srv/empty.hpp"
|
||||
@ -56,9 +57,9 @@ class MgOdomPublisher : public rclcpp::Node {
|
||||
void set_width(const std::shared_ptr<SetWidthSrv::Request> request) {
|
||||
RCLCPP_INFO(get_logger(), "Setting width to: %lf", request->width);
|
||||
|
||||
if (!enc_serial_port_.IsOpen()) {
|
||||
if (enc_serial_port_.IsOpen()) {
|
||||
union {
|
||||
std::array<double, sizeof(double)> bytes;
|
||||
std::array<u_char, sizeof(double)> bytes;
|
||||
double data;
|
||||
} value{};
|
||||
value.data = request->width;
|
||||
@ -71,7 +72,7 @@ class MgOdomPublisher : public rclcpp::Node {
|
||||
void zero(const std::shared_ptr<ZeroSrv::Request> /*request*/) {
|
||||
RCLCPP_INFO(get_logger(), "Zeroing odometry");
|
||||
|
||||
if (!enc_serial_port_.IsOpen()) {
|
||||
if (enc_serial_port_.IsOpen()) {
|
||||
enc_serial_port_ << "z;";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user