-
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.
[ControllerClient] Set the robot as previously defined
[ControllerClient] Add a new gui type to handle more complex robot data [ControllerClient] change the RobotMsg type to use Eigen Vectors instead
- Loading branch information
Showing
5 changed files
with
93 additions
and
16 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
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,65 @@ | ||
/* | ||
* Copyright 2015-2020 CNRS-UM LIRMM, CNRS-AIST JRL | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <mc_rtc/gui/details/traits.h> | ||
#include <mc_rtc/gui/elements.h> | ||
#include <mc_rtc/gui/types.h> | ||
|
||
#include <mc_rbdyn/Robot.h> | ||
|
||
namespace mc_rtc::gui | ||
{ | ||
|
||
namespace details | ||
{ | ||
|
||
/** Robot should display a robot model in the environment | ||
* | ||
* The element provides the following data to the client: | ||
* - the parameters passed to RobotLoader to get the RobotModule (vector<string>) | ||
* - the current robot configuration (vector<vector<double>>) | ||
* | ||
* \tparam GetT Should return an mc_rbdyn::Robot | ||
*/ | ||
template<typename GetT> | ||
struct RobotMsgImpl : public Element | ||
{ | ||
static constexpr auto type = Elements::RobotMsg; | ||
|
||
RobotMsgImpl(const std::string & name, GetT get_fn) : Element(name), get_fn_(get_fn) | ||
{ | ||
static_assert(CheckReturnType<GetT, mc_rbdyn::Robot>::value, "Robot element must return an mc_rbdyn::Robot"); | ||
} | ||
|
||
static constexpr size_t write_size() { return Element::write_size() + 7; } | ||
|
||
void write(mc_rtc::MessagePackBuilder & builder) | ||
{ | ||
const mc_rbdyn::Robot & robot = get_fn_(); | ||
Element::write(builder); | ||
builder.write(robot.module().parameters()); | ||
builder.write(rbd::paramToVector(robot.mb(),robot.mbc().q)); | ||
builder.write(rbd::paramToVector(robot.mb(),robot.mbc().alpha)); | ||
builder.write(rbd::paramToVector(robot.mb(),robot.mbc().alphaD)); | ||
builder.write(rbd::paramToVector(robot.mb(),robot.mbc().jointTorque)); | ||
builder.write(robot.mbc().force); | ||
builder.write(robot.posW()); | ||
} | ||
|
||
private: | ||
GetT get_fn_; | ||
}; | ||
|
||
} // namespace details | ||
|
||
/** Helper function to create a RobotImpl */ | ||
template<typename GetT> | ||
auto RobotMsg(const std::string & name, GetT get_fn) | ||
{ | ||
return details::RobotMsgImpl(name, get_fn); | ||
} | ||
|
||
} // namespace mc_rtc::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
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