-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added FK
- Loading branch information
Showing
6 changed files
with
206 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,59 @@ | ||
# IK Geo C++ | ||
|
||
This is a wrapper for the Rust implementation for C++ | ||
This is a wrapper for the Rust implementation for C++. The outpiut of this build is 2 files: | ||
|
||
1. ik_geo.h | ||
2. libik_geo.so/libik_geo.lib | ||
|
||
## To build | ||
|
||
In this directory, run `cmake . && make`. This will create a dist folder with three files: | ||
- `ik_geo.h`, a header file to include in a c++ project | ||
- `libik_cpp.a` (or `libik_cpp.lib` in Windows), a static library that must be included to use ik_geo in c++. | ||
- `libik_geo.a` (or `libik_geo.lib` in Windows), another static library that must be included as well. | ||
```bash | ||
mkdir build | ||
cd build | ||
cmake .. && make | ||
``` | ||
|
||
## Including as a dependency | ||
|
||
You can get a CMake object to link against by including this source as a sub_directory. | ||
|
||
```cmake | ||
# Include the ik_geo cmake as a subdirectory | ||
add_subdirectory(.. IK_GEO) | ||
add_executable(test src/main.cpp) | ||
# Link against the ik_geo object produced by the ik_geo cmake | ||
target_link_libraries(test PRIVATE ik_geo) | ||
``` | ||
|
||
## To use | ||
|
||
Include the three files from the build step in the project, and look at `ik_geo.h` for function signatures. | ||
Include the header | ||
|
||
```c++ | ||
#include "ik_geo.h" | ||
``` | ||
|
||
Then you can create robots based off of kinematic specifications or select from hard coded ones | ||
|
||
```c++ | ||
int main() { | ||
Robot robot = Robot::ur5(); | ||
double rotation_matrix[9] = { | ||
1.0, 0.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
0.0, 0.0, 1.0 | ||
}; | ||
|
||
double position_vector[3] = {0.0, 0.0, 0.0}; | ||
|
||
There is an example usage of this in `../examples/cpp` | ||
std::vector<ik_geo::Solution> solutions; | ||
robot.ik(rotation_matrix, position_vector, solutions); | ||
} | ||
``` | ||
|
||
## To do | ||
|
||
- Test Windows implementation | ||
- Create a GitHub workflow for generating the dist files | ||
- Create a moveit package | ||
- Add a wrapper for forward kinematics and allow for calculating error. | ||
- Test Windows implementation | ||
- Create a moveit package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
#include <iostream> | ||
#include "ik_geo.h" | ||
#include <array> | ||
#include <iostream> | ||
#include <vector> | ||
|
||
|
||
using namespace ik_geo; | ||
|
||
int main(int argc, char const *argv[]) | ||
{ | ||
Robot robot = Robot::ur5(); | ||
// Create identity matrix | ||
double rotation_matrix[9] = { | ||
1.0, 0.0, 0.0, | ||
0.0, 1.0, 0.0, | ||
0.0, 0.0, 1.0 | ||
}; | ||
int main(int argc, char const *argv[]) { | ||
Robot robot = Robot::ur5(); | ||
double rotation_matrix[9] = {1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}; | ||
|
||
double position_vector[3] = {0.5, 0.5, 0.0}; | ||
|
||
double position_vector[3] = {0.0, 0.0, 0.0}; | ||
std::vector<ik_geo::Solution> solutions; | ||
robot.ik(rotation_matrix, position_vector, solutions); | ||
|
||
std::vector<ik_geo::Solution> solutions; | ||
robot.ik(rotation_matrix, position_vector, solutions); | ||
for (auto &solution : solutions) { | ||
|
||
for (auto &solution : solutions) { | ||
std::cout << "Solution: "; | ||
for (size_t i = 0; i < 6; i++) { | ||
std::cout << solution.q[i] << " "; | ||
} | ||
std::cout << "Is LS: " << solution.is_ls << std::endl; | ||
std::cout << "Solution: "; | ||
for (std::size_t i = 0; i < 6; i++) { | ||
std::cout << solution.q[i] << " "; | ||
} | ||
|
||
std::array<double, 9> rotation_matrix; | ||
std::array<double, 3> position_vector; | ||
robot.fk(solution.q, rotation_matrix, position_vector); | ||
std::cout << "Is LS: " << (solution.is_ls ? "True" : "False") << std::endl; | ||
std::cout << "Rotation Matrix: " << std::endl; | ||
for (std::size_t i = 0; i < 3; i++) { | ||
for (std::size_t j = 0; j < 3; j++) | ||
std::cout << rotation_matrix[i * 3 + j] << " "; | ||
std::cout << std::endl; | ||
} | ||
std::cout << "Position Vector: " << std::endl; | ||
for (std::size_t i = 0; i < 3; i++) { | ||
std::cout << position_vector[i] << " "; | ||
} | ||
return 0; | ||
std::cout << std::endl; | ||
} | ||
return 0; | ||
} |
Oops, something went wrong.