Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(omron_node): diagnostics for frequency #14

Merged
merged 2 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions omron_os32c_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 2.8.3)
project(omron_os32c_driver)

find_package(catkin REQUIRED COMPONENTS odva_ethernetip roscpp sensor_msgs)
find_package(catkin REQUIRED COMPONENTS diagnostic_updater odva_ethernetip roscpp sensor_msgs)

find_package(Boost 1.47 REQUIRED COMPONENTS system)

catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS odva_ethernetip roscpp sensor_msgs
CATKIN_DEPENDS diagnostic_updater odva_ethernetip roscpp sensor_msgs
LIBRARIES omron_os32c
DEPENDS Boost
)
Expand Down
1 change: 1 addition & 0 deletions omron_os32c_driver/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<buildtool_depend>catkin</buildtool_depend>

<depend>boost</depend>
<depend>diagnostic_updater</depend>
<depend>odva_ethernetip</depend>
<depend>roscpp</depend>
<depend>sensor_msgs</depend>
Expand Down
14 changes: 14 additions & 0 deletions omron_os32c_driver/src/os32c_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSI

#include <ros/ros.h>
#include <boost/shared_ptr.hpp>
#include <diagnostic_updater/diagnostic_updater.h>
#include <diagnostic_updater/update_functions.h>
#include <sensor_msgs/LaserScan.h>

#include "odva_ethernetip/socket/tcp_socket.h"
Expand All @@ -41,6 +43,8 @@ using eip::socket::TCPSocket;
using eip::socket::UDPSocket;
using namespace omron_os32c_driver;

double RATE = 12.856;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameterize the expected rate and permitted deviation, please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, any suggestions for naming?

  • ~expected_frequency (default=12.856)
  • ~frequency_tolerance (default=0.1)
  • ~timestamp_min_acceptable (default=-1)
  • ~timestamp_max_acceptable (default=5)


int main(int argc, char *argv[])
{
ros::init(argc, argv, "os32c");
Expand All @@ -57,6 +61,12 @@ int main(int argc, char *argv[])
// publisher for laserscans
ros::Publisher laserscan_pub = nh.advertise<LaserScan>("scan", 1);

// diagnostics for frequency, monitor with 0.1 tolerance
diagnostic_updater::Updater updater;
updater.setHardwareID(host);
diagnostic_updater::FrequencyStatus frequency_status(diagnostic_updater::FrequencyStatusParam(&RATE, &RATE));
updater.add(frequency_status);

boost::asio::io_service io_service;
shared_ptr<TCPSocket> socket = shared_ptr<TCPSocket>(new TCPSocket(io_service));
shared_ptr<UDPSocket> io_socket = shared_ptr<UDPSocket>(new UDPSocket(io_service, 2222));
Expand Down Expand Up @@ -113,6 +123,10 @@ int main(int argc, char *argv[])
laserscan_msg.header.seq++;
laserscan_pub.publish(laserscan_msg);

// Tick the frequency and update the diagnostics
frequency_status.tick();
updater.update();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@reinzor reinzor Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review, I was not aware of the DiagnosedPublisher, I will refactor this to the diagnosed publisher


// Every tenth message received, send the keepalive message in response.
// TODO: Make this time-based instead of message-count based.
if (++ctr > 10)
Expand Down