Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ostasse/dynamic-graph-python
  • gsaurel/dynamic-graph-python
  • stack-of-tasks/dynamic-graph-python
3 results
Show changes
Showing
with 530 additions and 1293 deletions
This diff is collapsed.
/*
* Copyright 2010,
* François Bleibel,
* Olivier Stasse,
*
* CNRS/AIST
*
* This file is part of dynamic-graph.
* dynamic-graph is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* dynamic-graph is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dynamic-graph/python/exception-python.hh>
#include <dynamic-graph/debug.h>
#include <stdarg.h>
#include <cstdio>
namespace dynamicgraph {
namespace python {
/* --------------------------------------------------------------------- */
/* --- CLASS ----------------------------------------------------------- */
/* --------------------------------------------------------------------- */
const std::string ExceptionPython::EXCEPTION_NAME = "Python";
ExceptionPython::
ExceptionPython ( const ExceptionPython::ErrorCodeEnum& errcode,
const std::string & msg )
:ExceptionAbstract(errcode,msg)
{
dgDEBUGF( 15,"Created with message <%s>.",msg.c_str ());
dgDEBUG( 1) <<"Created with message <%s>."<<msg<<std::endl;
}
ExceptionPython::
ExceptionPython ( const ExceptionPython::ErrorCodeEnum& errcode,
const std::string & msg,const char* format, ... )
:ExceptionAbstract(errcode,msg)
{
va_list args;
va_start(args,format);
const unsigned int SIZE = 256;
char buffer[SIZE];
vsnprintf(buffer,SIZE,format,args);
dgDEBUG(15) <<"Created "<<" with message <"
<<msg<<"> and buffer <"<<buffer<<">. "<<std::endl;
message += buffer;
va_end(args);
dgDEBUG(1) << "Throw exception " << EXCEPTION_NAME << "[#" << errcode<<"]: "
<<"<"<< message << ">."<<std::endl;
}
} // namespace dynamicgraph
} // namespace python
/*
* Local variables:
* c-basic-offset: 2
* End:
*/
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
//
// This file is part of dynamic-graph-python.
// dynamic-graph-python is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// dynamic-graph-python is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Lesser Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifndef DYNAMIC_GRAPH_PYTHON_EXCEPTION
# define DYNAMIC_GRAPH_PYTHON_EXCEPTION
/// \brief Catch all exceptions which may be sent when C++ code is
/// called.
# define CATCH_ALL_EXCEPTIONS() \
catch (const std::exception& exc) \
{ \
PyErr_SetString(dgpyError, exc.what()); \
return NULL; \
} \
catch (const char* s) \
{ \
PyErr_SetString(dgpyError, s); \
return NULL; \
} catch (...) { \
PyErr_SetString(dgpyError, "Unknown exception"); \
return NULL; \
} struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
#endif //! DYNAMIC_GRAPH_PYTHON_EXCEPTION
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
//
// This file is part of dynamic-graph-python.
// dynamic-graph-python is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// dynamic-graph-python is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Lesser Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include <Python.h>
#include <iostream>
#include <dynamic-graph/factory.h>
using dynamicgraph::Entity;
using dynamicgraph::ExceptionAbstract;
namespace dynamicgraph {
namespace python {
namespace factory {
/**
\brief Get name of entity
*/
PyObject* getEntityClassList(PyObject* /*self*/, PyObject* args)
{
if (!PyArg_ParseTuple(args, ""))
return NULL;
std::vector <std::string> classNames;
dynamicgraph::FactoryStorage::getInstance()
->listEntities(classNames);
Py_ssize_t classNumber = classNames.size();
// Build a tuple object
PyObject* classTuple = PyTuple_New(classNumber);
for (Py_ssize_t iEntity = 0;
iEntity < (Py_ssize_t)classNames.size(); ++iEntity)
{
PyObject* className =
Py_BuildValue("s", classNames[iEntity].c_str());
PyTuple_SetItem(classTuple, iEntity, className);
}
return Py_BuildValue("O", classTuple);
}
} // namespace factory
} // namespace python
} // namespace dynamicgraph
This diff is collapsed.
// -*- mode: c++ -*-
// Copyright 2011, Florent Lamiraux, CNRS.
//
// This file is part of dynamic-graph-python.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#ifdef WIN32
#include <Windows.h>
#else
#include <dlfcn.h>
#endif
namespace dynamicgraph {
namespace python {
std::string libpython("@PYTHON_LIBRARY@");
} // namespace python
} // namespace dynamicgraph
// Copyright 2011, 2012, Florent Lamiraux, LAAS-CNRS.
//
// This file is part of dynamic-graph-python.
// dynamic-graph-python is free software: you can redistribute it
// and/or modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation, either
// version 3 of the License, or (at your option) any later version.
//
// dynamic-graph-python is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Lesser Public License for more details. You should
// have received a copy of the GNU Lesser General Public License along
// with dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
#include <Python.h>
#include <dynamic-graph/pool.h>
#include "exception.hh"
namespace dynamicgraph {
namespace python {
extern PyObject* dgpyError;
namespace pool {
PyObject* writeGraph (PyObject* /*self*/, PyObject* args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
return NULL;
try {
PoolStorage::getInstance()->writeGraph (filename);
} CATCH_ALL_EXCEPTIONS();
return Py_BuildValue ("");
}
} // python
} // dynamicgraph
} // namespace pool
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* Copyright 2020 LAAS, CNRS
* Joseph Mirabel
*
*/
#define ENABLE_RT_LOG
#include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-ptr.h>
#include <dynamic-graph/signal-time-dependent.h>
#include <sstream>
namespace dynamicgraph {
class CustomEntity : public Entity {
public:
dynamicgraph::SignalPtr<double, int> m_sigdSIN;
dynamicgraph::SignalTimeDependent<double, int> m_sigdTimeDepSOUT;
DYNAMIC_GRAPH_ENTITY_DECL();
CustomEntity(const std::string n);
void addSignal();
void rmValidSignal();
double &update(double &res, const int &inTime);
void act();
};
} // namespace dynamicgraph
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.