mirror of
https://github.com/westonrobot/ugv_sdk
synced 2023-04-08 06:32:14 +08:00
updated some path for app and demo for scout and tracer
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/hunter/hunter_base.hpp"
|
#include "ugv_sdk/hunter_base.hpp"
|
||||||
|
|
||||||
using namespace westonrobot;
|
using namespace westonrobot;
|
||||||
|
|
||||||
|
|||||||
@@ -7,51 +7,46 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/scout/scout_base.hpp"
|
#include "ugv_sdk/scout_base.hpp"
|
||||||
|
|
||||||
using namespace westonrobot;
|
using namespace westonrobot;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
int32_t baud_rate = 0;
|
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
device_name = {argv[1]};
|
device_name = {argv[1]};
|
||||||
std::cout << "Specified CAN: " << device_name << std::endl;
|
std::cout << "Specified CAN: " << device_name << std::endl;
|
||||||
} else if (argc == 3) {
|
|
||||||
device_name = {argv[1]};
|
|
||||||
baud_rate = std::stol(argv[2]);
|
|
||||||
std::cout << "Specified serial: " << device_name << "@" << baud_rate
|
|
||||||
<< std::endl;
|
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Usage: app_scout_demo <interface>" << std::endl
|
std::cout << "Usage: app_scout_demo <interface>" << std::endl
|
||||||
<< "Example 1: ./app_scout_demo can0" << std::endl
|
<< "Example 1: ./app_scout_demo can0" << std::endl;
|
||||||
<< "Example 2: ./app_scout_demo /dev/ttyUSB0 115200" << std::endl;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScoutBase scout;
|
ScoutBase scout;
|
||||||
scout.Connect(device_name, baud_rate);
|
scout.Connect(device_name);
|
||||||
|
|
||||||
|
scout.EnableCommandedMode();
|
||||||
|
|
||||||
// // light control
|
// // light control
|
||||||
// std::cout << "Light: const off" << std::endl;
|
std::cout << "Light: const off" << std::endl;
|
||||||
// scout.SetLightCommand({ScoutLightCmd::LightMode::CONST_OFF, 0,
|
scout.SetLightCommand({CONST_OFF, 0,
|
||||||
// ScoutLightCmd::LightMode::CONST_OFF, 0});
|
CONST_OFF, 0});
|
||||||
// sleep(3);
|
sleep(3);
|
||||||
// std::cout << "Light: const on" << std::endl;
|
std::cout << "Light: const on" << std::endl;
|
||||||
// scout.SetLightCommand({ScoutLightCmd::LightMode::CONST_ON, 0,
|
scout.SetLightCommand({CONST_ON, 0,
|
||||||
// ScoutLightCmd::LightMode::CONST_ON, 0});
|
CONST_ON, 0});
|
||||||
// sleep(3);
|
sleep(3);
|
||||||
// std::cout << "Light: breath" << std::endl;
|
std::cout << "Light: breath" << std::endl;
|
||||||
// scout.SetLightCommand({ScoutLightCmd::LightMode::BREATH, 0,
|
scout.SetLightCommand({BREATH, 0,
|
||||||
// ScoutLightCmd::LightMode::BREATH, 0});
|
BREATH, 0});
|
||||||
// sleep(3);
|
sleep(3);
|
||||||
// std::cout << "Light: custom 90-80" << std::endl;
|
std::cout << "Light: custom 90-80" << std::endl;
|
||||||
// scout.SetLightCommand({ScoutLightCmd::LightMode::CUSTOM, 90,
|
scout.SetLightCommand({CUSTOM, 90,
|
||||||
// ScoutLightCmd::LightMode::CUSTOM, 80});
|
CUSTOM, 80});
|
||||||
// sleep(3);
|
sleep(3);
|
||||||
// std::cout << "Light: diabled cmd control" << std::endl;
|
std::cout << "Light: diabled cmd control" << std::endl;
|
||||||
// scout.DisableLightCmdControl();
|
scout.DisableLightControl();
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -95,8 +90,8 @@ int main(int argc, char **argv) {
|
|||||||
// {
|
// {
|
||||||
// std::cout << "Motor: 0.0, 0, Light: breath" << std::endl;
|
// std::cout << "Motor: 0.0, 0, Light: breath" << std::endl;
|
||||||
// scout.SetMotionCommand(0.0, 0.0);
|
// scout.SetMotionCommand(0.0, 0.0);
|
||||||
// scout.SetLightCommand({ScoutLightCmd::LightMode::BREATH, 0,
|
// scout.SetLightCommand({BREATH, 0,
|
||||||
// ScoutLightCmd::LightMode::BREATH, 0});
|
// BREATH, 0});
|
||||||
// }
|
// }
|
||||||
if (count < 100) {
|
if (count < 100) {
|
||||||
std::cout << "Motor: 0.2, 0" << std::endl;
|
std::cout << "Motor: 0.2, 0" << std::endl;
|
||||||
@@ -106,12 +101,12 @@ int main(int argc, char **argv) {
|
|||||||
auto state = scout.GetScoutState();
|
auto state = scout.GetScoutState();
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
std::cout << "count: " << count << std::endl;
|
std::cout << "count: " << count << std::endl;
|
||||||
std::cout << "control mode: " << static_cast<int>(state.control_mode)
|
std::cout << "control mode: " << static_cast<int>(state.system_state.control_mode)
|
||||||
<< " , base state: " << static_cast<int>(state.base_state)
|
<< " , vehicle state: " << static_cast<int>(state.system_state.vehicle_state)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "battery voltage: " << state.battery_voltage << std::endl;
|
std::cout << "battery voltage: " << state.system_state.battery_voltage << std::endl;
|
||||||
std::cout << "velocity (linear, angular): " << state.linear_velocity << ", "
|
std::cout << "velocity (linear, angular): " << state.motion_state.linear_velocity << ", "
|
||||||
<< state.angular_velocity << std::endl;
|
<< state.motion_state.angular_velocity << std::endl;
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
|
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
|
|||||||
@@ -7,26 +7,19 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scout_base/scout_base.hpp"
|
#include "ugv_sdk/scout_base.hpp"
|
||||||
|
|
||||||
using namespace westonrobot;
|
using namespace westonrobot;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
int32_t baud_rate = 0;
|
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
{
|
{
|
||||||
device_name = {argv[1]};
|
device_name = {argv[1]};
|
||||||
std::cout << "Specified CAN: " << device_name << std::endl;
|
std::cout << "Specified CAN: " << device_name << std::endl;
|
||||||
}
|
}
|
||||||
else if (argc == 3)
|
|
||||||
{
|
|
||||||
device_name = {argv[1]};
|
|
||||||
baud_rate = std::stol(argv[2]);
|
|
||||||
std::cout << "Specified serial: " << device_name << "@" << baud_rate << std::endl;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "Usage: app_scout_monitor <interface>" << std::endl
|
std::cout << "Usage: app_scout_monitor <interface>" << std::endl
|
||||||
@@ -36,34 +29,36 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ScoutBase scout;
|
ScoutBase scout;
|
||||||
scout.Connect(device_name, baud_rate);
|
scout.Connect(device_name);
|
||||||
|
|
||||||
|
scout.EnableCommandedMode();
|
||||||
|
|
||||||
// light control
|
// light control
|
||||||
std::cout << "Light: const on" << std::endl;
|
std::cout << "Light: const on" << std::endl;
|
||||||
scout.SetLightCommand({ScoutLightCmd::LightMode::CONST_ON, 0, ScoutLightCmd::LightMode::CONST_ON, 0});
|
scout.SetLightCommand({CONST_ON, 0, CONST_ON, 0});
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
auto state = scout.GetScoutState();
|
auto state = scout.GetScoutState();
|
||||||
|
|
||||||
if (state.battery_voltage >= 22.5)
|
if (state.system_state.battery_voltage >= 22.5)
|
||||||
{
|
{
|
||||||
scout.SetMotionCommand(1.35, 0);
|
scout.SetMotionCommand(1.35, 0);
|
||||||
|
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
std::cout << "-------> discharging <--------" << std::endl;
|
std::cout << "-------> discharging <--------" << std::endl;
|
||||||
std::cout << "elapsed time: " << count / 60 << " minutes " << count % 60 << " seconds" << std::endl;
|
std::cout << "elapsed time: " << count / 60 << " minutes " << count % 60 << " seconds" << std::endl;
|
||||||
std::cout << "control mode: " << static_cast<int>(state.control_mode) << " , base state: " << static_cast<int>(state.base_state) << std::endl;
|
std::cout << "control mode: " << static_cast<int>(state.system_state.control_mode) << " , vehicle state: " << static_cast<int>(state.system_state.vehicle_state) << std::endl;
|
||||||
std::cout << "battery voltage: " << state.battery_voltage << std::endl;
|
std::cout << "battery voltage: " << state.system_state.battery_voltage << std::endl;
|
||||||
std::cout << "velocity (linear, angular): " << state.linear_velocity << ", " << state.angular_velocity << std::endl;
|
std::cout << "velocity (linear, angular): " << state.motion_state.linear_velocity << ", " << state.motion_state.angular_velocity << std::endl;
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scout.SetMotionCommand(0, 0);
|
scout.SetMotionCommand(0, 0);
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
std::cout << "discharge stopped at: " << state.battery_voltage << " V" << std::endl;
|
std::cout << "discharge stopped at: " << state.system_state.battery_voltage << " V" << std::endl;
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#ifndef SCOUT_MONITOR_HPP
|
#ifndef SCOUT_MONITOR_HPP
|
||||||
#define SCOUT_MONITOR_HPP
|
#define SCOUT_MONITOR_HPP
|
||||||
|
|
||||||
#include "ugv_sdk/scout/scout_base.hpp"
|
#include "ugv_sdk/scout_base.hpp"
|
||||||
|
|
||||||
#include <ncurses.h>
|
#include <ncurses.h>
|
||||||
|
|
||||||
|
|||||||
@@ -7,13 +7,12 @@
|
|||||||
* Copyright (c) 2019 Ruixiang Du (rdu)
|
* Copyright (c) 2019 Ruixiang Du (rdu)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ugv_sdk/tracer/tracer_base.hpp"
|
#include "ugv_sdk/tracer_base.hpp"
|
||||||
|
|
||||||
using namespace westonrobot;
|
using namespace westonrobot;
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
std::string device_name;
|
std::string device_name;
|
||||||
int32_t baud_rate = 0;
|
|
||||||
|
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
device_name = {argv[1]};
|
device_name = {argv[1]};
|
||||||
@@ -32,19 +31,19 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
// light control
|
// light control
|
||||||
std::cout << "Light: const off" << std::endl;
|
std::cout << "Light: const off" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_OFF, 0});
|
tracer.SetLightCommand({CONST_OFF, 0});
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: const on" << std::endl;
|
std::cout << "Light: const on" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CONST_ON, 0});
|
tracer.SetLightCommand({CONST_ON, 0});
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: breath" << std::endl;
|
std::cout << "Light: breath" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::BREATH, 0});
|
tracer.SetLightCommand({BREATH, 0});
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(8);
|
sleep(8);
|
||||||
std::cout << "Light: custom 90-80" << std::endl;
|
std::cout << "Light: custom 90-80" << std::endl;
|
||||||
tracer.SetLightCommand({TracerLightCmd::LightMode::CUSTOM, 90});
|
tracer.SetLightCommand({CUSTOM, 90});
|
||||||
// usleep(50000);
|
// usleep(50000);
|
||||||
sleep(3);
|
sleep(3);
|
||||||
std::cout << "Light: diabled cmd control" << std::endl;
|
std::cout << "Light: diabled cmd control" << std::endl;
|
||||||
@@ -83,12 +82,12 @@ int main(int argc, char **argv) {
|
|||||||
auto state = tracer.GetTracerState();
|
auto state = tracer.GetTracerState();
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
std::cout << "count: " << count << std::endl;
|
std::cout << "count: " << count << std::endl;
|
||||||
std::cout << "control mode: " << static_cast<int>(state.control_mode)
|
std::cout << "control mode: " << static_cast<int>(state.system_state.control_mode)
|
||||||
<< " , base state: " << static_cast<int>(state.base_state)
|
<< " , vehicle state: " << static_cast<int>(state.system_state.vehicle_state)
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
std::cout << "battery voltage: " << state.battery_voltage << std::endl;
|
std::cout << "battery voltage: " << state.system_state.battery_voltage << std::endl;
|
||||||
std::cout << "velocity (linear, angular): " << state.linear_velocity << ", "
|
std::cout << "velocity (linear, angular): " << state.motion_state.linear_velocity << ", "
|
||||||
<< state.angular_velocity << std::endl;
|
<< state.motion_state.angular_velocity << std::endl;
|
||||||
std::cout << "-------------------------------" << std::endl;
|
std::cout << "-------------------------------" << std::endl;
|
||||||
|
|
||||||
// usleep(20000);
|
// usleep(20000);
|
||||||
|
|||||||
Reference in New Issue
Block a user