33 #include <sr_utilities/sr_math_utils.hpp> 38 unsigned int repetition,
unsigned int nb_mvt_step,
39 std::string controller_type,
bool testing, HandCommander* hand_commander)
40 : joint_name_(joint_name), nh_tilde(
"~"), publishing_rate(rate), repetition(repetition),
41 min(0.0), max(1.5), last_target_(0.0), nb_mvt_step(nb_mvt_step),
42 SError_(0.0), MSError_(0.0), n_samples_(0), controller_type(controller_type)
47 ROS_INFO(
"This is a test: sleeping 10 seconds for Gazebo to start.");
51 if (hand_commander != NULL)
58 sr_robot_msgs::joint joint;
103 double last_target = 0.0;
105 for (
unsigned int i_rep = 0; i_rep <
repetition; ++i_rep)
115 msg.data =
partial_movements[i].get_target(static_cast<double>(j) / static_cast<double>(nb_mvt_step));
118 if (
msg.data == -1.0)
120 msg.data = last_target;
135 last_target =
msg.data;
153 double error = msg->set_point - msg->process_value;
160 ROS_DEBUG_STREAM(
"MSe: " <<
MSError_);
165 double error = msg->set_point - msg->process_value;
172 ROS_DEBUG_STREAM(
"MSe: " <<
MSError_);
182 static_cast<double>(index_mvt_step) / static_cast<double>(
nb_mvt_step));
187 if (
msg.data == -1.0)
MovementPublisher(std::string joint_name, double rate=100.0, unsigned int repetition=1, unsigned int nb_mvt_step=1000, std::string controller_type="", bool testing=false, HandCommander *hand_commander=NULL)
void execute_step(int index_mvt_step, int index_partial_movement)
virtual ~MovementPublisher()
void set_subscriber(ros::Subscriber subscriber)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void add_movement(PartialMovement mvt)
Publishes a sequence of movements.
boost::shared_ptr< HandCommander > hand_commander_
void subscribe_and_default_pub_(std::string input)
void calculateErrorCallback(const control_msgs::JointControllerState::ConstPtr &msg)
std::string controller_type
std::string get_subscriber_topic()
std::vector< PartialMovement > partial_movements
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_DEBUG_STREAM(args)
void set_publisher(ros::Publisher publisher)
#define ROS_INFO_STREAM(args)
std::vector< sr_robot_msgs::joint > joint_vector_
ROSCPP_DECL void spinOnce()
void sr_calculateErrorCallback(const sr_robot_msgs::JointControllerState::ConstPtr &msg)
ros::Rate publishing_rate