Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzheqie committed Apr 23, 2021
1 parent 174649d commit 24b6c75
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ranger_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ find_package(catkin REQUIRED COMPONENTS
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
# INCLUDE_DIRS include
INCLUDE_DIRS include
# LIBRARIES ranger_base
# CATKIN_DEPENDS controller_manager geometry_msgs ranger_msgs roscpp roslaunch sensor_msgs topic_tools ugv_sdk
# DEPENDS system_lib
Expand Down
5 changes: 4 additions & 1 deletion ranger_examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ include_directories(
## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/ranger_examples_node.cpp)
add_executable(change_the_mode src/change_the_mode.cpp)
target_link_libraries(change_the_mode ${catkin_LIBRARIES})
add_executable(control_the_car src/control_the_car.cpp)
target_link_libraries(control_the_car ${catkin_LIBRARIES})

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
Expand Down
39 changes: 39 additions & 0 deletions ranger_examples/src/change_the_mode.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* @Kit : Qt-Creator: Desktop
* @Author : Wang Zhe
* @Date : 2021-04-23 18:20:58
* @FileName : change_the_mode.cpp
* @Mail : [email protected]
* Copyright : AgileX Robotics (2021)
**/
#include <memory>

#include <nav_msgs/Odometry.h>
#include <ros/ros.h>

#include "ranger_base/ranger_messenger.hpp"
#include "ugv_sdk/ranger_base.hpp"

using namespace westonrobot;

std::shared_ptr<RangerBase> robot;

int main(int argc, char *argv[]) {
// setup ROS node
ros::init(argc, argv, "change_the_mode");
ros::NodeHandle node(""), private_node("~");

// instantiate a robot object
robot = std::make_shared<RangerBase>();

robot->Connect("can0");
robot->EnableCommandedMode();

// publish robot state at 50Hz while listening to twist commands
ros::Rate rate(50);
while (ros::ok()) {
ros::spinOnce();
rate.sleep();
}
return 0;
}
44 changes: 44 additions & 0 deletions ranger_examples/src/control_the_car.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @Kit : Qt-Creator: Desktop
* @Author : Wang Zhe
* @Date : 2021-04-23 18:20:37
* @FileName : control_the_car.cpp
* @Mail : [email protected]
* Copyright : AgileX Robotics (2021)
**/

#include <memory>

#include <nav_msgs/Odometry.h>
#include <ros/ros.h>

#include "ranger_base/ranger_messenger.hpp"
#include "ugv_sdk/ranger_base.hpp"

using namespace westonrobot;

std::shared_ptr<RangerBase> robot;


int main(int argc, char *argv[]) {
// setup ROS node
ros::init(argc, argv, "control_the_car");
ros::NodeHandle node(""), private_node("~");

// instantiate a robot object
robot = std::make_shared<RangerBase>();

robot->Connect("can0");
robot->EnableCommandedMode();




// publish robot state at 50Hz while listening to twist commands
ros::Rate rate(50);
while (ros::ok()) {
ros::spinOnce();
rate.sleep();
}
return 0;
}

0 comments on commit 24b6c75

Please sign in to comment.