28 #ifndef QB_DEVICE_CONTROL_H 29 #define QB_DEVICE_CONTROL_H 37 #include <control_msgs/FollowJointTrajectoryAction.h> 41 #include <std_msgs/Int32.h> 85 void move(
const trajectory_msgs::JointTrajectory &joint_trajectory,
const std::string &controller);
96 std::vector<trajectory_msgs::JointTrajectoryPoint>
getSinusoidalPoints(
const double &litude,
const double &period,
const int &samples_per_period,
const int &periods);
108 std::vector<trajectory_msgs::JointTrajectoryPoint>
getTrapezoidalPoints(
const double &litude,
const double &period,
const double &ramp_duration,
const int &periods);
118 trajectory_msgs::JointTrajectory
getCustomTrajectory(
const std::vector<std::vector<trajectory_msgs::JointTrajectoryPoint>> &joint_points,
const std::string &controller);
170 std::map<std::string, std::unique_ptr<actionlib::SimpleActionClient<control_msgs::FollowJointTrajectoryAction>>>
action_clients_;
207 void actionFeedbackCallback(
const control_msgs::FollowJointTrajectoryFeedbackConstPtr &feedback,
const std::string &controller);
285 bool setAsyncCommandsCallback(qb_device_srvs::SetCommandsRequest &request, qb_device_srvs::SetCommandsResponse &response);
298 bool setAsyncPIDCallback(qb_device_srvs::SetPIDRequest &request, qb_device_srvs::SetPIDResponse &response);
323 #endif // QB_DEVICE_CONTROL_H ros::ServiceServer set_async_commands_server_
ros::ServiceClient set_pid_client_
The qbrobotics Control interface provides all the common structures to control both the qbhand and qb...
bool getAsyncMeasurementsCallback(qb_device_srvs::GetMeasurementsRequest &request, qb_device_srvs::GetMeasurementsResponse &response)
Make a call to the same type of service provided by the Communication Handler.
trajectory_msgs::JointTrajectory getCustomTrajectory(const std::vector< std::vector< trajectory_msgs::JointTrajectoryPoint >> &joint_points, const std::string &controller)
Build a joint trajectory for the given controller using the given points, which must match the contro...
bool setAsyncCommandsCallback(qb_device_srvs::SetCommandsRequest &request, qb_device_srvs::SetCommandsResponse &response)
Make a call to the same type of service provided by the Communication Handler.
bool waitForResult(const ros::Duration &timeout, const std::string &controller)
Wait until the action is completed or the given timeout is reached.
ros::WallTimer frequency_timer_
void initActionClients()
Retrieve all the controllers which have their parameters set in the Parameter Server and initialize t...
std::vector< trajectory_msgs::JointTrajectoryPoint > getTrapezoidalPoints(const double &litude, const double &period, const double &ramp_duration, const int &periods)
Build a single-joint trapezoidal wave point trajectory from the given parameters. ...
std::map< std::string, std::string > controller_device_name_
std::map< std::string, trajectory_msgs::JointTrajectory > joint_trajectories_
std::map< std::string, std::unique_ptr< actionlib::SimpleActionClient< control_msgs::FollowJointTrajectoryAction > > > action_clients_
ros::Publisher frequency_publisher_
ros::ServiceServer get_async_measurements_server_
std::vector< std::string > controllers_
T xmlCast(XmlRpc::XmlRpcValue xml_value)
Cast an XmlRpcValue from TypeDouble, TypeInt or TypeBoolean to the specified template type...
bool parseVector(const XmlRpc::XmlRpcValue &xml_value, const std::string &controller, std::vector< double > &vector)
Parse the given XmlRpcValue as a std::vector, since the XmlRpc::XmlRpcValue class does not handle thi...
void update(const ros::WallTime &time, const ros::WallDuration &period)
Read the current state from the HW, update all active controllers, and send the new references to the...
std::string extractDeviceName(const std::string &controller)
Extract the device names associated to the given controller (each controller name is assumed to start...
void controlSetupCallback(const ros::WallTimerEvent &timer_event)
Initialize the control timer and automatically start the waypoint trajectory if it is not empty...
void actionDoneCallback(const actionlib::SimpleClientGoalState &state, const control_msgs::FollowJointTrajectoryResultConstPtr &result, const std::string &controller)
Restart the waypoint trajectory automatically if waypoints have been retrieved during the initializat...
ros::WallDuration control_duration_
void controlCallback(const ros::WallTimerEvent &timer_event)
Call the update() each time the timer triggers.
std::vector< trajectory_msgs::JointTrajectoryPoint > getSinusoidalPoints(const double &litude, const double &period, const int &samples_per_period, const int &periods)
Build a single-joint sine wave point trajectory from the given parameters.
std::map< std::string, std::vector< std::string > > controller_joints_
qbDeviceControl()
Initialize the control structures needed by ros_control: the combined_robot_hw::CombinedRobotHW to co...
ros::ServiceServer set_async_pid_server_
ros::ServiceClient get_measurements_client_
ros::WallTimer control_setup_timer_
ros::CallbackQueuePtr callback_queue_
ros::ServiceClient set_commands_client_
bool setAsyncPIDCallback(qb_device_srvs::SetPIDRequest &request, qb_device_srvs::SetPIDResponse &response)
Make a call to the same type of service provided by the Communication Handler.
void move()
Make all the calls to the Action Servers relative to all the waypoint trajectories previously parsed...
ros::WallTimer control_timer_
ros::NodeHandle node_handle_control_
std::mutex sync_protector_
void frequencyCallback(const ros::WallTimerEvent &timer_event)
Publish the real control loop frequency in Hz in the relative topic.
void actionFeedbackCallback(const control_msgs::FollowJointTrajectoryFeedbackConstPtr &feedback, const std::string &controller)
Do nothing apart from debug info.
void parseWaypoints()
Parse all the waypoints set up in the Parameter Server at <robot_namespace>/waypoints.
ros::AsyncSpinner spinner_
virtual ~qbDeviceControl()
Stop timer and spinner structures.
void actionActiveCallback(const std::string &controller)
Do nothing apart from debug info.
std::vector< std::string > device_names_
controller_manager::ControllerManager controller_manager_
ros::NodeHandle node_handle_
trajectory_msgs::JointTrajectory getWaypointTrajectory(ros::NodeHandle &node_handle, const std::string &controller)
Retrieve a set of reference waypoints from the Parameter Server.
combined_robot_hw::CombinedRobotHW devices_