Skip to content

Commit 71c6337

Browse files
committed
renaming & fixes
1 parent 9036e21 commit 71c6337

17 files changed

+85
-53
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ CMakeFiles
3333
cmake_install.cmake
3434
build
3535

36-
# generated by v_repStubsGen:
36+
# generated by simStubsGen:
3737
generated
3838

3939
# other:

CMakeLists.txt

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.5)
2-
project(vrep_ros_interface)
2+
project(sim_ros2_interface)
33

44
if(NOT CMAKE_CXX_STANDARD)
55
set(CMAKE_CXX_STANDARD 14)
@@ -31,7 +31,7 @@ set(CMAKE_MODULE_PATH
3131
${CMAKE_MODULE_PATH}
3232
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
3333
${CMAKE_CURRENT_SOURCE_DIR}/cmake/CoppeliaRobotics-modules)
34-
find_package(VREP 3.6.1.2 REQUIRED)
34+
find_package(CoppeliaSim 3.6.1.2 REQUIRED)
3535

3636
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
3737
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc)
@@ -54,34 +54,34 @@ include_directories(${tf2_msgs_INCLUDE_DIRS})
5454
include_directories(${tf2_sensor_msgs_INCLUDE_DIRS})
5555
include_directories(${trajectory_msgs_INCLUDE_DIRS})
5656
include_directories(${visualization_msgs_INCLUDE_DIRS})
57-
include_directories(${VREP_INCLUDE})
58-
include_directories(${VREP_COMMON})
57+
include_directories(${COPPELIASIM_INCLUDE_DIR})
58+
include_directories(${COPPELIASIM_COMMON_DIR})
5959

6060
set(ROS_MSG_SRV_CACHE "${CMAKE_CURRENT_BINARY_DIR}/ros-msg-srv-defs.pickle")
6161
add_custom_command(OUTPUT "${ROS_MSG_SRV_CACHE}" COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/tools/parse_messages_and_services.py" "${CMAKE_CURRENT_SOURCE_DIR}/meta/messages.txt" "${CMAKE_CURRENT_SOURCE_DIR}/meta/services.txt" "${ROS_MSG_SRV_CACHE}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/meta/messages.txt" "${CMAKE_CURRENT_SOURCE_DIR}/meta/services.txt" "${CMAKE_CURRENT_SOURCE_DIR}/tools/parse_messages_and_services.py")
6262

6363
set(generatedFiles)
6464
file(GLOB templateFiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/templates/ ${CMAKE_CURRENT_SOURCE_DIR}/templates/*)
6565
foreach(templateFile ${templateFiles})
66-
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}" COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/external/v_repStubsGen/external/pycpp/pycpp.py" -p "cache_file=${ROS_MSG_SRV_CACHE}" -i "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}" -o "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}" -P "${CMAKE_CURRENT_SOURCE_DIR}/tools" DEPENDS "${ROS_MSG_SRV_CACHE}" "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}")
66+
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}" COMMAND python "${CMAKE_CURRENT_SOURCE_DIR}/external/simStubsGen/external/pycpp/pycpp.py" -p "cache_file=${ROS_MSG_SRV_CACHE}" -i "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}" -o "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}" -P "${CMAKE_CURRENT_SOURCE_DIR}/tools" DEPENDS "${ROS_MSG_SRV_CACHE}" "${CMAKE_CURRENT_SOURCE_DIR}/templates/${templateFile}")
6767
set(generatedFiles ${generatedFiles} "${CMAKE_CURRENT_BINARY_DIR}/generated/${templateFile}")
6868
endforeach()
6969
add_custom_target(generate_ros_code DEPENDS ${generatedFiles})
70-
vrep_generate_stubs(${CMAKE_CURRENT_BINARY_DIR}/generated XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/meta/callbacks.xml LUA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/simExtROS2Interface.lua)
70+
coppeliasim_generate_stubs(${CMAKE_CURRENT_BINARY_DIR}/generated XML_FILE ${CMAKE_CURRENT_SOURCE_DIR}/meta/callbacks.xml LUA_FILE ${CMAKE_CURRENT_SOURCE_DIR}/simExtROS2Interface.lua)
7171

7272
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h)
7373

7474
set(SOURCES
75-
src/vrep_ros_interface.cpp
76-
${CMAKE_CURRENT_SOURCE_DIR}/external/v_repPlusPlus/Plugin.cpp
75+
src/sim_ros2_interface.cpp
76+
${CMAKE_CURRENT_SOURCE_DIR}/external/simPlusPlus/Plugin.cpp
7777
${CMAKE_CURRENT_BINARY_DIR}/generated/stubs.cpp
7878
src/ros_msg_builtin_io.cpp
79-
${VREP_EXPORTED_SOURCES}
79+
${COPPELIASIM_EXPORTED_SOURCES}
8080
${CMAKE_CURRENT_BINARY_DIR}/generated/callbacks.cpp
8181
)
8282
add_library(simExtROS2Interface SHARED ${SOURCES})
8383
add_dependencies(simExtROS2Interface generate_ros_code)
84-
target_link_libraries(simExtROS2Interface ${VREP_LIBRARIES})
84+
target_link_libraries(simExtROS2Interface ${COPPELIASIM_LIBRARIES})
8585
ament_target_dependencies(simExtROS2Interface rclcpp)
8686
ament_target_dependencies(simExtROS2Interface actionlib_msgs)
8787
ament_target_dependencies(simExtROS2Interface diagnostic_msgs)
@@ -98,12 +98,12 @@ ament_target_dependencies(simExtROS2Interface tf2_sensor_msgs)
9898
ament_target_dependencies(simExtROS2Interface trajectory_msgs)
9999
ament_target_dependencies(simExtROS2Interface visualization_msgs)
100100

101-
## This will produce the library directly in vrep root folder. The default folder
101+
## This will produce the library directly in CoppeliaSim root folder. The default folder
102102
## for the libsimExtROS2Interface.so file will not be devel/lib anymore.
103-
#set_target_properties(simExtROS2Interface PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${VREP_ROOT})
103+
#set_target_properties(simExtROS2Interface PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${COPPELIASIM_ROOT_DIR})
104104

105-
## install the library to VREP_ROOT folder
106-
## this command will install the generated library to the vrep root folder no matter where the library is generated.
107-
#install(TARGETS simExtROS2Interface DESTINATION ${VREP_ROOT})
105+
## install the library to COPPELIASIM_ROOT_DIR folder
106+
## this command will install the generated library to the CoppeliaSim root folder no matter where the library is generated.
107+
#install(TARGETS simExtROS2Interface DESTINATION ${COPPELIASIM_ROOT_DIR})
108108

109109
ament_package()

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# ROS Interface plugin for V-REP
1+
# ROS2 Interface plugin for CoppeliaSim
22

33
### Compiling
44

5-
_NOTE:_ the directory containing all files (i.e. package.xml etc) must be called vrep_ros_interface, otherwise build will fail.
5+
_NOTE:_ the directory containing all files (i.e. package.xml etc) must be called sim_ros2_interface, otherwise build will fail.
66

7-
1. Install required packages for [v_repStubsGen](https://github.com/CoppeliaRobotics/v_repStubsGen): see v_repStubsGen's [README](external/v_repStubsGen/README.md)
7+
1. Install required packages for [simStubsGen](https://github.com/CoppeliaRobotics/simStubsGen): see simStubsGen's [README](external/simStubsGen/README.md)
88
2. Checkout
99
```
10-
$ git clone --recursive https://github.com/CoppeliaRobotics/simExtRosInterface.git vrep_ros_interface
10+
$ git clone --recursive https://github.com/CoppeliaRobotics/simExtRos2Interface.git sim_ros2_interface
1111
```
1212
3. Edit `meta/messages.txt` and `meta/services.txt` if you need to include more ROS messages/services. You need to specify the full message/service type, i.e. geometry_msgs/Twist rather than Twist.
1313
4. Compile

external/simPlusPlus

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../simPlusPlus

external/simStubsGen

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../simStubsGen

external/v_repPlusPlus

-1
This file was deleted.

external/v_repStubsGen

-1
This file was deleted.

image_transport.ttt

-391 KB
Binary file not shown.

include/ros_msg_builtin_io.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef VREP_ROS_PLUGIN__ROS_MSG_BUILTIN_IO__H
2-
#define VREP_ROS_PLUGIN__ROS_MSG_BUILTIN_IO__H
1+
#ifndef SIM_ROS2_PLUGIN__ROS_MSG_BUILTIN_IO__H
2+
#define SIM_ROS2_PLUGIN__ROS_MSG_BUILTIN_IO__H
33

44
#include <rclcpp/rclcpp.hpp>
55

@@ -44,4 +44,4 @@ void write__string(std::string value, int stack, const WriteOptions *opt = NULL)
4444
void write__time(rclcpp::Time value, int stack, const WriteOptions *opt = NULL);
4545
void write__duration(rclcpp::Duration value, int stack, const WriteOptions *opt = NULL);
4646

47-
#endif // VREP_ROS_PLUGIN__ROS_MSG_BUILTIN_IO__H
47+
#endif // SIM_ROS2_PLUGIN__ROS_MSG_BUILTIN_IO__H

include/vrep_ros_interface.h include/sim_ros2_interface.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef VREP_ROS_INTERFACE_H_INCLUDED
2-
#define VREP_ROS_INTERFACE_H_INCLUDED
1+
#ifndef SIM_ROS2_INTERFACE_H_INCLUDED
2+
#define SIM_ROS2_INTERFACE_H_INCLUDED
33

44
#include <iostream>
55
#include <sstream>
@@ -14,7 +14,7 @@
1414

1515
//#include <image_transport/image_transport.h>
1616

17-
#define PLUGIN_NAME "RosInterface"
17+
#define PLUGIN_NAME "Ros2Interface"
1818
#define PLUGIN_VERSION 5
1919

2020
struct ScriptCallback
@@ -75,4 +75,4 @@ struct ServiceServerProxy : Proxy
7575
#include <stubs.h>
7676
#include <callbacks.h>
7777

78-
#endif // VREP_ROS_INTERFACE_H_INCLUDED
78+
#endif // SIM_ROS2_INTERFACE_H_INCLUDED

install.sh

+40-8
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,55 @@
11
#!/bin/sh
22

3-
if [ "x$VREP_ROOT" = "x" ]; then
4-
echo "error: \$VREP_ROOT is not set" 1>&2
5-
exit 1
3+
set -e
4+
5+
cd "`dirname "$0"`"
6+
7+
PLUGIN_NAME="$(basename "$(pwd)")"
8+
9+
if [ "x$COPPELIASIM_ROOT_DIR" = "x" ]; then
10+
# see if we can determine it automatically
11+
# (i.e. the plugin dir is in $COPPELIASIM_ROOT_DIR/programming/$dir)
12+
COPPELIASIM_ROOT_DIR="$(cd ../.. ; pwd)"
13+
if [ ! -d "$COPPELIASIM_ROOT_DIR/programming/include" ]; then
14+
echo "error: \$COPPELIASIM_ROOT_DIR is not set" 1>&2
15+
exit 1
16+
fi
617
fi
718

819
if [ "`uname`" = "Darwin" ]; then
9-
INSTALL_TARGET="$VREP_ROOT/coppeliaSim.app/Contents/MacOS/"
20+
INSTALL_TARGET="$COPPELIASIM_ROOT_DIR/coppeliaSim.app/Contents/MacOS/"
1021
DLEXT=dylib
1122
else
12-
INSTALL_TARGET="$VREP_ROOT"
23+
INSTALL_TARGET="$COPPELIASIM_ROOT_DIR"
1324
DLEXT=so
1425
fi
1526

1627
if [ "x$BUILD_TARGET" = "x" ]; then
1728
BUILD_TARGET=debug
1829
fi
1930

20-
cd "`dirname "$0"`"
21-
cp -v "../../devel/lib/libsimExtRosInterface.$DLEXT" "$INSTALL_TARGET"
22-
exit $?
31+
LIBRARY="lib$PLUGIN_NAME.$DLEXT"
32+
33+
if [ -f CMakeLists.txt ]; then
34+
# plugin uses cmake
35+
mkdir -p build
36+
cd build
37+
cmake ..
38+
cmake --build .
39+
cd ..
40+
LIBRARY="build/$LIBRARY"
41+
elif [ -f $PLUGIN_NAME.pro ]; then
42+
# plugin uses qmake
43+
qmake $PLUGIN_NAME.pro
44+
make $BUILD_TARGET
45+
elif [ -f makefile ]; then
46+
# plugin uses make
47+
make $BUILD_TARGET
48+
else
49+
echo "Unable to figure out the build system of $PLUGIN_NAME"
50+
exit 1
51+
fi
52+
53+
cp -v "$LIBRARY" "$INSTALL_TARGET"
54+
if [ -f *.lua ]; then cp -v *.lua "$COPPELIASIM_ROOT_DIR/lua/"; fi
2355

mainpage.dox

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
\mainpage
33
\htmlinclude manifest.html
44

5-
\b vrep_ros_interface
5+
\b sim_ros2_interface
66

77
<!--
88
Provide an overview of your package.

package.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<package format="2">
2-
<name>vrep_ros_interface</name>
3-
<description>V-REP plugin for ROS interface</description>
2+
<name>sim_ros2_interface</name>
3+
<description>CoppeliaSim ROS2 interface plugin</description>
44
<maintainer email="[email protected]">Marc</maintainer>
55
<version>3.3.0</version>
66
<author>Federico Ferri</author>

src/vrep_ros_interface.cpp src/sim_ros2_interface.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <vrep_ros_interface.h>
2-
#include <v_repPlusPlus/Plugin.h>
1+
#include <sim_ros2_interface.h>
2+
#include <simPlusPlus/Plugin.h>
33

44
#include <cstdlib>
55
#include <functional>
@@ -561,11 +561,11 @@ bool initialize()
561561

562562
int node_name_length = 0;
563563
char *node_name = nullptr;
564-
#if VREP_PROGRAM_FULL_VERSION_NB >= 3060104 // 3.6.1.rev4
565-
node_name = simGetStringNamedParam("RosInterface.nodeName", &node_name_length);
564+
#if SIM_PROGRAM_FULL_VERSION_NB >= 3060104 // 3.6.1.rev4
565+
node_name = simGetStringNamedParam("Ros2Interface.nodeName", &node_name_length);
566566
#endif
567567

568-
node = rclcpp::Node::make_shared(node_name && node_name_length ? node_name : "vrep_ros_interface");
568+
node = rclcpp::Node::make_shared(node_name && node_name_length ? node_name : "sim_ros2_interface");
569569

570570
if(node_name) simReleaseBuffer(node_name);
571571

@@ -676,7 +676,7 @@ void shutdownTransientProxies(SScriptCallBack *p)
676676
shutdownTransientServiceServers(p);
677677
}
678678

679-
class Plugin : public vrep::Plugin
679+
class Plugin : public sim::Plugin
680680
{
681681
public:
682682
void onStart()
@@ -696,7 +696,7 @@ class Plugin : public vrep::Plugin
696696
shutdown();
697697
}
698698

699-
void onInstancePass(const vrep::InstancePassFlags &flags, bool first)
699+
void onInstancePass(const sim::InstancePassFlags &flags, bool first)
700700
{
701701
rclcpp::spin_some(node);
702702
}
@@ -712,7 +712,7 @@ class Plugin : public vrep::Plugin
712712
if(previousStopSimulationRequestCounter == -1)
713713
previousStopSimulationRequestCounter = stopSimulationRequestCounter;
714714
if(previousStopSimulationRequestCounter == stopSimulationRequestCounter)
715-
out = 0; // this tells V-REP that we don't wanna execute the main script
715+
out = 0; // this tells CoppeliaSim that we don't wanna execute the main script
716716
}
717717
else
718718
previousStopSimulationRequestCounter = -1;
@@ -732,4 +732,4 @@ class Plugin : public vrep::Plugin
732732
int previousStopSimulationRequestCounter = -1;
733733
};
734734

735-
VREP_PLUGIN(PLUGIN_NAME, PLUGIN_VERSION, Plugin)
735+
SIM_PLUGIN(PLUGIN_NAME, PLUGIN_VERSION, Plugin)

templates/callbacks.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#ifndef VREP_ROS_PLUGIN__CALLBACKS__H
2-
#define VREP_ROS_PLUGIN__CALLBACKS__H
1+
#ifndef SIM_ROS2_PLUGIN__CALLBACKS__H
2+
#define SIM_ROS2_PLUGIN__CALLBACKS__H
33

44
#include <ros_msg_builtin_io.h>
5-
#include <vrep_ros_interface.h>
5+
#include <sim_ros2_interface.h>
66

77
#py import parse_messages_and_services as p
88
#py msgs, srvs, msgssrvs = p.load_cache(pycpp.params['cache_file'])
@@ -24,4 +24,4 @@ void ros_callback__`info.typespec.normalized()`(const `info.typespec.cpp_type()`
2424
bool ros_srv_callback__`info.typespec.normalized()`(const std::shared_ptr<rmw_request_id_t> request_header, const `info.typespec.cpp_type()`::Request::SharedPtr req, `info.typespec.cpp_type()`::Response::SharedPtr res, ServiceServerProxy *proxy);
2525
#py endfor
2626

27-
#endif // VREP_ROS_PLUGIN__CALLBACKS__H
27+
#endif // SIM_ROS2_PLUGIN__CALLBACKS__H

test_sendTransform.ttt

-1.02 MB
Binary file not shown.

vrep_ros_plugin.ttt

-240 KB
Binary file not shown.

0 commit comments

Comments
 (0)