Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resetSimulationState and regenerate thrift-generated files #424

Merged
merged 3 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugins/clock/include/GazeboYarpPlugins/ClockServerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class GazeboYarpPlugins::ClockServerImpl : public GazeboYarpPlugins::ClockServer
virtual void resetSimulation();
virtual double getSimulationTime();
virtual double getStepSize();
virtual void resetSimulationState();

private:

Expand Down
5 changes: 5 additions & 0 deletions plugins/clock/include/gazebo/Clock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public:
*/
void resetSimulationTime();

/**
* Reset the simulation state back to initial state
*/
void resetSimulationState();

/**
* Reset the simulation time and state back to zero
*/
Expand Down
8 changes: 7 additions & 1 deletion plugins/clock/src/Clock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <gazebo/common/Events.hh>
#include <gazebo/physics/PhysicsEngine.hh>
#include <gazebo/physics/World.hh>
#include <gazebo/physics/physics.hh>
#include <gazebo/physics/PhysicsIface.hh>
#include <yarp/os/Network.h>
#include <yarp/os/Property.h>
Expand All @@ -30,7 +31,6 @@ namespace gazebo
, m_rpcPort(0)
, m_clockServer(0)
{

}

GazeboYarpClock::~GazeboYarpClock()
Expand Down Expand Up @@ -182,6 +182,12 @@ namespace gazebo
m_world->Reset();
}

void GazeboYarpClock::resetSimulationState()
{
m_world->ResetEntities(gazebo::physics::Base::BASE);
event::Events::worldReset();
}

common::Time GazeboYarpClock::getSimulationTime()
{
#if GAZEBO_MAJOR_VERSION >= 8
Expand Down
5 changes: 5 additions & 0 deletions plugins/clock/src/ClockServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ namespace GazeboYarpPlugins {
{
return m_clock.getStepSize();
}

void ClockServerImpl::resetSimulationState()
{
m_clock.resetSimulationState();
}
}
2 changes: 1 addition & 1 deletion thrift/clock/autogenerated/clock_rpc_thrift.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
# Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
# All rights reserved.
#
# This software may be modified and distributed under the terms of the
Expand Down
125 changes: 73 additions & 52 deletions thrift/clock/autogenerated/include/ClockServer.h
Original file line number Diff line number Diff line change
@@ -1,71 +1,92 @@
/*
* Copyright (C) 2006-2018 Istituto Italiano di Tecnologia (IIT)
* Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
* All rights reserved.
*
* This software may be modified and distributed under the terms of the
* BSD-3-Clause license. See the accompanying LICENSE file for details.
*/

// Autogenerated by Thrift Compiler (0.12.0-yarped)
//
// This is an automatically generated file.
// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.

#ifndef YARP_THRIFT_GENERATOR_ClockServer
#define YARP_THRIFT_GENERATOR_ClockServer
#ifndef YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H
#define YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H

#include <yarp/os/Wire.h>
#include <yarp/os/idl/WireTypes.h>

namespace GazeboYarpPlugins {
class ClockServer;
}


class GazeboYarpPlugins::ClockServer : public yarp::os::Wire {
class ClockServer :
public yarp::os::Wire
{
public:
ClockServer();
/**
* Pause the simulation if it was running
*/
virtual void pauseSimulation();
/**
* Resume the simulation if it was paused
*/
virtual void continueSimulation();
/**
* Steps the simulation for the provided number of steps.
* The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed)
* @note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function
* twice before the previous call actually ends its computation gives and undefined behavior.
* @param numberOfSteps number of steps to simulate
*/
virtual void stepSimulation(const std::int32_t numberOfSteps = 1);
/**
* Steps the simulation for the provided number of steps.
* The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed)
* @note: this function is blocking
* @param numberOfSteps number of steps to simulate
*/
virtual void stepSimulationAndWait(const std::int32_t numberOfSteps = 1);
/**
* Reset the simulation time back to zero
*/
virtual void resetSimulationTime();
/**
* Get the current simulation time
* @return the simulation time.
*/
virtual double getSimulationTime();
/**
* Get the current step size in seconds.
* @return the step size in seconds
*/
virtual double getStepSize();
/**
* Reset the simulation state and time
*/
virtual void resetSimulation();
virtual bool read(yarp::os::ConnectionReader& connection) override;
virtual std::vector<std::string> help(const std::string& functionName="--all");
// Constructor
ClockServer();

/**
* Pause the simulation if it was running
*/
virtual void pauseSimulation();

/**
* Resume the simulation if it was paused
*/
virtual void continueSimulation();

/**
* Steps the simulation for the provided number of steps.
* The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed)
* @note: this function (will be) not blocking, i.e. it will return immediately. Currently calling this function
* twice before the previous call actually ends its computation gives and undefined behavior.
* @param numberOfSteps number of steps to simulate
*/
virtual void stepSimulation(const std::int32_t numberOfSteps = 1);

/**
* Steps the simulation for the provided number of steps.
* The input paramter is the number of steps, not the time (Usually 1 step = 1ms but this is not guaranteed)
* @note: this function is blocking
* @param numberOfSteps number of steps to simulate
*/
virtual void stepSimulationAndWait(const std::int32_t numberOfSteps = 1);

/**
* Reset the simulation time back to zero
*/
virtual void resetSimulationTime();

/**
* Get the current simulation time
* @return the simulation time.
*/
virtual double getSimulationTime();

/**
* Get the current step size in seconds.
* @return the step size in seconds
*/
virtual double getStepSize();

/**
* Reset the simulation state and time
*/
virtual void resetSimulation();

/**
* Reset the simulation state back to initial pose
*/
virtual void resetSimulationState();

// help method
virtual std::vector<std::string> help(const std::string& functionName = "--all");

// read from ConnectionReader
bool read(yarp::os::ConnectionReader& connection) override;
};

#endif
} // namespace GazeboYarpPlugins

#endif // YARP_THRIFT_GENERATOR_SERVICE_CLOCKSERVER_H
Loading