bump agv_pro_base to 1.0.1

This commit is contained in:
X-lanni
2025-06-18 11:45:46 +08:00
parent 0e68d8525d
commit 115318ee53
3 changed files with 17 additions and 12 deletions
@@ -39,8 +39,6 @@ private:
std::string name_space_; std::string name_space_;
std::string device_name_; std::string device_name_;
std::thread control_thread_;
double x= 0.0; double x= 0.0;
double y= 0.0; double y= 0.0;
double theta= 0.0; double theta= 0.0;
@@ -60,6 +58,7 @@ private:
float battery_voltage = 0.0f; float battery_voltage = 0.0f;
rclcpp::Time currentTime, lastTime; rclcpp::Time currentTime, lastTime;
rclcpp::TimerBase::SharedPtr control_timer_;
rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr pub_odom; rclcpp::Publisher<nav_msgs::msg::Odometry>::SharedPtr pub_odom;
rclcpp::Publisher<sensor_msgs::msg::Imu>::SharedPtr pub_imu; rclcpp::Publisher<sensor_msgs::msg::Imu>::SharedPtr pub_imu;
rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr pub_voltage; rclcpp::Publisher<std_msgs::msg::Float32>::SharedPtr pub_voltage;
+1 -1
View File
@@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> <?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3"> <package format="3">
<name>agv_pro_base</name> <name>agv_pro_base</name>
<version>1.0.0</version> <version>1.0.1</version>
<description>Control Nodes for AGV Pro</description> <description>Control Nodes for AGV Pro</description>
<maintainer email="weijun.xie@elephantrobotics.com">lanni</maintainer> <maintainer email="weijun.xie@elephantrobotics.com">lanni</maintainer>
<license>BSD-3-Clause license</license> <license>BSD-3-Clause license</license>
+15 -9
View File
@@ -243,18 +243,18 @@ void AGV_PRO::publisherOdom(double dt)
void AGV_PRO::Control() void AGV_PRO::Control()
{ {
lastTime = this->get_clock()->now();
while(rclcpp::ok())
{
currentTime = this->get_clock()->now();
double dt = (currentTime - lastTime).seconds();
if (true == readData()) if (true == readData())
{ {
publisherOdom(dt); currentTime = this->get_clock()->now();
//RCLCPP_INFO(this->get_logger(), "dt:%f", dt); double dt = 0.0;
publisherVoltage(); if (lastTime.nanoseconds() != 0) {
dt = (currentTime - lastTime).seconds();
} }
lastTime = currentTime; lastTime = currentTime;
publisherOdom(dt);
RCLCPP_INFO(this->get_logger(), "dt:%f", dt);
publisherVoltage();
} }
} }
@@ -285,6 +285,8 @@ AGV_PRO::AGV_PRO(std::string node_name):rclcpp::Node(node_name)
cmd_sub = this->create_subscription<geometry_msgs::msg::Twist>( cmd_sub = this->create_subscription<geometry_msgs::msg::Twist>(
"/cmd_vel", 10, std::bind(&AGV_PRO::cmdCallback, this, std::placeholders::_1)); "/cmd_vel", 10, std::bind(&AGV_PRO::cmdCallback, this, std::placeholders::_1));
lastTime = this->get_clock()->now();
drivers::serial_driver::SerialPortConfig config( drivers::serial_driver::SerialPortConfig config(
1000000, 1000000,
drivers::serial_driver::FlowControl::NONE, drivers::serial_driver::FlowControl::NONE,
@@ -309,7 +311,11 @@ AGV_PRO::AGV_PRO(std::string node_name):rclcpp::Node(node_name)
return; return;
} }
control_thread_ = std::thread(&AGV_PRO::Control, this); control_timer_ = this->create_wall_timer(
std::chrono::milliseconds(20),
std::bind(&AGV_PRO::Control, this)
);
} }
AGV_PRO::~AGV_PRO() AGV_PRO::~AGV_PRO()