Skip to content

Commit 596ad7e

Browse files
authored
Merge pull request #510 from jhwangbo/master
fix sensor update time, getGeneralizedVelocityIndex
2 parents ad4c60f + 407205e commit 596ad7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+41
-10
lines changed

raisim/linux/include/raisim/RaisimServer.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ class RaisimServer final {
11861186
< world_->getWorldTime() + 1e-10) {
11871187
data_ = set(data_, true);
11881188
needsSensorUpdate_ = true;
1189+
sensorUpdateTime_ = world_->getWorldTime();
11891190
} else {
11901191
data_ = set(data_, false);
11911192
}
@@ -1691,14 +1692,14 @@ class RaisimServer final {
16911692
auto &img = std::static_pointer_cast<RGBCamera>(sensor)->getImageBuffer();
16921693
RSFATAL_IF(width * height * 4 != img.size(), "Image size mismatch. Sensor module not working properly")
16931694
rData_ = getN(rData_, img.data(), width * height * 4);
1694-
sensor->setUpdateTimeStamp(world_->getWorldTime());
1695+
sensor->setUpdateTimeStamp(sensorUpdateTime_);
16951696
} else if (type == Sensor::Type::DEPTH) {
16961697
int width, height;
16971698
rData_ = get(rData_, &width, &height);
16981699
auto &depthArray = std::static_pointer_cast<DepthCamera>(sensor)->getDepthArray();
16991700
RSFATAL_IF(width * height != depthArray.size(), "Image size mismatch. Sensor module not working properly")
17001701
rData_ = getN(rData_, depthArray.data(), width * height);
1701-
sensor->setUpdateTimeStamp(world_->getWorldTime());
1702+
sensor->setUpdateTimeStamp(sensorUpdateTime_);
17021703
}
17031704
}
17041705

@@ -1707,6 +1708,7 @@ class RaisimServer final {
17071708

17081709
char *data_, *rData_;
17091710
bool needsSensorUpdate_ = false;
1711+
double sensorUpdateTime_;
17101712
World *world_;
17111713
std::vector<char> receive_buffer, send_buffer;
17121714
bool connected_ = false;

raisim/linux/include/raisim/object/ArticulatedSystem/ArticulatedSystem.hpp

+13-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <cmath>
1616
#include <unordered_map>
1717
#include <fstream>
18+
#include <map>
1819
#include "raisim/math.hpp"
1920
#include "algorithm"
2021

@@ -560,6 +561,14 @@ class ArticulatedSystem : public Object {
560561
* @return movable joint names in the joint order. */
561562
[[nodiscard]] const std::vector<std::string> &getMovableJointNames() const { return movableJointNames; };
562563

564+
/**
565+
* get generalized velocity index of a joint.
566+
* @return the joint index. */
567+
[[nodiscard]] size_t getGeneralizedVelocityIndex(const std::string& name) const {
568+
RSFATAL_IF(jointName2GvIdx.find(name) == jointName2GvIdx.end(), name + " not found")
569+
return jointName2GvIdx.at(name);
570+
};
571+
563572
/**
564573
* @param[in] bodyIdx The body which contains the point, can be retrieved by getBodyIdx()
565574
* @param[in] point_B The position of the point in the body frame
@@ -1573,23 +1582,23 @@ class ArticulatedSystem : public Object {
15731582
*
15741583
* @return return if the inverse dynamics is computed
15751584
*/
1576-
bool getComputeInverseDynamics() const { return computeInverseDynamics_; }
1585+
[[nodiscard]] bool getComputeInverseDynamics() const { return computeInverseDynamics_; }
15771586

15781587
/**
15791588
* YOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method.
15801589
* This method returns the force at the specified joint
15811590
* @param jointId[in] the joint id
15821591
* @return force at the joint
15831592
*/
1584-
const raisim::Vec<3>& getForceAtJointInWorldFrame(size_t jointId) const { return forceAtJoint_W[jointId]; }
1593+
[[nodiscard]] const raisim::Vec<3>& getForceAtJointInWorldFrame(size_t jointId) const { return forceAtJoint_W[jointId]; }
15851594

15861595
/**
15871596
* YOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method.
15881597
* This method returns the torque at the specified joint
15891598
* @param jointId[in] the joint id
15901599
* @return torque at the joint
15911600
*/
1592-
const raisim::Vec<3>& getTorqueAtJointInWorldFrame(size_t jointId) const { return torqueAtJoint_W[jointId]; }
1601+
[[nodiscard]] const raisim::Vec<3>& getTorqueAtJointInWorldFrame(size_t jointId) const { return torqueAtJoint_W[jointId]; }
15931602

15941603
protected:
15951604

@@ -1746,6 +1755,7 @@ class ArticulatedSystem : public Object {
17461755
std::vector<Child> rootChild_;
17471756
std::vector<std::string> bodyName;
17481757
std::vector<std::string> movableJointNames;
1758+
std::map<std::string, size_t> jointName2GvIdx;
17491759

17501760
std::vector<SparseJacobian> contactJaco_;
17511761
std::vector<SparseJacobian> externalForceAndTorqueJaco_;

raisim/linux/lib/libraisim.so.1.1.7

6.16 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/aliengo.exe

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/anymals.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/atlas.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/balls.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/cartPole.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/compound.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/deletion.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/dynamicHeightMap.exe

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/go1.exe

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/heightmap.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/hill1.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/inverseDynamics.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/kinematicObject.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/kinova.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/laikago.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/lake1.exe

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/materials.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/meshes.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/mjcf_ant.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/mjcf_cassie.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/mjcf_humanoid.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/mountain1.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/newtonsCradle.exe

512 Bytes
Binary file not shown.

raisim/win32/bin/office1.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/primitives.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/raisim.dll

4.5 KB
Binary file not shown.

raisim/win32/bin/raisim.mexw64

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimMine.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimMined.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimODE.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimODEd.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimPng.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimPngd.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimZ.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimZd.dll

0 Bytes
Binary file not shown.

raisim/win32/bin/raisimd.dll

44 KB
Binary file not shown.
512 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
512 Bytes
Binary file not shown.

raisim/win32/bin/rayDemo.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/rayDemo2.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/sensors.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/speed_test.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/springTest.exe

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

raisim/win32/bin/templatedXml.exe

0 Bytes
Binary file not shown.
Binary file not shown.

raisim/win32/bin/visualObjects.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/wheeledRobot.exe

0 Bytes
Binary file not shown.

raisim/win32/bin/xmlRader.exe

0 Bytes
Binary file not shown.

raisim/win32/include/raisim/RaisimServer.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ class RaisimServer final {
11861186
< world_->getWorldTime() + 1e-10) {
11871187
data_ = set(data_, true);
11881188
needsSensorUpdate_ = true;
1189+
sensorUpdateTime_ = world_->getWorldTime();
11891190
} else {
11901191
data_ = set(data_, false);
11911192
}
@@ -1691,14 +1692,14 @@ class RaisimServer final {
16911692
auto &img = std::static_pointer_cast<RGBCamera>(sensor)->getImageBuffer();
16921693
RSFATAL_IF(width * height * 4 != img.size(), "Image size mismatch. Sensor module not working properly")
16931694
rData_ = getN(rData_, img.data(), width * height * 4);
1694-
sensor->setUpdateTimeStamp(world_->getWorldTime());
1695+
sensor->setUpdateTimeStamp(sensorUpdateTime_);
16951696
} else if (type == Sensor::Type::DEPTH) {
16961697
int width, height;
16971698
rData_ = get(rData_, &width, &height);
16981699
auto &depthArray = std::static_pointer_cast<DepthCamera>(sensor)->getDepthArray();
16991700
RSFATAL_IF(width * height != depthArray.size(), "Image size mismatch. Sensor module not working properly")
17001701
rData_ = getN(rData_, depthArray.data(), width * height);
1701-
sensor->setUpdateTimeStamp(world_->getWorldTime());
1702+
sensor->setUpdateTimeStamp(sensorUpdateTime_);
17021703
}
17031704
}
17041705

@@ -1707,6 +1708,7 @@ class RaisimServer final {
17071708

17081709
char *data_, *rData_;
17091710
bool needsSensorUpdate_ = false;
1711+
double sensorUpdateTime_;
17101712
World *world_;
17111713
std::vector<char> receive_buffer, send_buffer;
17121714
bool connected_ = false;

raisim/win32/include/raisim/object/ArticulatedSystem/ArticulatedSystem.hpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <cmath>
1616
#include <unordered_map>
1717
#include <fstream>
18+
#include <map>
1819
#include "raisim/math.hpp"
1920
#include "algorithm"
2021

@@ -560,6 +561,14 @@ class ArticulatedSystem : public Object {
560561
* @return movable joint names in the joint order. */
561562
[[nodiscard]] const std::vector<std::string> &getMovableJointNames() const { return movableJointNames; };
562563

564+
/**
565+
* get generalized velocity index of a joint.
566+
* @return the joint index. */
567+
[[nodiscard]] size_t getGeneralizedVelocityIndex(const std::string& name) const {
568+
RSFATAL_IF(jointName2GvIdx.find(name) == jointName2GvIdx.end(), name + " not found")
569+
return jointName2GvIdx.at(name);
570+
};
571+
563572
/**
564573
* @param[in] bodyIdx The body which contains the point, can be retrieved by getBodyIdx()
565574
* @param[in] point_B The position of the point in the body frame
@@ -1504,6 +1513,13 @@ class ArticulatedSystem : public Object {
15041513
return jointLimits_;
15051514
}
15061515

1516+
/**
1517+
* get the joint velocity limits
1518+
* @return jointLimits joint velocity limits*/
1519+
const VecDyn& getJointVelocityLimits() {
1520+
return velLimits_;
1521+
}
1522+
15071523
/**
15081524
* Clears all external forces and torques */
15091525
void clearExternalForcesAndTorques() final {
@@ -1566,23 +1582,23 @@ class ArticulatedSystem : public Object {
15661582
*
15671583
* @return return if the inverse dynamics is computed
15681584
*/
1569-
bool getComputeInverseDynamics() const { return computeInverseDynamics_; }
1585+
[[nodiscard]] bool getComputeInverseDynamics() const { return computeInverseDynamics_; }
15701586

15711587
/**
15721588
* YOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method.
15731589
* This method returns the force at the specified joint
15741590
* @param jointId[in] the joint id
15751591
* @return force at the joint
15761592
*/
1577-
const raisim::Vec<3>& getForceAtJointInWorldFrame(size_t jointId) const { return forceAtJoint_W[jointId]; }
1593+
[[nodiscard]] const raisim::Vec<3>& getForceAtJointInWorldFrame(size_t jointId) const { return forceAtJoint_W[jointId]; }
15781594

15791595
/**
15801596
* YOU MUST CALL raisim::ArticulatedSystem::setComputeInverseDynamics(true) before calling this method.
15811597
* This method returns the torque at the specified joint
15821598
* @param jointId[in] the joint id
15831599
* @return torque at the joint
15841600
*/
1585-
const raisim::Vec<3>& getTorqueAtJointInWorldFrame(size_t jointId) const { return torqueAtJoint_W[jointId]; }
1601+
[[nodiscard]] const raisim::Vec<3>& getTorqueAtJointInWorldFrame(size_t jointId) const { return torqueAtJoint_W[jointId]; }
15861602

15871603
protected:
15881604

@@ -1739,6 +1755,7 @@ class ArticulatedSystem : public Object {
17391755
std::vector<Child> rootChild_;
17401756
std::vector<std::string> bodyName;
17411757
std::vector<std::string> movableJointNames;
1758+
std::map<std::string, size_t> jointName2GvIdx;
17421759

17431760
std::vector<SparseJacobian> contactJaco_;
17441761
std::vector<SparseJacobian> externalForceAndTorqueJaco_;

raisim/win32/lib/raisim.lib

13.1 KB
Binary file not shown.

raisim/win32/lib/raisimd.lib

130 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)