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

onboarding need review #100

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
Empty file added 10_Examples/-onboarding
Empty file.
66 changes: 66 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

cmake_minimum_required(VERSION 3.8)
project(Johnny_Shen_onboarding)

include_directories(include)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_gtest REQUIRED)
find_package(std_msgs REQUIRED)
find_package(rclcpp REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()

add_library(hello_world src/hello_world.cpp)
install(TARGETS
hello_world
DESTINATION lib/${PROJECT_NAME})


add_executable(publish_test src/a.cpp)

ament_target_dependencies(publish_test
std_msgs
rclcpp)

install(TARGETS
publish_test
DESTINATION lib/${PROJECT_NAME})

add_executable(subscribe_test src/b.cpp)

ament_target_dependencies(subscribe_test
std_msgs
rclcpp)

install(TARGETS
subscribe_test
DESTINATION lib/${PROJECT_NAME})

ament_add_gtest(testadd test/c.cpp)
target_link_libraries(testadd
gtest
hello_world)



Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 Jake Wendling
* All rights reserved.

* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:

* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#pragma once
#include "std_msgs/msg/string.hpp"
#include "rclcpp/rclcpp.hpp"

// file that contains the custom nodes definitions
// #include "dummy_nodes.h"
// using namespace DummyNodes;

class Publishertest : public rclcpp::Node
{
private:
// std::shared_ptr<ghost_v5_interfaces::RobotHardwareInterface> robot_hardware_interface_ptr_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr robot_pub_;

public:
Publishertest();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Jake Wendling
* All rights reserved.

* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:

* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#pragma once
#include "std_msgs/msg/string.hpp"
#include "rclcpp/rclcpp.hpp"

// file that contains the custom nodes definitions
// #include "dummy_nodes.h"
// using namespace DummyNodes;

class Subscribertest : public rclcpp::Node
{
private:
// std::shared_ptr<ghost_v5_interfaces::RobotHardwareInterface> robot_hardware_interface_ptr_;
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr robot_sub_;
void printer(std_msgs::msg::String::SharedPtr msg);

public:
Subscribertest();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include <iostream>

class Add{
public:
int add (int x, int y);

};
int Add::add(int x, int y){
return x+y;
}
18 changes: 18 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>Johnny_Shen_onboarding</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">johnny</maintainer>
<license>TODO: License declaration</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
22 changes: 22 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/src/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "Johnny_Shen_onboarding/a.hpp"

Publishertest::Publishertest()
: rclcpp::Node("hello_node")
{
robot_pub_ = create_publisher<std_msgs::msg::String>(
"/hello",
10);
std_msgs::msg::String hello_msg{};
hello_msg.data = "hello";
robot_pub_->publish(hello_msg);
}

int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
auto node = std::make_shared<Publishertest>();
rclcpp::spin(node);

rclcpp::shutdown();
return 0;
}
25 changes: 25 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/src/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Johnny_Shen_onboarding/b.hpp"
using std::placeholders::_1;

Subscribertest::Subscribertest()
: rclcpp::Node("hello1_node")
{
robot_sub_ = create_subscription<std_msgs::msg::String>(
"/hello",
10,
std::bind(&Subscribertest::printer,this,_1));

}
void Subscribertest::printer(std_msgs::msg::String::SharedPtr msg){
std::cout << msg->data;
// RCLCPP_INFO(this, msg->data);
}
int main(int argc, char * argv[])
{
rclcpp::init(argc, argv);
auto node = std::make_shared<Subscribertest>();
rclcpp::spin(node);

rclcpp::shutdown();
return 0;
}
12 changes: 12 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/src/hello_world.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include "Johnny_Shen_onboarding/hello_world.hpp"




int main(int argc, char **argv) {
std::cout << "Hello World!" << std::endl;
Add myObj;
std::cout << myObj.add(100,200);
return 0;
}
49 changes: 49 additions & 0 deletions 10_Examples/Johnny_Shen_onboarding/test/c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 Maxx Wilson
* All rights reserved.

* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:

* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

#include "Johnny_Shen_onboarding/hello_world.hpp"
#include "gtest/gtest.h"


class TestMathUtil : public ::testing::Test
{
public:
TestMathUtil()
{
}
};

TEST_F(TestMathUtil, testAdd) {
Add adder;



EXPECT_EQ(adder.add(7, 9), 16); // (-inf,1]
EXPECT_EQ(adder.add(3, 2), 5); // [1,2]

}
int main(int argc, char ** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
35 changes: 35 additions & 0 deletions 10_Examples/my_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.8)
project(my_package)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(my_node src/my_node.cpp)
target_include_directories(my_node PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(my_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17

install(TARGETS my_node
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
Loading
Loading