Added pioneer_id parameter

This commit is contained in:
Jakub Delicat 2022-09-29 12:22:30 +02:00
parent 598f597d53
commit a1a54f58e4
7 changed files with 10 additions and 14 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
PIONEER_ID=5

View File

@ -2,4 +2,4 @@ version: "3"
services: services:
ros2aria: ros2aria:
build: . build: .
command: ros2 run ros2aria ros2aria command: ros2 run ros2aria ros2aria --ros-args -p pioneer_id:=${PIONEER_ID}

View File

@ -28,7 +28,7 @@ private:
ArFunctorC<Ros2Aria> sensorCb; ArFunctorC<Ros2Aria> sensorCb;
// config // config
std::string sonar_frame_id; std::size_t pioneer_id;
// publishers // publishers
void publish(); void publish();

View File

@ -19,8 +19,8 @@ nav_msgs::msg::Odometry Ros2Aria::handlePose(rclcpp::Time stamp) {
odom_msg.twist.twist.linear.y = r->getLatVel() / 1000; odom_msg.twist.twist.linear.y = r->getLatVel() / 1000;
odom_msg.twist.twist.angular.z = r->getRotVel() * M_PI / 180; odom_msg.twist.twist.angular.z = r->getRotVel() * M_PI / 180;
odom_msg.header.frame_id = "header.frame_id"; // TODO: use correct frame_id odom_msg.header.frame_id = "odom";
odom_msg.child_frame_id = "child_frame_id"; // TODO: use correct child_frame_id odom_msg.child_frame_id = "base_link";
odom_msg.header.stamp = stamp; odom_msg.header.stamp = stamp;
return odom_msg; return odom_msg;

View File

@ -37,7 +37,9 @@ Ros2Aria::Ros2Aria()
auto r = robot->getRobot(); auto r = robot->getRobot();
r->addSensorInterpTask("ROSPublishingTask", 100, &this->sensorCb); r->addSensorInterpTask("ROSPublishingTask", 100, &this->sensorCb);
sonar_frame_id = "pionier6"; // TODO: use args declare_parameter<uint8_t>("pioneer_id");
pioneer_id = get_parameter("pioneer_id").as_int();
RCLCPP_INFO(get_logger(), "PIONEER_ID = %d", pioneer_id);
} }
Ros2Aria::~Ros2Aria() Ros2Aria::~Ros2Aria()

View File

@ -6,7 +6,7 @@ sensor_msgs::msg::PointCloud Ros2Aria::handleSonar(rclcpp::Time stamp)
sensor_msgs::msg::PointCloud cloud; //sonar readings. sensor_msgs::msg::PointCloud cloud; //sonar readings.
cloud.header.stamp = stamp; cloud.header.stamp = stamp;
// sonar sensors relative to base_link // sonar sensors relative to base_link
cloud.header.frame_id = this->sonar_frame_id; cloud.header.frame_id = "sonar_frame";
auto r = robot->getRobot(); auto r = robot->getRobot();

View File

@ -13,20 +13,13 @@ void Ros2Aria::publishState(rclcpp::Time stamp)
this->battery_recharge_state_pub_->publish(recharge_state); this->battery_recharge_state_pub_->publish(recharge_state);
} }
// TODO: our robots don't have this, cannot test
if (r->haveStateOfCharge() && this->battery_state_of_charge_pub_->get_subscription_count() > 0)
{
std_msgs::msg::Float32 soc;
soc.data = r->getStateOfCharge() / 100.0;
this->battery_state_of_charge_pub_->publish(soc);
}
if (this->robot_info_pub_->get_subscription_count() > 0) if (this->robot_info_pub_->get_subscription_count() > 0)
{ {
ros2aria_msgs::msg::RobotInfoMsg robot_info_msg; ros2aria_msgs::msg::RobotInfoMsg robot_info_msg;
// TODO: allow setting the robot_id // TODO: allow setting the robot_id
robot_info_msg.robot_id.data = 6; robot_info_msg.robot_id.data = pioneer_id;
robot_info_msg.battery_voltage.data = r->getRealBatteryVoltageNow(); robot_info_msg.battery_voltage.data = r->getRealBatteryVoltageNow();
robot_info_msg.twist.linear.x = r->getVel() / 1000; robot_info_msg.twist.linear.x = r->getVel() / 1000;
robot_info_msg.twist.linear.y = r->getLatVel() / 1000.0; robot_info_msg.twist.linear.y = r->getLatVel() / 1000.0;