Skip to content

Commit 26c84d3

Browse files
committed
Adding custom node
1 parent d26f46b commit 26c84d3

File tree

9 files changed

+339
-3
lines changed

9 files changed

+339
-3
lines changed

Assets/Scenes/SampleScene.unity

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ RenderSettings:
3838
m_ReflectionIntensity: 1
3939
m_CustomReflection: {fileID: 0}
4040
m_Sun: {fileID: 0}
41-
m_IndirectSpecularColor: {r: 0.18028334, g: 0.22571328, b: 0.3069217, a: 1}
41+
m_IndirectSpecularColor: {r: 0.18028378, g: 0.22571412, b: 0.30692285, a: 1}
4242
m_UseRadianceAmbientProbe: 0
4343
--- !u!157 &3
4444
LightmapSettings:
4545
m_ObjectHideFlags: 0
4646
serializedVersion: 11
47-
m_GIWorkflowMode: 0
47+
m_GIWorkflowMode: 1
4848
m_GISettings:
4949
serializedVersion: 2
5050
m_BounceScale: 1
5151
m_IndirectOutputScale: 1
5252
m_AlbedoBoost: 1
5353
m_TemporalCoherenceThreshold: 1
5454
m_EnvironmentLightingMode: 0
55-
m_EnableBakedLightmaps: 1
55+
m_EnableBakedLightmaps: 0
5656
m_EnableRealtimeLightmaps: 0
5757
m_LightmapEditorSettings:
5858
serializedVersion: 10

Assets/Scripts/ROSController.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ public class ROSController : MonoBehaviour
2626
/// </summary>
2727
public string subVector3Topic = "/stanford/vector3";
2828

29+
/// <summary>
30+
/// Example subscriber topic for the custom node
31+
/// </summary>
32+
public string subCustomNodeTopic = "/stanford/vector3converted";
33+
2934
/// <summary>
3035
/// Example publisher
3136
/// </summary>
@@ -35,6 +40,11 @@ public class ROSController : MonoBehaviour
3540
/// Example subscriber
3641
/// </summary>
3742
Subscriber<Messages.geometry_msgs.Vector3> subVector3;
43+
44+
/// <summary>
45+
/// Example subscriber for the custom node
46+
/// </summary>
47+
//Subscriber<Messages.stanford_msgs.ExampleCustom> subCustomNode;
3848
#endregion
3949

4050

@@ -82,6 +92,7 @@ public void InitROS()
8292

8393
// Setup subscribers
8494
subVector3 = nodeHandle.subscribe<Messages.geometry_msgs.Vector3>(subVector3Topic, 1, OnReceiveVector3);
95+
//subCustomNode = nodeHandle.subscribe<Messages.stanford_msgs.ExampleCustom>(subCustomNodeTopic, 1, OnReceiveCustomNodeData);
8596
}
8697
else
8798
{
@@ -153,5 +164,11 @@ void OnReceiveVector3(Messages.geometry_msgs.Vector3 data)
153164
{
154165
Debug.LogFormat("Received Vector3 message: ({0}, {1}, {2})", data.x.ToString("F4"), data.y.ToString("F4"), data.z.ToString("F4"));
155166
}
167+
168+
169+
//void OnReceiveCustomNodeData(Messages.stanford_msgs.ExampleCustom data)
170+
//{
171+
172+
//}
156173
#endregion
157174
}

ros/.catkin_workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file currently only serves to mark the location of a catkin workspace for tool integration

ros/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
cmake_minimum_required(VERSION 2.8.3)
2+
project(stanford_msgs)
3+
4+
## Compile as C++11, supported in ROS Kinetic and newer
5+
# add_compile_options(-std=c++11)
6+
7+
## Find catkin macros and libraries
8+
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
9+
## is used, also find other catkin packages
10+
find_package(catkin REQUIRED COMPONENTS
11+
geometry_msgs
12+
roscpp
13+
rospy
14+
std_msgs
15+
message_generation
16+
)
17+
18+
## System dependencies are found with CMake's conventions
19+
# find_package(Boost REQUIRED COMPONENTS system)
20+
21+
22+
## Uncomment this if the package has a setup.py. This macro ensures
23+
## modules and global scripts declared therein get installed
24+
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
25+
# catkin_python_setup()
26+
27+
################################################
28+
## Declare ROS messages, services and actions ##
29+
################################################
30+
31+
## To declare and build messages, services or actions from within this
32+
## package, follow these steps:
33+
## * Let MSG_DEP_SET be the set of packages whose message types you use in
34+
## your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
35+
## * In the file package.xml:
36+
## * add a build_depend tag for "message_generation"
37+
## * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
38+
## * If MSG_DEP_SET isn't empty the following dependency has been pulled in
39+
## but can be declared for certainty nonetheless:
40+
## * add a run_depend tag for "message_runtime"
41+
## * In this file (CMakeLists.txt):
42+
## * add "message_generation" and every package in MSG_DEP_SET to
43+
## find_package(catkin REQUIRED COMPONENTS ...)
44+
## * add "message_runtime" and every package in MSG_DEP_SET to
45+
## catkin_package(CATKIN_DEPENDS ...)
46+
## * uncomment the add_*_files sections below as needed
47+
## and list every .msg/.srv/.action file to be processed
48+
## * uncomment the generate_messages entry below
49+
## * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)
50+
51+
## Generate messages in the 'msg' folder
52+
add_message_files(
53+
FILES
54+
ExampleCustom.msg
55+
)
56+
57+
## Generate services in the 'srv' folder
58+
# add_service_files(
59+
# FILES
60+
# Service1.srv
61+
# Service2.srv
62+
# )
63+
64+
## Generate actions in the 'action' folder
65+
# add_action_files(
66+
# FILES
67+
# Action1.action
68+
# Action2.action
69+
# )
70+
71+
## Generate added messages and services with any dependencies listed here
72+
generate_messages(
73+
DEPENDENCIES
74+
geometry_msgs
75+
std_msgs
76+
)
77+
78+
################################################
79+
## Declare ROS dynamic reconfigure parameters ##
80+
################################################
81+
82+
## To declare and build dynamic reconfigure parameters within this
83+
## package, follow these steps:
84+
## * In the file package.xml:
85+
## * add a build_depend and a run_depend tag for "dynamic_reconfigure"
86+
## * In this file (CMakeLists.txt):
87+
## * add "dynamic_reconfigure" to
88+
## find_package(catkin REQUIRED COMPONENTS ...)
89+
## * uncomment the "generate_dynamic_reconfigure_options" section below
90+
## and list every .cfg file to be processed
91+
92+
## Generate dynamic reconfigure parameters in the 'cfg' folder
93+
# generate_dynamic_reconfigure_options(
94+
# cfg/DynReconf1.cfg
95+
# cfg/DynReconf2.cfg
96+
# )
97+
98+
###################################
99+
## catkin specific configuration ##
100+
###################################
101+
## The catkin_package macro generates cmake config files for your package
102+
## Declare things to be passed to dependent projects
103+
## INCLUDE_DIRS: uncomment this if your package contains header files
104+
## LIBRARIES: libraries you create in this project that dependent projects also need
105+
## CATKIN_DEPENDS: catkin_packages dependent projects also need
106+
## DEPENDS: system dependencies of this project that dependent projects also need
107+
catkin_package(
108+
# INCLUDE_DIRS include
109+
# LIBRARIES stanford_msgs
110+
CATKIN_DEPENDS geometry_msgs roscpp rospy std_msgs message_runtime
111+
# DEPENDS system_lib
112+
)
113+
114+
###########
115+
## Build ##
116+
###########
117+
118+
## Specify additional locations of header files
119+
## Your package locations should be listed before other locations
120+
include_directories(
121+
# include
122+
${catkin_INCLUDE_DIRS}
123+
)
124+
125+
## Declare a C++ library
126+
# add_library(${PROJECT_NAME}
127+
# src/${PROJECT_NAME}/stanford_msgs.cpp
128+
# )
129+
130+
## Add cmake target dependencies of the library
131+
## as an example, code may need to be generated before libraries
132+
## either from message generation or dynamic reconfigure
133+
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
134+
135+
## Declare a C++ executable
136+
## With catkin_make all packages are built within a single CMake context
137+
## The recommended prefix ensures that target names across packages don't collide
138+
add_executable(example_custom_node src/example_custom_node.cpp)
139+
140+
## Rename C++ executable without prefix
141+
## The above recommended prefix causes long target names, the following renames the
142+
## target back to the shorter version for ease of user use
143+
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
144+
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")
145+
146+
## Add cmake target dependencies of the executable
147+
## same as for the library above
148+
add_dependencies(example_custom_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
149+
150+
## Specify libraries to link a library or executable target against
151+
target_link_libraries(example_custom_node
152+
${catkin_LIBRARIES}
153+
)
154+
155+
#############
156+
## Install ##
157+
#############
158+
159+
# all install targets should use catkin DESTINATION variables
160+
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
161+
162+
## Mark executable scripts (Python etc.) for installation
163+
## in contrast to setup.py, you can choose the destination
164+
# install(PROGRAMS
165+
# scripts/my_python_script
166+
# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
167+
# )
168+
169+
## Mark executables and/or libraries for installation
170+
# install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node
171+
# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
172+
# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
173+
# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
174+
# )
175+
176+
## Mark cpp header files for installation
177+
# install(DIRECTORY include/${PROJECT_NAME}/
178+
# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
179+
# FILES_MATCHING PATTERN "*.h"
180+
# PATTERN ".svn" EXCLUDE
181+
# )
182+
183+
## Mark other files for installation (e.g. launch and bag files, etc.)
184+
# install(FILES
185+
# # myfile1
186+
# # myfile2
187+
# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
188+
# )
189+
190+
#############
191+
## Testing ##
192+
#############
193+
194+
## Add gtest based cpp test target and link libraries
195+
# catkin_add_gtest(${PROJECT_NAME}-test test/test_stanford_msgs.cpp)
196+
# if(TARGET ${PROJECT_NAME}-test)
197+
# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
198+
# endif()
199+
200+
## Add folders to be run by python nosetests
201+
# catkin_add_nosetests(test)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<launch>
2+
<node
3+
pkg="stanford_msgs"
4+
type="example_custom_node"
5+
name="stanford_example_node"
6+
/>
7+
</launch>
8+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
geometry_msgs/Vector3 input
2+
geometry_msgs/Vector3 output

ros/src/stanford_msgs/package.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0"?>
2+
<package format="2">
3+
<name>stanford_msgs</name>
4+
<version>0.0.0</version>
5+
<description>The stanford_msgs package</description>
6+
7+
<!-- One maintainer tag required, multiple allowed, one person per tag -->
8+
<!-- Example: -->
9+
<!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
10+
<maintainer email="luminar@todo.todo">luminar</maintainer>
11+
12+
13+
<!-- One license tag required, multiple allowed, one license per tag -->
14+
<!-- Commonly used license strings: -->
15+
<!-- BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
16+
<license>TODO</license>
17+
18+
19+
<!-- Url tags are optional, but multiple are allowed, one per tag -->
20+
<!-- Optional attribute type can be: website, bugtracker, or repository -->
21+
<!-- Example: -->
22+
<!-- <url type="website">http://wiki.ros.org/stanford_msgs</url> -->
23+
24+
25+
<!-- Author tags are optional, multiple are allowed, one per tag -->
26+
<!-- Authors do not have to be maintainers, but could be -->
27+
<!-- Example: -->
28+
<!-- <author email="jane.doe@example.com">Jane Doe</author> -->
29+
30+
31+
<!-- The *depend tags are used to specify dependencies -->
32+
<!-- Dependencies can be catkin packages or system dependencies -->
33+
<!-- Examples: -->
34+
<!-- Use depend as a shortcut for packages that are both build and exec dependencies -->
35+
<!-- <depend>roscpp</depend> -->
36+
<!-- Note that this is equivalent to the following: -->
37+
<!-- <build_depend>roscpp</build_depend> -->
38+
<!-- <exec_depend>roscpp</exec_depend> -->
39+
<!-- Use build_depend for packages you need at compile time: -->
40+
<build_depend>message_generation</build_depend>
41+
<!-- Use build_export_depend for packages you need in order to build against this package: -->
42+
<!-- <build_export_depend>message_generation</build_export_depend> -->
43+
<!-- Use buildtool_depend for build tool packages: -->
44+
<!-- <buildtool_depend>catkin</buildtool_depend> -->
45+
<!-- Use exec_depend for packages you need at runtime: -->
46+
<exec_depend>message_runtime</exec_depend>
47+
<!-- Use test_depend for packages you need only for testing: -->
48+
<!-- <test_depend>gtest</test_depend> -->
49+
<!-- Use doc_depend for packages you need only for building documentation: -->
50+
<!-- <doc_depend>doxygen</doc_depend> -->
51+
<buildtool_depend>catkin</buildtool_depend>
52+
<build_depend>geometry_msgs</build_depend>
53+
<build_depend>roscpp</build_depend>
54+
<build_depend>rospy</build_depend>
55+
<build_depend>std_msgs</build_depend>
56+
<build_export_depend>geometry_msgs</build_export_depend>
57+
<build_export_depend>roscpp</build_export_depend>
58+
<build_export_depend>rospy</build_export_depend>
59+
<build_export_depend>std_msgs</build_export_depend>
60+
<exec_depend>geometry_msgs</exec_depend>
61+
<exec_depend>roscpp</exec_depend>
62+
<exec_depend>rospy</exec_depend>
63+
<exec_depend>std_msgs</exec_depend>
64+
65+
66+
<!-- The export tag contains other, unspecified, tags -->
67+
<export>
68+
<!-- Other tools can request additional information be placed here -->
69+
70+
</export>
71+
</package>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <iostream>
2+
#include <ros/ros.h>
3+
#include <stanford_msgs/ExampleCustom.h>
4+
5+
ros::Publisher pubCustom;
6+
7+
void msg_cb (const geometry_msgs::Vector3 incomingMsg)
8+
{
9+
stanford_msgs::ExampleCustom outgoingMsg;
10+
11+
outgoingMsg.input.x = incomingMsg.x;
12+
outgoingMsg.input.y = incomingMsg.y;
13+
outgoingMsg.input.z = incomingMsg.z;
14+
outgoingMsg.output.x = incomingMsg.z;
15+
outgoingMsg.output.y = -incomingMsg.x;
16+
outgoingMsg.output.z = incomingMsg.y;
17+
18+
pubCustom.publish(outgoingMsg);
19+
}
20+
21+
int main (int argc, char** argv)
22+
{
23+
// Initialize ROS connection
24+
ros::init(argc, argv, "stanford_example_node");
25+
ros::NodeHandle nh;
26+
27+
// Create a ROS subscriber for the input data
28+
ros::Subscriber sub = nh.subscribe("/stanford/vector3", 1, msg_cb);
29+
30+
// Create the publisher for the converted data
31+
pubCustom = nh.advertise<stanford_msgs::ExampleCustom>("/stanford/vector3converted", 1);
32+
33+
// Spin
34+
ros::spin ();
35+
}

0 commit comments

Comments
 (0)