Commits

bergsoe committed a15a3f0

New papl_robwork.hpp header file.

The c_papl_robwork library now has a C++ header as well as a C
header. The C++ header is needed Ocaml libraries that extend
the functionality of papl_robwork.

Comments (0)

Files changed (4)

 workcell can be written to a file that can then be loaded and viewed
 with RobWorkStudio.
 
-The `c_robwork` directory contains a C library named `c_papl_robwork`
-that must be built and installed prior to the building of the
-`papl_robwork` Ocaml package.
+The `c_robwork` directory contains a combined C and C++ library named
+`c_papl_robwork` that must be built and installed prior to the
+building of the `papl_robwork` Ocaml package.
 
 [0]: http://www.bergsoe.org/papl
 [1]: http://www.robwork.dk

c_robwork/papl_robwork.cpp

 */
 
 #include "papl_robwork.h"
+#include "papl_robwork.hpp"
 #include <rw/math/Transform3D.hpp>
 #include <rw/math/Rotation3D.hpp>
 #include <rw/math/Vector3D.hpp>
 #include <rw/common/macros.hpp>
 #include <rw/common/Exception.hpp>
-#include <rw/models/WorkCell.hpp>
-#include <rw/models/Device.hpp>
-#include <rw/kinematics/FKTable.hpp>
-#include <rw/kinematics/State.hpp>
 #include <rw/kinematics/Kinematics.hpp>
 #include <rw/math/Q.hpp>
 #include <rw/loaders/WorkCellFactory.hpp>
 #include <rw/loaders/path/PathLoader.hpp>
-#include <rw/proximity/CollisionDetector.hpp>
 #include <rwlibs/proximitystrategies/ProximityStrategyYaobi.hpp>
 #include <sstream>
 #include <algorithm>
 using namespace rwlibs::proximitystrategies;
 
 /*----------------------------------------------------------------------*
-  Data types
- *----------------------------------------------------------------------*/
-
-struct RW_WorkCell
-{
-    WorkCell::Ptr workcell;
-    CollisionDetector::Ptr detector;
-    std::string error;
-
-    RW_WorkCell(
-        const WorkCell::Ptr& workcell,
-        const CollisionDetector::Ptr& detector,
-        const std::string& error)
-        :
-        workcell(workcell),
-        detector(detector),
-        error(error)
-    {}
-};
-
-struct RW_State {
-    State state;
-
-    RW_State(const State& state) : state(state) {}
-};
-
-struct RW_Device {
-    Device::Ptr device;
-
-    RW_Device(const Device::Ptr& device) : device(device) {}
-};
-
-struct RW_Frame {
-    Frame* frame;
-
-    RW_Frame(Frame* frame) : frame(frame) {}
-};
-
-struct RW_FKTable {
-    Ptr<FKTable> table;
-
-    RW_FKTable(Ptr<FKTable> table) : table(table) {}
-};
-
-struct RW_TimedStatePath {
-    TimedStatePath path;
-};
-
-/*----------------------------------------------------------------------*
   Destructors
  *----------------------------------------------------------------------*/
 

c_robwork/papl_robwork.hpp

+/*
+  Copyright (c) 2012 Anders Lau Olsen.
+  See LICENSE file for terms and conditions.
+*/
+#ifndef PAPL_ROBWORK_HPP
+#define PAPL_ROBWORK_HPP
+
+/*
+  The data types of the RobWork interface.
+
+  This C++ header declares all of the structs that the C interface (see
+  papl_robwork.h) is accessing.
+
+  This header file should be installed together with papl_robwork.h so that
+  Ocaml libraries can be written that extend the functionality of papl_robwork.
+ */
+
+#include <rw/models/WorkCell.hpp>
+#include <rw/proximity/CollisionDetector.hpp>
+#include <rw/kinematics/State.hpp>
+#include <rw/kinematics/Frame.hpp>
+#include <rw/kinematics/FKTable.hpp>
+#include <rw/models/Device.hpp>
+#include <rw/trajectory/Path.hpp>
+#include <string>
+
+/*----------------------------------------------------------------------*
+  Data types
+ *----------------------------------------------------------------------*/
+
+struct RW_WorkCell
+{
+    rw::models::WorkCell::Ptr workcell;
+    rw::proximity::CollisionDetector::Ptr detector;
+    std::string error;
+
+    RW_WorkCell(
+        const rw::models::WorkCell::Ptr& workcell,
+        const rw::proximity::CollisionDetector::Ptr& detector,
+        const std::string& error)
+        :
+        workcell(workcell),
+        detector(detector),
+        error(error)
+    {}
+};
+
+struct RW_State {
+    rw::kinematics::State state;
+
+    RW_State(const rw::kinematics::State& state) : state(state) {}
+};
+
+struct RW_Device {
+    rw::models::Device::Ptr device;
+
+    RW_Device(const rw::models::Device::Ptr& device) : device(device) {}
+};
+
+struct RW_Frame {
+    rw::kinematics::Frame* frame;
+
+    RW_Frame(rw::kinematics::Frame* frame) : frame(frame) {}
+};
+
+struct RW_FKTable {
+    rw::common::Ptr<rw::kinematics::FKTable> table;
+
+    RW_FKTable(rw::common::Ptr<rw::kinematics::FKTable> table) :
+        table(table) {}
+};
+
+struct RW_TimedStatePath {
+    rw::trajectory::TimedStatePath path;
+};
+
+#endif // end include guard
 
 #include <papl_robwork.h>
 #include <stdio.h>
+#include <string.h>
 
 /*----------------------------------------------------------------------*
   Value accessors
 
     const char* error_msg = robwork_getWorkCellError(workcell);
     const int len = robwork_getWorkCellErrorSize(workcell);
-
-    int i;
-    for (i = 0; i < len; i++)
-        error[i] = error_msg[i];
-
+    memcpy(error, error_msg, len);
     CAMLreturn(Val_unit);
 }