6 #include <visp3/core/vpConfig.h> 8 #ifdef VISP_HAVE_FRANKA 10 #include <franka/exception.h> 11 #include <franka/robot.h> 25 int main(
int argc,
char **argv)
28 std::cerr <<
"Usage: ./generate_joint_velocity_motion <robot-hostname>" << std::endl;
32 franka::Robot robot(argv[1]);
36 robot.setCollisionBehavior(
37 {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}}, {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}},
38 {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}}, {{20.0, 20.0, 18.0, 18.0, 16.0, 14.0, 12.0}},
39 {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}},
40 {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}});
42 double time_max = 4.0;
43 double omega_max = 0.2;
45 robot.control([=, &time](
const franka::RobotState &, franka::Duration time_step) -> franka::JointVelocities {
46 time += time_step.toSec();
48 double cycle = std::floor(std::pow(-1.0, (time - std::fmod(time, time_max)) / time_max));
49 double omega = cycle * omega_max / 2.0 * (1.0 - std::cos(2.0 * M_PI / time_max * time));
51 franka::JointVelocities velocities = {{0.0, 0.0, 0.0, omega, omega, omega, omega}};
53 if (time >= 2 * time_max) {
54 std::cout << std::endl <<
"Finished motion, shutting down example" << std::endl;
55 return franka::MotionFinished(velocities);
59 }
catch (
const franka::Exception &e) {
60 std::cout << e.what() << std::endl;
68 int main() { std::cout <<
"This example needs libfranka to control Panda robot." << std::endl; }