20 "JointVelocityExampleController: Error getting velocity joint interface from hardware!");
25 if (!node_handle.
getParam(
"arm_id", arm_id)) {
26 ROS_ERROR(
"JointVelocityExampleController: Could not get parameter arm_id");
31 if (!node_handle.
getParam(
"joint_names", joint_names)) {
32 ROS_ERROR(
"JointVelocityExampleController: Could not parse joint names");
34 if (joint_names.size() != 7) {
35 ROS_ERROR_STREAM(
"JointVelocityExampleController: Wrong number of joint names, got " 36 << joint_names.size() <<
" instead of 7 names!");
40 for (
size_t i = 0; i < 7; ++i) {
45 "JointVelocityExampleController: Exception getting joint handles: " << ex.
what());
51 if (state_interface ==
nullptr) {
52 ROS_ERROR(
"JointVelocityExampleController: Could not get state interface from hardware");
57 auto state_handle = state_interface->getHandle(arm_id +
"_robot");
59 std::array<double, 7> q_start{{0, -M_PI_4, 0, -3 * M_PI_4, 0, M_PI_2, M_PI_4}};
60 for (
size_t i = 0; i < q_start.size(); i++) {
61 if (std::abs(state_handle.getRobotState().q_d[i] - q_start[i]) > 0.1) {
63 "JointVelocityExampleController: Robot is not in the expected starting position for " 64 "running this example. Run `roslaunch franka_example_controllers move_to_start.launch " 65 "robot_ip:=<robot-ip> load_gripper:=<has-attached-gripper>` first.");
71 "JointVelocityExampleController: Exception getting state handle: " << e.
what());
87 double omega_max = 0.1;
88 double cycle = std::floor(
91 double omega = cycle * omega_max / 2.0 *
95 joint_handle.setCommand(omega);
void starting(const ros::Time &) override
bool init(hardware_interface::RobotHW *robot_hardware, ros::NodeHandle &node_handle) override
std::array< std::string, 7 > joint_names
void update(const ros::Time &, const ros::Duration &period) override
const char * what() const noexcept override
bool getParam(const std::string &key, std::string &s) const
void stopping(const ros::Time &) override
std::vector< hardware_interface::JointHandle > velocity_joint_handles_
JointHandle getHandle(const std::string &name)
ros::Duration elapsed_time_
#define ROS_ERROR_STREAM(args)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
hardware_interface::VelocityJointInterface * velocity_joint_interface_