-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #431 from gergondet/topic/mc_convex_visualization
Introduce tools to display surfaces and convex
- Loading branch information
Showing
32 changed files
with
988 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
`mc_convex_visualization` is a tool that allows you to visualize the convexes of a robot in the RViZ application. It is part of the {% link mc_rtc_ros %} package. | ||
`mc_convex_visualization` is a tool that allows you to visualize the convexes of a robot in any mc_rtc GUI application. | ||
|
||
### Launching the visualization | ||
|
||
The tool is launched as follows: | ||
|
||
```bash | ||
$ roslaunch mc_convex_visualization display.launch robot:=JVRC1 | ||
$ mc_convex_visualization JVRC1 | ||
``` | ||
|
||
The `robot` argument should be the same as what you would pass to the `mc_rbdyn::RobotLoader::get_robot_module` function, this can also be a robot alias. For example: | ||
The arguments to the program should be the same as you would use as a `MainRobot` entry. It can also handle aliases. For example: | ||
|
||
```bash | ||
# Specify a vector of arguments | ||
$ roslaunch mc_convex_visualization display.launch robot:="[env, `rospack find mc_env_description`, ground]" | ||
$ mc_convex_visualization env `rospack find mc_env_description` ground | ||
# Or an alias | ||
$ roslaunch mc_convex_visualization display.launch robot:=env/ground | ||
$ mc_convex_visualization env/ground | ||
``` | ||
|
||
After launching it should look like this: | ||
After launching an mc_rtc GUI, it should look like this: | ||
|
||
<img src="{{site.baseurl_root}}/assets/tutorials/tools/img/mc_convex_visualization.png" alt="mc_convex_visualization in action" class="img-fluid" /> | ||
|
||
By enabling/disabling the checkboxes in the highlighted area you can show/hide selected convexes. | ||
You can easily select which convexes to display through the interface. |
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,24 +1,24 @@ | ||
`mc_convex_visualization`は、ロボットの凸領域をRVizで表示するツールです。{% link mc_rtc_ros %}パッケージに含まれています。 | ||
`mc_convex_visualization` は mc_rtc GUI アプリケーションでロボットの凸部を可視化するツールです。 | ||
|
||
### 可視化ツールを起動する | ||
### ビジュアライゼーションの起動 | ||
|
||
以下のようにツールを起動します。 | ||
ツールの起動方法は以下の通りです: | ||
|
||
```bash | ||
$ roslaunch mc_convex_visualization display.launch robot:=JVRC1 | ||
$ mc_convex_visualization JVRC1 | ||
``` | ||
|
||
引数`robot`には、`mc_rbdyn::RobotLoader::get_robot_module`関数に渡すのと同じものを指定する必要があります。なお、この引数ではロボットの別名を使用できます。例: | ||
プログラムの引数は `MainRobot` のエントリと同じものを指定します。エイリアスも扱えます。例えば | ||
|
||
```bash | ||
# 引数のベクトルとして与える方法 | ||
$ roslaunch mc_convex_visualization display.launch robot:="[env, `rospack find mc_env_description`, ground]" | ||
# エイリアスを使用する方法 | ||
$ roslaunch mc_convex_visualization display.launch robot:=env/ground | ||
# 引数のベクトルを指定する | ||
$ mc_convex_visualization env `rospack find mc_env_description` ground | ||
# またはエイリアス | ||
$ mc_convex_visualization env/ground | ||
``` | ||
|
||
このツールを起動すると、以下のように表示されます。 | ||
mc_rtc GUIを起動した後、これが表示されるはずです: | ||
|
||
<img src="{{site.baseurl_root}}/assets/tutorials/tools/img/mc_convex_visualization.png" alt="mc_convex_visualization in action" class="img-fluid" /> | ||
|
||
赤い枠で囲まれた領域にあるチェックボックスをオン・オフすることで、選択した凸領域の表示・非表示を切り替えられます。 | ||
インターフェースを通じて表示する凸形状を簡単に選択できます。 |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+164 KB
(160%)
doc/assets/tutorials/tools/img/mc_surfaces_visualization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright 2015-2024 CNRS-UM LIRMM, CNRS-AIST JRL | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <mc_control/api.h> | ||
|
||
#include <mc_rtc/Configuration.h> | ||
#include <mc_rtc/path.h> | ||
|
||
namespace mc_control | ||
{ | ||
|
||
namespace details | ||
{ | ||
|
||
// FIXME This could be inside ControllerServerConfiguration but it crashes clang-10 | ||
|
||
/** "Classic" socket configuration | ||
* | ||
* \tparam default_pub_port Default publisher port | ||
* | ||
* \tparam default_pull_port Default pull port | ||
*/ | ||
template<uint16_t default_pub_port, uint16_t default_pull_port> | ||
struct SocketConfiguration | ||
{ | ||
/** Which host the socket binds to */ | ||
std::string host = "*"; | ||
/** Publisher port */ | ||
uint16_t pub_port = default_pub_port; | ||
/** Pull request port */ | ||
uint16_t pull_port = default_pull_port; | ||
}; | ||
|
||
} // namespace details | ||
|
||
/** Configuration for \ref mc_control::ControllerServer */ | ||
struct MC_CONTROL_DLLAPI ControllerServerConfiguration | ||
{ | ||
/** Controller server publication timestep | ||
* | ||
* If it is null or negative, the timestep will be the same as the controller | ||
* | ||
* If it happens to be lower than the controller's timestep then it will also be the same | ||
*/ | ||
double timestep = 0.05; | ||
|
||
/** IPC socket file | ||
* | ||
* Actual ipc sockets are created as socket + "_pub.ipc" and socket + "_rep.ipc" | ||
* | ||
* If nullopt, IPC is disabled | ||
*/ | ||
std::optional<std::string> ipc_socket = mc_rtc::temp_directory_path("mc_rtc"); | ||
|
||
using TCPConfiguration = details::SocketConfiguration<4242, 4343>; | ||
|
||
/** Configuration for the TCP socket | ||
* | ||
* TCP is disabled if this is nullopt | ||
*/ | ||
std::optional<TCPConfiguration> tcp_config = TCPConfiguration{}; | ||
|
||
using WebSocketConfiguration = details::SocketConfiguration<8080, 8081>; | ||
|
||
/** Configuration for the WebSocket socket | ||
* | ||
* WebSocket is disabled if this is nullopt (default) | ||
*/ | ||
std::optional<WebSocketConfiguration> websocket_config = std::nullopt; | ||
|
||
/** Loads from a configuration object */ | ||
void load(const mc_rtc::Configuration & config); | ||
|
||
/** Returns the URI(s) the PUB socket should bind to */ | ||
std::vector<std::string> pub_uris() const noexcept; | ||
|
||
/** Returns the URI(s) the PULL socket should bind to */ | ||
std::vector<std::string> pull_uris() const noexcept; | ||
|
||
/** Prints a message about the server configuration */ | ||
void print_serving_information() const noexcept; | ||
|
||
static ControllerServerConfiguration fromConfiguration(const mc_rtc::Configuration & config); | ||
}; | ||
|
||
} // namespace mc_control |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2015-2024 CNRS-UM LIRMM, CNRS-AIST JRL | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <mc_rbdyn/Robot.h> | ||
|
||
#include <mc_rtc/gui/StateBuilder.h> | ||
#include <mc_rtc/gui/types.h> | ||
|
||
namespace mc_rbdyn::gui | ||
{ | ||
|
||
static const mc_rtc::gui::PolyhedronConfig defaultConvexConfig = []() | ||
{ | ||
mc_rtc::gui::PolyhedronConfig cfg; | ||
cfg.triangle_color = {0, 0.8, 0, 0.5}; | ||
cfg.edge_config.color = {0, 1, 0, 1}; | ||
cfg.edge_config.width = 0.001; | ||
cfg.show_edges = true; | ||
cfg.show_vertices = false; | ||
return cfg; | ||
}(); | ||
|
||
/** Helper function to create a GUI element from a convex object inside a robot | ||
* | ||
* \param gui State builder where the object is added (typically controller.gui() | ||
* | ||
* \param category Category where the object is added | ||
* | ||
* \param cfg Configuration of the appearance of the convex object | ||
* | ||
* \param robot Robot that the convex belongs to, this reference is captured by the GUI and should survive | ||
* | ||
* \param name Name of the collision object added to the GUI, the object should remain in the robot while it is in the | ||
* GUI | ||
* | ||
* \param publishName Name of the object in the GUI, defaults to \param name | ||
*/ | ||
MC_RBDYN_DLLAPI void addConvexToGUI(mc_rtc::gui::StateBuilder & gui, | ||
const std::vector<std::string> & category, | ||
const mc_rbdyn::Robot & robot, | ||
const std::string & name, | ||
const mc_rtc::gui::PolyhedronConfig & cfg = defaultConvexConfig, | ||
const std::optional<std::string> & publishName = std::nullopt); | ||
|
||
} // namespace mc_rbdyn::gui |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2015-2024 CNRS-UM LIRMM, CNRS-AIST JRL | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <mc_rbdyn/Robot.h> | ||
#include <mc_rtc/gui/StateBuilder.h> | ||
|
||
namespace mc_rbdyn::gui | ||
{ | ||
|
||
static const mc_rtc::gui::LineConfig defaultSurfaceConfig = []() { | ||
return mc_rtc::gui::LineConfig{mc_rtc::gui::Color::Green, 0.01}; | ||
}(); | ||
|
||
/** Helper function to create a GUI element from a surface object inside a robot | ||
* | ||
* Multiple elements can be added based on the surface type (e.g. for a planar surface, the polygon and the normal are | ||
* added) so this function returns the names of the elements that were added | ||
* | ||
* \param gui State builder where the object is added (typically controller.gui() | ||
* | ||
* \param category Category where the object is added | ||
* | ||
* \param cfg Configuration for the surface polygon | ||
* | ||
* \param robot Robot that the surfaces belongs to, this reference is captured by the GUI and should survive | ||
* | ||
* \param name Name of the surface added to the GUI, the object should remain in the robot while it is in the | ||
* GUI | ||
* | ||
* \param publishName Name of the object in the GUI, defaults to \param name | ||
* | ||
* \returns The names of the elements added by the function | ||
*/ | ||
MC_RBDYN_DLLAPI std::vector<std::string> addSurfaceToGUI(mc_rtc::gui::StateBuilder & gui, | ||
const std::vector<std::string> & category, | ||
const mc_rbdyn::Robot & robot, | ||
const std::string & name, | ||
const mc_rtc::gui::LineConfig & cfg = defaultSurfaceConfig, | ||
const std::optional<std::string> & publishName = std::nullopt); | ||
|
||
} // namespace mc_rbdyn::gui |
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2015-2024 CNRS-UM LIRMM, CNRS-AIST JRL | ||
*/ | ||
|
||
#pragma once | ||
|
||
/** This header defines a number of utility functions related to forming path in the environment | ||
* | ||
* They are thin wrapper around boost::filesystem to be later replaced by std::filesystem after Ubuntu 18.04 support is | ||
* fully dropped | ||
*/ | ||
|
||
#include <mc_rtc/utils_api.h> | ||
|
||
#include <string> | ||
|
||
namespace mc_rtc | ||
{ | ||
|
||
/** Returns the path to the OS temporary directory | ||
* | ||
* \param suffix Added (with a path separator) to the returned path | ||
*/ | ||
MC_RTC_UTILS_DLLAPI std::string temp_directory_path(const std::string & suffix = ""); | ||
|
||
/** Returns the path to the user's config directory | ||
* | ||
* On Linux/macOS this returns ${HOME}/.config/mc_rtc folder | ||
* | ||
* On Windows this returns the %APPDATA%/mc_rtc folder | ||
* | ||
* \param suffix Added (with a path separator) to the returned path | ||
*/ | ||
MC_RTC_UTILS_DLLAPI std::string user_config_directory_path(const std::string & suffix = ""); | ||
|
||
} // namespace mc_rtc |
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
Oops, something went wrong.