Skip to content

Commit

Permalink
Added unknown to bunker variant when value is out of range
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeelkii committed Jan 9, 2025
1 parent 2dee079 commit cd3d4a3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"files.associations": {
"ostream": "cpp"
}
}
4 changes: 2 additions & 2 deletions bunker_base/launch/bunker_base.launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def generate_launch_description():
description='Base link frame id')
odom_topic_arg = DeclareLaunchArgument('odom_topic_name', default_value='odom',
description='Odometry topic name')
bunker_variant_arg = DeclareLaunchArgument('bunker_variant_', default_value='1',
bunker_variant_arg = DeclareLaunchArgument('bunker_variant', default_value='0',
description='Bunker robot')
simulated_robot_arg = DeclareLaunchArgument('simulated_robot', default_value='false',
description='Whether running with simulator')
Expand All @@ -39,7 +39,7 @@ def generate_launch_description():
'odom_frame': launch.substitutions.LaunchConfiguration('odom_frame'),
'base_frame': launch.substitutions.LaunchConfiguration('base_frame'),
'odom_topic_name': launch.substitutions.LaunchConfiguration('odom_topic_name'),
'bunker_variant_': launch.substitutions.LaunchConfiguration('bunker_variant_'),
'bunker_variant': launch.substitutions.LaunchConfiguration('bunker_variant'),
'simulated_robot': launch.substitutions.LaunchConfiguration('simulated_robot'),
'control_rate': launch.substitutions.LaunchConfiguration('control_rate'),
}])
Expand Down
23 changes: 13 additions & 10 deletions bunker_base/src/bunker_base_ros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "bunker_base/bunker_messenger.hpp"
#include "ugv_sdk/utilities/protocol_detector.hpp"


namespace westonrobot {

BunkerBaseRos::BunkerBaseRos(std::string node_name)
Expand All @@ -24,35 +23,32 @@ BunkerBaseRos::BunkerBaseRos(std::string node_name)
this->declare_parameter("odom_topic_name", "odom");

this->declare_parameter("simulated_robot", false);
this->declare_parameter("bunker_variant_",
this->declare_parameter("bunker_variant",
static_cast<int>(BunkerRobot::Variant::kBunkerV2));
this->declare_parameter("control_rate", 50);

LoadParameters();
}



void BunkerBaseRos::LoadParameters() {

this->get_parameter_or<std::string>("port_name", port_name_, "can0");
this->get_parameter_or<std::string>("odom_frame", odom_frame_, "odom");
this->get_parameter_or<std::string>("base_frame", base_frame_, "base_link");
this->get_parameter_or<std::string>("odom_topic_name", odom_topic_name_,
"odom");
this->get_parameter_or<bool>("simulated_robot", simulated_robot_, false);
this->get_parameter_or<int>(
"bunker_variant_", bunker_variant_,
"bunker_variant", bunker_variant_,
static_cast<int>(BunkerRobot::Variant::kBunkerV2));
this->get_parameter_or<int>("control_rate", sim_control_rate_, 50);

std::cout << "Loading parameters: " << std::endl;
std::cout << "- port name: " << port_name_ << std::endl;
std::cout << "- odom frame name: " << odom_frame_ << std::endl;
std::cout << "- base frame name: " << base_frame_ << std::endl;
std::cout << "- odom topic name: " << odom_topic_name_ << std::endl;

std::cout << "- bunker variant: " ;
std::cout << "- bunker variant: ";

if (bunker_variant_ == static_cast<int>(BunkerRobot::Variant::kBunkerV1)) {
std::cout << "Bunker V1" << std::endl;
Expand All @@ -62,9 +58,13 @@ void BunkerBaseRos::LoadParameters() {
} else if (bunker_variant_ ==
static_cast<int>(BunkerRobot::Variant::kBunkerPro)) {
std::cout << "Bunker Pro" << std::endl;
} else {
} else if (bunker_variant_ ==
static_cast<int>(BunkerRobot::Variant::kBunkerMini)) {
std::cout << "Bunker Mini" << std::endl;
}
else{
std::cout << "Unknown" << std::endl;
}

std::cout << "- simulated robot: " << std::boolalpha << simulated_robot_
<< std::endl;
Expand All @@ -81,8 +81,11 @@ bool BunkerBaseRos::Initialize() {
} else if (bunker_variant_ ==
static_cast<int>(BunkerRobot::Variant::kBunkerPro)) {
std::cout << "Robot base: Bunker Pro" << std::endl;
} else {
} else if (bunker_variant_ ==
static_cast<int>(BunkerRobot::Variant::kBunkerMini)) {
std::cout << "Robot base: Bunker Mini" << std::endl;
} else {
std::cout << "Unknown" << std::endl;
}

ProtocolDetector detector;
Expand Down

0 comments on commit cd3d4a3

Please sign in to comment.