Skip to content

Commit

Permalink
Merge branch 'roslog' into 'master'
Browse files Browse the repository at this point in the history
Roslog

Closes #3

See merge request ros/neo_relayboard_v3!4
  • Loading branch information
Pradheep Krishna Muthukrishnan Padmanabhan committed Mar 8, 2024
2 parents 5193710 + 63b78fd commit 323bb3e
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 12 deletions.
1 change: 1 addition & 0 deletions config/default/generic/RelayBoardV3Node.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
}
},
"topics_from_board": [
"vnx.log_out",
"platform.system_state",
"platform.power_state"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/Object.hpp>
#include <vnx/TopicPtr.hpp>
Expand Down
2 changes: 2 additions & 0 deletions generated/include/neo_relayboard_v3/RelayBoardV3Base.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/Object.hpp>
#include <vnx/TopicPtr.hpp>
Expand Down Expand Up @@ -74,6 +75,7 @@ public:
protected:
using Super::handle;

virtual void handle(std::shared_ptr<const ::vnx::LogMsg> _value) {}
virtual void handle(std::shared_ptr<const ::pilot::SystemState> _value) {}
virtual void handle(std::shared_ptr<const ::pilot::SafetyState> _value) {}
virtual void handle(std::shared_ptr<const ::pilot::EmergencyState> _value) {}
Expand Down
1 change: 1 addition & 0 deletions generated/include/neo_relayboard_v3/RelayBoardV3Client.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/Object.hpp>
#include <vnx/TopicPtr.hpp>
Expand Down
1 change: 1 addition & 0 deletions generated/src/RelayBoardV3AsyncClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/ModuleInterface_vnx_get_config.hxx>
#include <vnx/ModuleInterface_vnx_get_config_return.hxx>
Expand Down
4 changes: 4 additions & 0 deletions generated/src/RelayBoardV3Base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/ModuleInterface_vnx_get_config.hxx>
#include <vnx/ModuleInterface_vnx_get_config_return.hxx>
Expand Down Expand Up @@ -398,6 +399,9 @@ void RelayBoardV3Base::vnx_handle_switch(std::shared_ptr<const vnx::Value> _valu
case 0x735822e6960c247ull:
handle(std::static_pointer_cast<const ::pilot::kinematics::omnidrive::DriveState>(_value));
return;
case 0x2a13f6d072f9b852ull:
handle(std::static_pointer_cast<const ::vnx::LogMsg>(_value));
return;
default:
_type_code = _type_code->super;
}
Expand Down
1 change: 1 addition & 0 deletions generated/src/RelayBoardV3Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <pilot/kinematics/differential/DriveState.hxx>
#include <pilot/kinematics/mecanum/DriveState.hxx>
#include <pilot/kinematics/omnidrive/DriveState.hxx>
#include <vnx/LogMsg.hxx>
#include <vnx/Module.h>
#include <vnx/ModuleInterface_vnx_get_config.hxx>
#include <vnx/ModuleInterface_vnx_get_config_return.hxx>
Expand Down
1 change: 1 addition & 0 deletions include/neo_relayboard_v3/RelayBoardV3.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RelayBoardV3 : public RelayBoardV3Base{
protected:
void main() override;

void handle(std::shared_ptr<const vnx::LogMsg> value) override;
void handle(std::shared_ptr<const pilot::SystemState> value) override;
void handle(std::shared_ptr<const pilot::SafetyState> value) override;
void handle(std::shared_ptr<const pilot::EmergencyState> value) override;
Expand Down
1 change: 1 addition & 0 deletions modules/RelayBoardV3.vni
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module RelayBoardV3{

pilot.kinematic_type_e kinematic_type;

void handle(vnx.LogMsg value);
void handle(pilot.SystemState value);
void handle(pilot.SafetyState value);
void handle(pilot.EmergencyState value);
Expand Down
37 changes: 27 additions & 10 deletions src/RelayBoardV3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ void RelayBoardV3::main(){
}


void RelayBoardV3::handle(std::shared_ptr<const vnx::LogMsg> value){
const std::string message = value->get_output();
auto logger = nh->get_logger();

switch(value->level){
case ERROR:
RCLCPP_ERROR(logger, message);
break;
case WARN:
RCLCPP_WARN(logger, message);
break;
case DEBUG:
RCLCPP_DEBUG(logger, message);
break;
case INFO:
default:
RCLCPP_INFO(logger, message);
break;
}
}


void RelayBoardV3::handle(std::shared_ptr<const pilot::SystemState> value){
if (value->is_shutdown && !is_shutdown) {
RCLCPP_INFO(nh->get_logger(),"-----------SHUTDOWN Signal from RelayBoardV3----------");
Expand Down Expand Up @@ -497,8 +519,7 @@ bool RelayBoardV3::service_set_relay(std::shared_ptr<neo_srvs2::srv::RelayBoardS
res->success = true;
return true;
}catch(const std::exception &err){
const std::string error = "Service call failed with: " + std::string(err.what());
RCLCPP_ERROR_STREAM(nh->get_logger(), error);
log(WARN) << "Service call failed with: " << err.what();
res->success = false;
return false;
}
Expand All @@ -511,8 +532,7 @@ bool RelayBoardV3::service_set_digital_output(std::shared_ptr<neo_srvs2::srv::IO
res->success = true;
return true;
}catch(const std::exception &err){
const std::string error = "Service call failed with: " + std::string(err.what());
RCLCPP_ERROR_STREAM(nh->get_logger(), error);
log(WARN) << "Service call failed with: " << err.what();
res->success = false;
return false;
}
Expand All @@ -524,8 +544,7 @@ bool RelayBoardV3::service_start_charging(std::shared_ptr<std_srvs::srv::Empty::
platform_interface->start_charging();
return true;
}catch(const std::exception &err){
const std::string error = "Service call failed with: " + std::string(err.what());
RCLCPP_ERROR_STREAM(nh->get_logger(), error);
log(WARN) << "Service call failed with: " << err.what();
return false;
}
}
Expand All @@ -536,8 +555,7 @@ bool RelayBoardV3::service_stop_charging(std::shared_ptr<std_srvs::srv::Empty::R
platform_interface->stop_charging();
return true;
}catch(const std::exception &err){
const std::string error = "Service call failed with: " + std::string(err.what());
RCLCPP_ERROR_STREAM(nh->get_logger(), error);
log(WARN) << "Service call failed with: " << err.what();
return false;
}
}
Expand All @@ -549,8 +567,7 @@ bool RelayBoardV3::service_set_safety_field(std::shared_ptr<neo_srvs2::srv::SetS
res->success = true;
return true;
}catch(const std::exception &err){
const std::string error = "Service call failed with: " + std::string(err.what());
RCLCPP_ERROR_STREAM(nh->get_logger(), error);
log(WARN) << "Service call failed with: " << err.what();
res->success = false;
return false;
}
Expand Down
5 changes: 3 additions & 2 deletions src/relayboardv3_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ int main(int argc, char **argv){
vnx::read_config_tree(pilot_config);

{
vnx::Handle<vnx::Terminal> module = new vnx::Terminal("Terminal");
module.start_detached();
// disable vnx log, since the messages will be printed by ROS
vnx::ProcessClient process(process_name);
process.pause_log();
}

{
Expand Down

0 comments on commit 323bb3e

Please sign in to comment.