diff --git a/catkin_ws/src/poppy_ros/CMakeLists.txt b/catkin_ws/src/poppy_ros/CMakeLists.txt index 99636c6..81e69c3 100644 --- a/catkin_ws/src/poppy_ros/CMakeLists.txt +++ b/catkin_ws/src/poppy_ros/CMakeLists.txt @@ -12,7 +12,7 @@ find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs - message_generation +# message_generation ) find_package(OpenCV REQUIRED COMPONENTS core @@ -65,10 +65,10 @@ find_package(OpenCV REQUIRED COMPONENTS # Service1.srv # Service2.srv # ) -add_service_files( - FILES - ik.srv -) +#add_service_files( +# FILES +# ik.srv +#) ## Generate actions in the 'action' folder # add_action_files( # FILES @@ -81,10 +81,10 @@ add_service_files( # DEPENDENCIES # std_msgs # ) -generate_messages( - DEPENDENCIES - std_msgs -) +#generate_messages( +# DEPENDENCIES +# std_msgs +#) ################################################ ## Declare ROS dynamic reconfigure parameters ## ################################################ @@ -157,9 +157,9 @@ add_executable(poppy_test src/poppy_test.cpp) add_executable(poppy_pong_iv src/poppy_pong_iv.cpp) add_executable(poppy_track_x src/poppy_track_x.cpp) -add_executable(ik_server src/ik_server.cpp /home/lucas/toolkit-kinematics/src/Kinematics.cpp /home/lucas/toolkit-kinematics/src/RotationMatrix.cpp /home/lucas/toolkit-kinematics/src/TranslationMatrix.cpp /home/lucas/toolkit-kinematics/src/TransformationMatrix.cpp) +#add_executable(ik_server src/ik_server.cpp /home/lucas/toolkit-kinematics/src/Kinematics.cpp /home/lucas/toolkit-kinematics/src/RotationMatrix.cpp /home/lucas/toolkit-kinematics/src/TranslationMatrix.cpp /home/lucas/toolkit-kinematics/src/TransformationMatrix.cpp) -add_executable(ik_client src/ik_client.cpp) +#add_executable(ik_client src/ik_client.cpp) add_executable(sim_poppy_joint src/sim_poppy_joint.cpp) ## Rename C++ executable without prefix @@ -181,9 +181,9 @@ target_link_libraries(poppy_test ${catkin_LIBRARIES}) target_link_libraries(poppy_pong_iv ${catkin_LIBRARIES}) target_link_libraries(poppy_track_x ${catkin_LIBRARIES}) -target_link_libraries(ik_server ${catkin_LIBRARIES} ${OpenCV_LIBS}) +#target_link_libraries(ik_server ${catkin_LIBRARIES} ${OpenCV_LIBS}) -target_link_libraries(ik_client ${catkin_LIBRARIES}) +#target_link_libraries(ik_client ${catkin_LIBRARIES}) target_link_libraries(sim_poppy_joint ${catkin_LIBRARIES}) ############# ## Install ## diff --git a/catkin_ws/src/poppy_ros/package.xml b/catkin_ws/src/poppy_ros/package.xml index 84b2fc0..62de016 100644 --- a/catkin_ws/src/poppy_ros/package.xml +++ b/catkin_ws/src/poppy_ros/package.xml @@ -52,11 +52,9 @@ roscpp rospy std_msgs - message_generation roscpp rospy std_msgs - message_runtime roscpp rospy std_msgs diff --git a/catkin_ws/src/poppy_ros/src/ik_client.cpp b/catkin_ws/src/poppy_ros/src/ik_client.cpp deleted file mode 100644 index 012a1d4..0000000 --- a/catkin_ws/src/poppy_ros/src/ik_client.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include "ros/ros.h" -#include "poppy_ros/ik.h" -#include "geometry_msgs/Twist.h" - - -int main(int argc, char** argv) -{ - ros::init(argc, argv, "ik_client"); - ros::NodeHandle nh; - ros::ServiceClient client = nh.serviceClient("ik"); - ros::Publisher joint_cmd_pub = nh.advertise("/joint_cmd", 1); - poppy_ros::ik srv; - srv.request.x = atoll(argv[1]); - srv.request.y = atoll(argv[2]); - srv.request.z = atoll(argv[3]); - if (client.call(srv)) - { - // Assuming joint values are to be published as a geometry_msgs::Twist message - geometry_msgs::Twist joint_cmd; - - joint_cmd.linear.x = srv.response.joints[0]; - joint_cmd.linear.y = srv.response.joints[1]; - joint_cmd.linear.z = srv.response.joints[2]; - joint_cmd.angular.x = srv.response.joints[3]; - joint_cmd.angular.y = srv.response.joints[4]; - joint_cmd.angular.z = srv.response.joints[5]; - - joint_cmd_pub.publish(joint_cmd); - ROS_INFO("Command passed"); - } else { - ROS_ERROR("Failed to call service ik_service"); - } - return 0; -} diff --git a/catkin_ws/src/poppy_ros/src/ik_server.cpp b/catkin_ws/src/poppy_ros/src/ik_server.cpp deleted file mode 100644 index 6515cdc..0000000 --- a/catkin_ws/src/poppy_ros/src/ik_server.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "ros/ros.h" -#include "poppy_ros/ik.h" -#include "Kinematics.h" -#include - -Kinematics kinematics; - -bool ProcessIK(poppy_ros::ik::Request &req, poppy_ros::ik::Response &res) { - // Create a cv::Mat for Cartesian coordinates - cv::Mat cartesian_coords = (cv::Mat_(3, 1) << req.x, req.y, req.z); - - // Create a cv::Mat for joint values - cv::Mat joint_values; - - // Perform inverse kinematics calculations and get the result directly - kinematics.inverseKinematics(cartesian_coords); - - // Get the joint values after inverse kinematics - joint_values = kinematics.computeCurrentEndEffectorPosition(); - - - // Set the response - if (!joint_values.empty()) { - // Convert cv::Mat to std::vector - std::vector joint_values_vector(joint_values.begin(), joint_values.end()); - - // Set the response - res.joints = joint_values_vector; - return true; - } else { - ROS_ERROR("Inverse kinematics calculation failed."); - return false; - } -} - -int main(int argc, char** argv) -{ - ros::init(argc, argv, "ik_server"); - ros::NodeHandle nh; - - //load to the kinematics lib - kinematics.loadDHParameters("/home/lucas/catkin_ws/src/poppy_ros/src/poppy_dh.yaml"); - kinematics.loadIKParameters("/home/lucas/catkin_ws/src/poppy_ros/src/poppy_ik.yaml"); - - ros::ServiceServer server = nh.advertiseService("ik", ProcessIK); - ros::spin(); - return 0; -} - diff --git a/catkin_ws/src/poppy_ros/src/poppy_dh.yaml b/catkin_ws/src/poppy_ros/src/poppy_dh.yaml deleted file mode 100644 index 566c147..0000000 --- a/catkin_ws/src/poppy_ros/src/poppy_dh.yaml +++ /dev/null @@ -1,11 +0,0 @@ -%YAML:1.0 ---- -dhThetaParams: [ 0., 0., 0., 0., 0., 0., 0. ] -dhDParams: [ 2.5000000000000000e+00, 2.5000000000000000e+00, 0., 0., 0., - 0., 0. ] -dhAParams: [ 0., 0., 5.5000000000000000e+00, 3., 0., 5., 12. ] -dhAlphaParams: [ 0., 90., 0., 0., -90., 90., 0. ] -jointType: [ 0, 1, 1, 1, 0, 1, 1 ] -nbJoints: 5 -jointOffset: [ 0., 0., 90., 0., -90., 0., 0. ] -qiValues: [ 0., 0., 0., 0., 90. ] diff --git a/catkin_ws/src/poppy_ros/src/poppy_ik.yaml b/catkin_ws/src/poppy_ros/src/poppy_ik.yaml deleted file mode 100644 index 7605a03..0000000 --- a/catkin_ws/src/poppy_ros/src/poppy_ik.yaml +++ /dev/null @@ -1,6 +0,0 @@ -%YAML:1.0 ---- -maxNbIterations: 1000 -pController: 0.5 -rankThreshold: 0.2 -distanceThreshold: 0.01 diff --git a/catkin_ws/src/poppy_ros/srv/ik.srv b/catkin_ws/src/poppy_ros/srv/ik.srv deleted file mode 100644 index 65250ef..0000000 --- a/catkin_ws/src/poppy_ros/srv/ik.srv +++ /dev/null @@ -1,5 +0,0 @@ -int64 x -int64 y -int64 z ---- -float64[] joints