Skip to content

Commit

Permalink
Merge pull request #511 from jhwangbo/master
Browse files Browse the repository at this point in the history
added needsSensorUpdate
  • Loading branch information
jhwangbo authored Sep 23, 2023
2 parents 596ad7e + bcf3867 commit 9f1be94
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
12 changes: 6 additions & 6 deletions examples/src/server/synchronousServerUpdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ int main(int argc, char **argv) {
server.acceptConnection(2000.0);

for (int k = 0; k < loopN; k++) {
// RS_TIMED_LOOP(int(world.getTimeStep()*1e7))
// for (int i = 0; i < 10; i++)
server.applyInteractionForce();
world.integrate();

if (server.waitForMessageFromClient(1.0)) {
if (!server.processRequests()) {
server.acceptConnection(2000.0);
if (server.needsSensorUpdate()) {
if (server.waitForMessageFromClient(1.0)) {
if (!server.processRequests()) {
server.acceptConnection(2000.0);
}
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions raisim/linux/include/raisim/RaisimServer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,27 @@ class RaisimServer final {
#endif
}

/**
* Check if there is any sensor that has to be updated from the visualizer
* @return if any of the sensors needs an update
*/
inline bool needsSensorUpdate() {
auto &objList = world_->getObjList();
for (auto *ob: objList) {
if (ob->getObjectType() == ObjectType::ARTICULATED_SYSTEM) {
auto as = dynamic_cast<ArticulatedSystem *>(ob);
for (auto &sensor: as->getSensors()) {
if (sensor.second->getMeasurementSource() == Sensor::MeasurementSource::VISUALIZER &&
sensor.second->getUpdateTimeStamp() + 1. / sensor.second->getUpdateRate()
< world_->getWorldTime() + 1e-10) {
return true;
}
}
}
}
return false;
}

/**
* Synchronous update method.
* Receive a request from the client, process it and return the requested data to the client.
Expand Down
Binary file modified raisim/linux/lib/raisimpy.cpython-310-x86_64-linux-gnu.so
Binary file not shown.
Binary file modified raisim/linux/lib/raisimpy.cpython-311-x86_64-linux-gnu.so
Binary file not shown.
Binary file modified raisim/linux/lib/raisimpy.cpython-37m-x86_64-linux-gnu.so
Binary file not shown.
Binary file modified raisim/linux/lib/raisimpy.cpython-38-x86_64-linux-gnu.so
Binary file not shown.
Binary file modified raisim/linux/lib/raisimpy.cpython-39-x86_64-linux-gnu.so
Binary file not shown.

0 comments on commit 9f1be94

Please sign in to comment.