forked from qiayuanl/legged_control
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LeggedSelfCollisionVisualization
- Loading branch information
Showing
8 changed files
with
61 additions
and
12 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
39 changes: 39 additions & 0 deletions
39
...d_controllers/include/legged_controllers/visualization/LeggedSelfCollisionVisualization.h
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,39 @@ | ||
// | ||
// Created by qiayuan on 23-1-30. | ||
// | ||
|
||
#pragma once | ||
#include <ros/ros.h> | ||
|
||
#include <ocs2_self_collision_visualization/GeometryInterfaceVisualization.h> | ||
|
||
#include <utility> | ||
|
||
namespace legged { | ||
|
||
using namespace ocs2; | ||
|
||
class LeggedSelfCollisionVisualization : public GeometryInterfaceVisualization { | ||
public: | ||
LeggedSelfCollisionVisualization(PinocchioInterface pinocchioInterface, PinocchioGeometryInterface geometryInterface, | ||
const CentroidalModelPinocchioMapping& mapping, ros::NodeHandle& nh, scalar_t maxUpdateFrequency = 50.0) | ||
: mappingPtr_(mapping.clone()), | ||
GeometryInterfaceVisualization(std::move(pinocchioInterface), std::move(geometryInterface), nh, "odom"), | ||
lastTime_(std::numeric_limits<scalar_t>::lowest()), | ||
minPublishTimeDifference_(1.0 / maxUpdateFrequency) {} | ||
void update(const SystemObservation& observation) { | ||
if (observation.time - lastTime_ > minPublishTimeDifference_) { | ||
lastTime_ = observation.time; | ||
|
||
publishDistances(mappingPtr_->getPinocchioJointPosition(observation.state)); | ||
} | ||
} | ||
|
||
private: | ||
std::unique_ptr<CentroidalModelPinocchioMapping> mappingPtr_; | ||
|
||
scalar_t lastTime_; | ||
scalar_t minPublishTimeDifference_; | ||
}; | ||
|
||
} // namespace legged |
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
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