Skip to content

Commit

Permalink
also added StatusOverview service
Browse files Browse the repository at this point in the history
  • Loading branch information
chr-wurm authored and lenpuc committed Jun 1, 2023
1 parent d623e1c commit 7a5a2a2
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ add_message_files(

add_service_files(
FILES
FieldData.srv
ConfigMetadata.srv
FieldData.srv
StatusOverview.srv
)

generate_messages(
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ Returns all configured protective and warning fields for the sensor

Returns the meta data of the current configuration of the sensor

`
~/status_overview
`

Returns the status overview of the sensor


### ROS parameters

Expand Down
5 changes: 5 additions & 0 deletions include/sick_safetyscanners/SickSafetyscannersRos.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include <sick_safetyscanners/ConfigMetadata.h>
#include <sick_safetyscanners/OutputPathsMsg.h>
#include <sick_safetyscanners/RawMicroScanDataMsg.h>
#include <sick_safetyscanners/StatusOverview.h>
#include <sick_safetyscanners/SickSafetyscanners.h>
#include <sick_safetyscanners/SickSafetyscannersConfigurationConfig.h>
#include <sick_safetyscanners/datastructure/CommSettings.h>
Expand Down Expand Up @@ -144,6 +145,7 @@ class SickSafetyscannersRos

ros::ServiceServer m_field_service_server;
ros::ServiceServer m_config_metadata_server;
ros::ServiceServer m_status_overview_server;

bool m_initialised;

Expand Down Expand Up @@ -228,6 +230,9 @@ class SickSafetyscannersRos
bool getConfigMetadata(sick_safetyscanners::ConfigMetadata::Request& req,
sick_safetyscanners::ConfigMetadata::Response& res);

bool getStatusOverview(sick_safetyscanners::StatusOverview::Request& req,
sick_safetyscanners::StatusOverview::Response& res);

/**
* @brief getCheckSumString converts the uint32 value received as checksum such that the hexadecimal
* representation matches the value in the SafetyDesigner. To do this, we must invert the order of
Expand Down
32 changes: 32 additions & 0 deletions src/SickSafetyscannersRos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ SickSafetyscannersRos::SickSafetyscannersRos()

m_config_metadata_server =
m_nh.advertiseService("config_metadata", &SickSafetyscannersRos::getConfigMetadata, this);
m_status_overview_server =
m_nh.advertiseService("status_overview", &SickSafetyscannersRos::getStatusOverview, this);

// Diagnostics for frequency
m_diagnostic_updater.setHardwareID(m_communication_settings.getSensorIp().to_string());
Expand Down Expand Up @@ -879,6 +881,36 @@ bool SickSafetyscannersRos::getConfigMetadata(sick_safetyscanners::ConfigMetadat
return true;
}

bool SickSafetyscannersRos::getStatusOverview(sick_safetyscanners::StatusOverview::Request &req, sick_safetyscanners::StatusOverview::Response &res)
{
static_cast<void>(req);

sick::datastructure::StatusOverview status_overview;
m_device->requestStatusOverview(m_communication_settings, status_overview);

res.version_c_version = status_overview.getVersionCVersion();
res.version_major_version_number = status_overview.getVersionMajorVersionNumber();
res.version_minor_version_number = status_overview.getVersionMinorVersionNumber();
res.version_release_number = status_overview.getVersionReleaseNumber();

res.device_state = status_overview.getDeviceState();
res.config_state = status_overview.getConfigState();
res.application_state = status_overview.getApplicationState();
res.current_time_power_on_count = status_overview.getCurrentTimePowerOnCount();

res.current_time_date = status_overview.getCurrentTimeDate();
res.current_time_time = status_overview.getCurrentTimeTime();
res.current_time = getDateString(res.current_time_date, res.current_time_time);

res.error_info_code = status_overview.getErrorInfoCode();

res.error_info_time_date = status_overview.getErrorInfoDate();
res.error_info_time_time = status_overview.getErrorInfoTime();
res.error_info_time = getDateString(res.error_info_time_date, res.error_info_time_time);

return true;
}

std::string SickSafetyscannersRos::getCheckSumString(uint32_t checksum)
{
std::stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion srv/ConfigMetadata.srv
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ uint32 transfer_time_time
string version_c_version
uint8 version_major_version_number
uint8 version_minor_version_number
uint8 version_release_number
uint8 version_release_number
24 changes: 24 additions & 0 deletions srv/StatusOverview.srv
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

---

string version_c_version
uint8 version_major_version_number
uint8 version_minor_version_number
uint8 version_release_number

uint8 device_state
uint8 config_state
uint8 application_state
uint32 current_time_power_on_count

string current_time
# for devices without real time clock, also provide the raw time information
uint32 current_time_time
uint16 current_time_date

uint32 error_info_code

string error_info_time
# for devices without real time clock, also provide the raw time information
uint32 error_info_time_time
uint16 error_info_time_date

0 comments on commit 7a5a2a2

Please sign in to comment.