An example showing how to move the robot's elbow.
An example showing how to move the robot's elbow.
#include <cmath>
#include <iostream>
int main(int argc, char** argv) {
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " <robot-hostname>" << std::endl;
return -1;
}
try {
setDefaultBehavior(robot);
std::array<double, 7> q_goal = {{0, -M_PI_4, 0, -3 * M_PI_4, 0, M_PI_2, M_PI_4}};
std::cout << "WARNING: This example will move the robot! "
<< "Please make sure to have the user stop button at hand!" << std::endl
<< "Press Enter to continue..." << std::endl;
std::cin.ignore();
std::cout << "Finished moving to initial joint configuration." << std::endl;
{{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}},
{{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}},
{{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}},
{{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}}, {{20.0, 20.0, 20.0, 25.0, 25.0, 25.0}});
std::array<double, 16> initial_pose;
std::array<double, 2> initial_elbow;
double time = 0.0;
if (time == 0.0) {
initial_pose = robot_state.
O_T_EE;
initial_elbow = robot_state.
elbow;
}
double angle = M_PI / 10.0 * (1.0 - std::cos(M_PI / 5.0 * time));
auto elbow = initial_elbow;
elbow[0] += angle;
if (time >= 10.0) {
std::cout << std::endl << "Finished motion, shutting down example" << std::endl;
return franka::MotionFinished({initial_pose, elbow});
}
return {initial_pose, elbow};
});
std::cout << e.what() << std::endl;
return -1;
}
return 0;
}
An example showing how to generate a joint pose motion to a goal position.
Definition examples_common.h:31
Stores values for Cartesian pose motion generation.
Definition control_types.h:127
Represents a duration with millisecond resolution.
Definition duration.h:19
double toSec() const noexcept
Returns the stored duration in .
Maintains a network connection to the robot, provides the current robot state, gives access to the mo...
Definition robot.h:68
void control(std::function< Torques(const RobotState &, franka::Duration)> control_callback, bool limit_rate=false, double cutoff_frequency=kDefaultCutoffFrequency)
Starts a control loop for sending joint-level torque commands.
void setCollisionBehavior(const std::array< double, 7 > &lower_torque_thresholds_acceleration, const std::array< double, 7 > &upper_torque_thresholds_acceleration, const std::array< double, 7 > &lower_torque_thresholds_nominal, const std::array< double, 7 > &upper_torque_thresholds_nominal, const std::array< double, 6 > &lower_force_thresholds_acceleration, const std::array< double, 6 > &upper_force_thresholds_acceleration, const std::array< double, 6 > &lower_force_thresholds_nominal, const std::array< double, 6 > &upper_force_thresholds_nominal)
Changes the collision behavior.
Contains common types and functions for the examples.
Contains exception definitions.
Contains the franka::Robot type.
Base class for all exceptions used by libfranka.
Definition exception.h:20
Describes the robot state.
Definition robot_state.h:34
std::array< double, 16 > O_T_EE
Measured end effector pose in base frame.
Definition robot_state.h:40
std::array< double, 2 > elbow
Elbow configuration.
Definition robot_state.h:161