include
ros_control_boilerplate
tools
csv_to_controller.h
Go to the documentation of this file.
1
/*********************************************************************
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2015, University of Colorado, Boulder
5
* All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions
9
* are met:
10
*
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
13
* * Redistributions in binary form must reproduce the above
14
* copyright notice, this list of conditions and the following
15
* disclaimer in the documentation and/or other materials provided
16
* with the distribution.
17
* * Neither the name of the Univ of CO, Boulder nor the names of its
18
* contributors may be used to endorse or promote products derived
19
* from this software without specific prior written permission.
20
*
21
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
* POSSIBILITY OF SUCH DAMAGE.
33
*********************************************************************/
34
35
/* Author: Dave Coleman
36
Desc: Records a ros_control ControllerState data to CSV for Matlab/etc analysis
37
*/
38
39
#ifndef GENERIC_ROS_CONTROL__CSV_TO_CONTROLLER_H
40
#define GENERIC_ROS_CONTROL__CSV_TO_CONTROLLER_H
41
42
// ROS
43
#include <
ros/ros.h
>
44
45
// ros_control
46
#include <control_msgs/FollowJointTrajectoryAction.h>
47
#include <control_msgs/JointTrajectoryControllerState.h>
48
49
// actionlib
50
#include <
actionlib/client/simple_action_client.h
>
51
#include <
actionlib/client/terminal_state.h
>
52
53
namespace
ros_control_boilerplate
54
{
55
static
const
double
RECORD_RATE_HZ
= 100.0;
// times per second to record
56
57
class
CSVToController
58
{
59
public
:
63
CSVToController
(
const
std::string& joint_trajectory_action,
const
std::string& controller_state_topic);
64
66
void
stateCB
(
const
control_msgs::JointTrajectoryControllerState::ConstPtr& state);
67
68
void
printPoint
(trajectory_msgs::JointTrajectoryPoint& point);
69
70
// Start the data collection
71
void
loadAndRunCSV
(
const
std::string& file_name);
72
73
private
:
74
// A shared node handle
75
ros::NodeHandle
nh_
;
76
77
// Listener to state of controller
78
ros::Subscriber
state_sub_
;
79
80
// Action
81
actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction>
joint_trajectory_action_
;
82
83
// Where to save the CSV
84
std::string
file_name_
;
85
std::string
controller_state_topic_
;
86
87
// Cache of last recieved state
88
control_msgs::JointTrajectoryControllerState
current_state_
;
89
90
};
// end class
91
92
}
// namespace ros_control_boilerplate
93
94
#endif
ros_control_boilerplate::CSVToController::nh_
ros::NodeHandle nh_
Definition:
csv_to_controller.h:107
ros_control_boilerplate::CSVToController::printPoint
void printPoint(trajectory_msgs::JointTrajectoryPoint &point)
Definition:
csv_to_controller.cpp:106
ros_control_boilerplate
Definition:
generic_hw_control_loop.h:44
ros.h
terminal_state.h
ros_control_boilerplate::CSVToController::file_name_
std::string file_name_
Definition:
csv_to_controller.h:116
ros_control_boilerplate::CSVToController::joint_trajectory_action_
actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction > joint_trajectory_action_
Definition:
csv_to_controller.h:113
ros_control_boilerplate::CSVToController::current_state_
control_msgs::JointTrajectoryControllerState current_state_
Definition:
csv_to_controller.h:120
ros_control_boilerplate::CSVToController::state_sub_
ros::Subscriber state_sub_
Definition:
csv_to_controller.h:110
actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction >
ros_control_boilerplate::RECORD_RATE_HZ
static const double RECORD_RATE_HZ
Definition:
csv_to_controller.h:87
simple_action_client.h
ros_control_boilerplate::CSVToController::CSVToController
CSVToController(const std::string &joint_trajectory_action, const std::string &controller_state_topic)
Constructor.
Definition:
csv_to_controller.cpp:84
ros_control_boilerplate::CSVToController::stateCB
void stateCB(const control_msgs::JointTrajectoryControllerState::ConstPtr &state)
Callback from ROS message.
Definition:
csv_to_controller.cpp:101
ros_control_boilerplate::CSVToController::controller_state_topic_
std::string controller_state_topic_
Definition:
csv_to_controller.h:117
ros_control_boilerplate::CSVToController::loadAndRunCSV
void loadAndRunCSV(const std::string &file_name)
Definition:
csv_to_controller.cpp:114
ros::NodeHandle
ros::Subscriber
ros_control_boilerplate
Author(s): Dave Coleman
autogenerated on Wed Mar 2 2022 00:52:14