repo_id
stringlengths 19
138
| file_path
stringlengths 32
200
| content
stringlengths 1
12.9M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/object_extended_info_60d.cc
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/drivers/radar/conti_radar/protocol/object_extended_info_60d.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
#include "modules/drivers/radar/conti_radar/protocol/const_vars.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::canbus::Byte;
ObjectExtendedInfo60D::ObjectExtendedInfo60D() {}
const uint32_t ObjectExtendedInfo60D::ID = 0x60D;
void ObjectExtendedInfo60D::Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const {
int obj_id = object_id(bytes, length);
for (int i = 0; i < conti_radar->contiobs_size(); ++i) {
if (conti_radar->contiobs(i).obstacle_id() == obj_id) {
auto obs = conti_radar->mutable_contiobs(i);
obs->set_longitude_accel(longitude_accel(bytes, length));
obs->set_lateral_accel(lateral_accel(bytes, length));
obs->set_oritation_angle(oritation_angle(bytes, length));
obs->set_length(object_length(bytes, length));
obs->set_width(object_width(bytes, length));
obs->set_obstacle_class(obstacle_class(bytes, length));
break;
}
}
// auto conti_obs = conti_radar->mutable_contiobs(object_id(bytes, length));
}
int ObjectExtendedInfo60D::object_id(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
double ObjectExtendedInfo60D::longitude_accel(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 2);
int32_t t = t1.get_byte(5, 3);
x <<= 3;
x |= t;
double ret = x * OBJECT_AREL_RES + OBJECT_AREL_LONG_MIN;
return ret;
}
double ObjectExtendedInfo60D::lateral_accel(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 5);
Byte t1(bytes + 3);
int32_t t = t1.get_byte(4, 4);
x <<= 4;
x |= t;
double ret = x * OBJECT_AREL_RES + OBJECT_AREL_LAT_MIN;
return ret;
}
int ObjectExtendedInfo60D::obstacle_class(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(0, 3);
int ret = x;
return ret;
}
double ObjectExtendedInfo60D::oritation_angle(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 5);
int32_t t = t1.get_byte(6, 2);
x <<= 2;
x |= t;
double ret = x * OBJECT_ORIENTATION_ANGEL_RES + OBJECT_ORIENTATION_ANGEL_MIN;
return ret;
}
double ObjectExtendedInfo60D::object_length(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 6);
int32_t x = t0.get_byte(0, 8);
double ret = x * OBJECT_LENGTH_RES;
return ret;
}
double ObjectExtendedInfo60D::object_width(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 7);
int32_t x = t0.get_byte(0, 8);
double ret = x * OBJECT_WIDTH_RES;
return ret;
}
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/cluster_list_status_600.cc
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/drivers/radar/conti_radar/protocol/cluster_list_status_600.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::ContiRadarObs;
using apollo::drivers::canbus::Byte;
ClusterListStatus600::ClusterListStatus600() {}
const uint32_t ClusterListStatus600::ID = 0x600;
void ClusterListStatus600::Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const {
auto status = conti_radar->mutable_cluster_list_status();
status->set_near(near(bytes, length));
status->set_far(far(bytes, length));
status->set_meas_counter(meas_counter(bytes, length));
status->set_interface_version(interface_version(bytes, length));
auto counter = status->near() + status->far();
conti_radar->mutable_contiobs()->Reserve(counter);
}
int ClusterListStatus600::near(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
int ClusterListStatus600::far(const std::uint8_t* bytes, int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
int ClusterListStatus600::meas_counter(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 3);
uint32_t t = t0.get_byte(0, 8);
x <<= 8;
x |= t;
int ret = x;
return ret;
}
int ClusterListStatus600::interface_version(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(4, 4);
int ret = x;
return ret;
}
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/motion_input_yawrate_301.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <cmath>
#include "modules/common_msgs/sensor_msgs/conti_radar.pb.h"
#include "modules/drivers/canbus/can_comm/protocol_data.h"
#include "modules/drivers/radar/conti_radar/proto/conti_radar_conf.pb.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::ContiRadar;
using apollo::drivers::conti_radar::RadarConf;
class MotionInputYawRate301
: public apollo::drivers::canbus::ProtocolData<ContiRadar> {
public:
static const uint32_t ID;
MotionInputYawRate301();
~MotionInputYawRate301();
/**
* @brief get the data period
* @return the value of data period
*/
uint32_t GetPeriod() const override;
/**
* @brief update the data
* @param data a pointer to the data to be updated
*/
void UpdateData(uint8_t* data) override;
/**
* @brief reset the private variables
*/
void Reset() override;
void SetYawRate(const float& yaw_rate);
private:
float yaw_rate_ = NAN;
};
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/object_list_status_60a.cc
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/drivers/radar/conti_radar/protocol/object_list_status_60a.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::ContiRadarObs;
using apollo::drivers::canbus::Byte;
ObjectListStatus60A::ObjectListStatus60A() {}
const uint32_t ObjectListStatus60A::ID = 0x60A;
void ObjectListStatus60A::Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const {
auto status = conti_radar->mutable_object_list_status();
auto num_of_obj = num_of_objects(bytes, length);
status->set_nof_objects(num_of_obj);
status->set_meas_counter(meas_counter(bytes, length));
status->set_interface_version(interface_version(bytes, length));
conti_radar->mutable_contiobs()->Reserve(num_of_obj);
}
int ObjectListStatus60A::num_of_objects(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
int ObjectListStatus60A::meas_counter(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
uint32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 3);
uint32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
int ret = x;
return ret;
}
int ObjectListStatus60A::interface_version(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(4, 4);
int ret = x;
return ret;
}
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "drivers_conti_radar_protocol",
srcs = glob([
"*.cc",
]),
hdrs = glob([
"*.h",
]),
deps = [
"//modules/common_msgs/basic_msgs:header_cc_proto",
"//modules/drivers/canbus/can_comm:message_manager_base",
"//modules/common_msgs/drivers_msgs:can_card_parameter_cc_proto",
"//modules/common_msgs/sensor_msgs:conti_radar_cc_proto",
"//modules/drivers/radar/conti_radar/proto:conti_radar_conf_cc_proto",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/cluster_list_status_600.h
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include "modules/drivers/canbus/can_comm/protocol_data.h"
#include "modules/common_msgs/sensor_msgs/conti_radar.pb.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::ContiRadar;
class ClusterListStatus600
: public apollo::drivers::canbus::ProtocolData<ContiRadar> {
public:
static const uint32_t ID;
ClusterListStatus600();
void Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const override;
private:
int near(const std::uint8_t* bytes, int32_t length) const;
int far(const std::uint8_t* bytes, int32_t length) const;
int meas_counter(const std::uint8_t* bytes, int32_t length) const;
int interface_version(const std::uint8_t* bytes, int32_t length) const;
};
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/cluster_quality_info_702.cc
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/drivers/radar/conti_radar/protocol/cluster_quality_info_702.h"
#include "modules/drivers/radar/conti_radar/protocol/const_vars.h"
#include "glog/logging.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::canbus::Byte;
ClusterQualityInfo702::ClusterQualityInfo702() {}
const uint32_t ClusterQualityInfo702::ID = 0x702;
void ClusterQualityInfo702::Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const {
int id = target_id(bytes, length);
for (int i = 0; i < conti_radar->contiobs_size(); ++i) {
if (conti_radar->contiobs(i).obstacle_id() == id) {
auto conti_obs = conti_radar->mutable_contiobs(i);
conti_obs->set_longitude_dist_rms(
LINEAR_RMS[longitude_dist_rms(bytes, length)]);
conti_obs->set_lateral_dist_rms(
LINEAR_RMS[lateral_dist_rms(bytes, length)]);
conti_obs->set_longitude_vel_rms(
LINEAR_RMS[longitude_vel_rms(bytes, length)]);
conti_obs->set_lateral_vel_rms(
LINEAR_RMS[lateral_vel_rms(bytes, length)]);
conti_obs->set_probexist(PROBOFEXIST[pdh0(bytes, length)]);
switch (invalid_state(bytes, length)) {
case 0x01:
case 0x02:
case 0x03:
case 0x06:
case 0x07:
case 0x0E:
conti_obs->set_probexist(PROBOFEXIST[0]);
default:
break;
}
switch (ambig_state(bytes, length)) {
case 0x00:
case 0x01:
case 0x02:
conti_obs->set_probexist(PROBOFEXIST[0]);
default:
break;
}
}
}
}
int ClusterQualityInfo702::target_id(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
int ClusterQualityInfo702::longitude_dist_rms(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(3, 5);
int ret = x;
return ret;
}
int ClusterQualityInfo702::lateral_dist_rms(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 3);
Byte t1(bytes + 2);
int32_t t = t1.get_byte(6, 2);
x <<= 2;
x |= t;
int ret = x;
return ret;
}
int ClusterQualityInfo702::longitude_vel_rms(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(1, 5);
int ret = x;
return ret;
}
int ClusterQualityInfo702::pdh0(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 3);
int32_t x = t0.get_byte(0, 3);
int ret = x;
return ret;
}
int ClusterQualityInfo702::ambig_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(0, 3);
int ret = x;
return ret;
}
int ClusterQualityInfo702::invalid_state(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(3, 5);
int ret = x;
return ret;
}
int ClusterQualityInfo702::lateral_vel_rms(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 1);
Byte t1(bytes + 3);
int32_t t = t1.get_byte(4, 4);
x <<= 4;
x |= t;
int ret = x;
return ret;
}
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/protocol/object_general_info_60b.cc
|
/******************************************************************************
* Copyright 2017 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/drivers/radar/conti_radar/protocol/object_general_info_60b.h"
#include "glog/logging.h"
#include "cyber/time/time.h"
#include "modules/drivers/canbus/common/byte.h"
#include "modules/drivers/canbus/common/canbus_consts.h"
#include "modules/drivers/radar/conti_radar/protocol/const_vars.h"
namespace apollo {
namespace drivers {
namespace conti_radar {
using apollo::drivers::canbus::Byte;
ObjectGeneralInfo60B::ObjectGeneralInfo60B() {}
const uint32_t ObjectGeneralInfo60B::ID = 0x60B;
void ObjectGeneralInfo60B::Parse(const std::uint8_t* bytes, int32_t length,
ContiRadar* conti_radar) const {
int obj_id = object_id(bytes, length);
auto conti_obs = conti_radar->add_contiobs();
conti_obs->set_clusterortrack(false);
conti_obs->set_obstacle_id(obj_id);
conti_obs->set_longitude_dist(longitude_dist(bytes, length));
conti_obs->set_lateral_dist(lateral_dist(bytes, length));
conti_obs->set_longitude_vel(longitude_vel(bytes, length));
conti_obs->set_lateral_vel(lateral_vel(bytes, length));
conti_obs->set_rcs(rcs(bytes, length));
conti_obs->set_dynprop(dynprop(bytes, length));
double timestamp = apollo::cyber::Time::Now().ToSecond();
auto header = conti_obs->mutable_header();
header->CopyFrom(conti_radar->header());
header->set_timestamp_sec(timestamp);
}
int ObjectGeneralInfo60B::object_id(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes);
int32_t x = t0.get_byte(0, 8);
int ret = x;
return ret;
}
double ObjectGeneralInfo60B::longitude_dist(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 1);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 2);
int32_t t = t1.get_byte(3, 5);
x <<= 5;
x |= t;
double ret = x * OBJECT_DIST_RES + OBJECT_DIST_LONG_MIN;
return ret;
}
double ObjectGeneralInfo60B::lateral_dist(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 2);
int32_t x = t0.get_byte(0, 3);
Byte t1(bytes + 3);
int32_t t = t1.get_byte(0, 8);
x <<= 8;
x |= t;
double ret = x * OBJECT_DIST_RES + OBJECT_DIST_LAT_MIN;
return ret;
}
double ObjectGeneralInfo60B::longitude_vel(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 4);
int32_t x = t0.get_byte(0, 8);
Byte t1(bytes + 5);
int32_t t = t1.get_byte(6, 2);
x <<= 2;
x |= t;
double ret = x * OBJECT_VREL_RES + OBJECT_VREL_LONG_MIN;
return ret;
}
double ObjectGeneralInfo60B::lateral_vel(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 5);
int32_t x = t0.get_byte(0, 6);
Byte t1(bytes + 6);
int32_t t = t1.get_byte(5, 3);
x <<= 3;
x |= t;
double ret = x * OBJECT_VREL_RES + OBJECT_VREL_LAT_MIN;
return ret;
}
double ObjectGeneralInfo60B::rcs(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 7);
int32_t x = t0.get_byte(0, 8);
double ret = x * OBJECT_RCS_RES + OBJECT_RCS_MIN;
return ret;
}
int ObjectGeneralInfo60B::dynprop(const std::uint8_t* bytes,
int32_t length) const {
Byte t0(bytes + 6);
int32_t x = t0.get_byte(0, 3);
int ret = x;
return ret;
}
} // namespace conti_radar
} // namespace drivers
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/conf/conti_radar_conf.pb.txt
|
can_conf {
can_card_parameter {
brand:ESD_CAN
type: PCI_CARD
channel_id: CHANNEL_ID_ONE
}
enable_debug_mode: false
enable_receiver_log: false
}
radar_conf {
max_distance_valid: true
sensor_id_valid: false
radar_power_valid: false
output_type_valid: true
send_quality_valid: true
send_ext_info_valid: true
sort_index_valid: false
store_in_nvm_valid: true
ctrl_relay_valid: false
rcs_threshold_valid: true
max_distance: 250
sensor_id: 0
output_type: OUTPUT_TYPE_OBJECTS
radar_power: 0
ctrl_relay: 0
send_ext_info: true
send_quality: true
sort_index: 0
store_in_nvm: 1
rcs_threshold: RCS_THRESHOLD_STANDARD
# unit: nanoseconds, 20ms for 50Hz
input_send_interval: 20000000
}
radar_channel: "/apollo/sensor/radar"
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/conf/radar_front_conf.pb.txt
|
can_conf {
can_card_parameter {
brand:HERMES_CAN
type: PCI_CARD
channel_id: CHANNEL_ID_ONE
}
enable_debug_mode: false
enable_receiver_log: false
}
radar_conf {
max_distance_valid: true
sensor_id_valid: false
radar_power_valid: false
output_type_valid: true
send_quality_valid: true
send_ext_info_valid: true
sort_index_valid: false
store_in_nvm_valid: true
ctrl_relay_valid: false
rcs_threshold_valid: true
max_distance: 250
sensor_id: 0
output_type: OUTPUT_TYPE_OBJECTS
radar_power: 0
ctrl_relay: 0
send_ext_info: true
send_quality: true
sort_index: 0
store_in_nvm: 1
rcs_threshold: RCS_THRESHOLD_STANDARD
# unit: nanoseconds, 20ms for 50Hz
input_send_interval: 20000000
}
radar_channel: "/apollo/sensor/radar/front"
| 0
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar
|
apollo_public_repos/apollo/modules/drivers/radar/conti_radar/conf/radar_rear_conf.pb.txt
|
can_conf {
can_card_parameter {
brand:HERMES_CAN
type: PCI_CARD
channel_id: CHANNEL_ID_TWO
}
enable_debug_mode: false
enable_receiver_log: false
}
radar_conf {
max_distance_valid: true
sensor_id_valid: false
radar_power_valid: false
output_type_valid: true
send_quality_valid: true
send_ext_info_valid: true
sort_index_valid: false
store_in_nvm_valid: true
ctrl_relay_valid: false
rcs_threshold_valid: true
max_distance: 250
sensor_id: 0
output_type: OUTPUT_TYPE_OBJECTS
radar_power: 0
ctrl_relay: 0
send_ext_info: true
send_quality: true
sort_index: 0
store_in_nvm: 1
rcs_threshold: RCS_THRESHOLD_STANDARD
# unit: nanoseconds, 20ms for 50Hz
input_send_interval: 20000000
}
radar_channel: "/apollo/sensor/radar/rear"
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/v2x/cyberfile.xml
|
<package format="2">
<name>v2x</name>
<version>local</version>
<description>
Apollo v2x module.
</description>
<maintainer email="apollo-support@baidu.com">Apollo</maintainer>
<license>Apache License 2.0</license>
<url type="website">https://www.apollo.auto/</url>
<url type="repository">https://github.com/ApolloAuto/apollo</url>
<url type="bugtracker">https://github.com/ApolloAuto/apollo/issues</url>
<type>module</type>
<src_path url="https://github.com/ApolloAuto/apollo">//modules/v2x</src_path>
<depend type="binary" repo_name="cyber">cyber-dev</depend>
<depend type="binary" repo_name="common" lib_names="common">common-dev</depend>
<depend repo_name="common-msgs" lib_names="common-msgs">common-msgs-dev</depend>
<depend>bazel-extend-tools-dev</depend>
<depend type="binary" repo_name="map" lib_names="map">map-dev</depend>
<depend type="binary" repo_name="perception" lib_names="perception">perception-dev</depend>
<depend repo_name="com_github_gflags_gflags" lib_names="gflags">3rd-gflags-dev</depend>
<depend repo_name="com_google_googletest" lib_names="gtest,gtest_main">3rd-gtest-dev</depend>
<depend repo_name="boost">3rd-boost-dev</depend>
<depend repo_name="com_google_absl" lib_names="absl">3rd-absl-dev</depend>
<depend repo_name="eigen">3rd-eigen3-dev</depend>
</package>
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/v2x/v2x.BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "v2x",
includes = ["include"],
hdrs = glob(["include/**/*.h"]),
srcs = glob(["lib/**/*.so*"]),
include_prefix = "modules/v2x",
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/v2x/BUILD
|
load("//tools/install:install.bzl", "install", "install_files", "install_src_files")
package(default_visibility = ["//visibility:public"])
filegroup(
name = "v2x_testdata",
srcs = glob(["fusion/test_data/*"]),
)
install(
name = "testdata",
data = [
":v2x_testdata"
],
data_dest = "v2x/addition_data"
)
install(
name = "install",
data_dest = "v2x",
data = [
":runtime_data",
":cyberfile.xml",
":v2x.BUILD",
],
deps = [
"//modules/v2x/fusion/apps:install",
":pb_hdrs",
"//modules/v2x/v2x_proxy/app:install",
"testdata",
"//modules/v2x/proto:py_pb_v2x"
],
)
install(
name = "pb_hdrs",
data_dest = "v2x/include",
data = [
"//modules/v2x/proto:fusion_params_cc_proto",
"//modules/v2x/proto:v2x_car_status_cc_proto",
"//modules/v2x/proto:v2x_junction_cc_proto",
"//modules/v2x/proto:v2x_monitor_cc_proto",
"//modules/v2x/proto:v2x_obstacles_cc_proto",
"//modules/v2x/proto:v2x_obu_rsi_cc_proto",
"//modules/v2x/proto:v2x_obu_traffic_light_cc_proto",
"//modules/v2x/proto:v2x_rsi_cc_proto",
"//modules/v2x/proto:v2x_service_car_to_obu_cc_proto",
"//modules/v2x/proto:v2x_service_obu_to_car_cc_proto",
"//modules/v2x/proto:v2x_traffic_light_policy_cc_proto",
],
)
install_src_files(
name = "install_src",
deps = [
":install_v2x_src",
":install_v2x_hdrs"
],
)
install_src_files(
name = "install_v2x_src",
src_dir = ["."],
dest = "v2x/src",
filter = "*",
)
install_src_files(
name = "install_v2x_hdrs",
src_dir = ["."],
dest = "v2x/include",
filter = "*.h",
)
filegroup(
name = "runtime_data",
srcs = glob([
"conf/*.conf",
"dag/*.dag",
"data/**",
"launch/*.launch",
"fusion/test_data/**",
]),
)
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_params.pt
|
score_params {
prob_scale: 0.125
max_match_distance: 10
min_score: 0
use_mahalanobis_distance: true
check_type: true
confidence_level: C975P
}
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/benchmark
|
5 3 10 20 0
5 3 20 20 0
5 5 40 20 0
5 3 40 28 0
5 5 40 40 0
5 3 50 30 0
5 3 50 50 0
5 3 52 58 0
5 3 52 80 0
5 3 62 60 0
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_object1
|
5 3 0.9 9.31946521 18.30961269 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 3 0.92 19.89205768 19.74458419 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 3 0.9 40.86857973 29.44662098 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 4 0.2 48.96013459 30.90766418 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 3 0.9 51.71806427 48.35927642 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 3 0.9 53.62918569 57.52490467 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 3 0.9 52.26166017 81.807556 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
5 5 0.1 60.41045885 59.87098393 0 1.87197597 -0.43041365 0 -0.43041365 2.70802403 0 0 0 1
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/app_config.pt
|
input {
input_type: OLD
seq: 0
channel_name: "/perception/obstacles_old"
}
input {
input_type: CAMERA
seq: 1
channel_name: "/perception/obstacles_camera1"
}
input {
input_type: CAMERA
seq: 2
channel_name: "/perception/obstacles_camera2"
}
input {
input_type: CAMERA
seq: 3
channel_name: "/perception/obstacles_camera3"
}
input {
input_type: CAMERA
seq: 4
channel_name: "/perception/obstacles_camera4"
}
input {
input_type: CAMERA
seq: 5
channel_name: "/perception/obstacles_camera5"
}
input {
input_type: CAMERA
seq: 6
channel_name: "/perception/obstacles_camera6"
}
input {
input_type: CAMERA
seq: 7
channel_name: "/perception/obstacles_camera7"
}
input {
input_type: CAMERA
seq: 8
channel_name: "/perception/obstacles_camera8"
}
output_name: "/perception/obstacles"
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_params_wrong.pt
|
score_params {
prob_scales: 0.125
max_match_distance: 10
min_score: 0
use_mahalanobis_distance: true
check_type: true
}
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_object2
|
5 3 0.9 11.61865708 18.75230918 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.9 21.48883758 17.21299772 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.1 41.3889516 19.32466078 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.9 42.67292524 27.95346616 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.9 50.4440022 29.66052762 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.9 49.87589212 50.78223584 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
5 3 0.9 61.7858522 61.33488594 0 1.51751643 -0.49272486 0 -0.49272486 1.68748357 0 0 0 1
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_object3
|
5 3 0.9 7.51697628 20.11302683 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
5 3 0.9 18.76581442 20.3855129 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
5 3 0.1 40.26919145 39.59741714 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
5 3 0.9 54.46195886 30.55647023 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
5 3 0.9 51.48225631 58.84663973 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
5 3 0.9 51.05921321 77.69595062 0 4.80338629 -0.36491583 0 -0.36491583 1.20301371 0 0 0 1
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/test_data/fusion_object4
|
5 3 0.9 19.45528984 20.64674959 0 1.89160066 1.5809713 0 1.5809713 3.12089934 0 0 0 1
5 3 0.1 40.27277858 27.25332916 0 1.89160066 1.5809713 0 1.5809713 3.12089934 0 0 0 1
5 5 0.1 48.94089065 29.8692135 0 1.89160066 1.5809713 0 1.5809713 3.12089934 0 0 0 1
5 3 0.9 51.67702261 79.53939934 0 1.89160066 1.5809713 0 1.5809713 3.12089934 0 0 0 1
5 3 0.9 60.15997698 59.60247437 0 1.89160066 1.5809713 0 1.5809713 3.12089934 0 0 0 1
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/fusion.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <unistd.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <Eigen/Core>
#include "modules/v2x/fusion/configs/ft_config_manager.h"
#include "modules/v2x/fusion/libs/common/v2x_object.h"
#include "modules/v2x/fusion/libs/fusion/km.h"
namespace apollo {
namespace v2x {
namespace ft {
class Fusion {
public:
Fusion();
~Fusion() {}
bool Proc(const std::vector<std::vector<base::Object>> &input_objectlists,
double timestamp);
bool Init();
std::vector<base::Object> &get_fused_objects() { return updated_objects_; }
std::vector<std::vector<base::Object>> &get_fusion_result() {
return fusion_result_;
}
bool CombineNewResource(
const std::vector<base::Object> &new_objects,
std::vector<base::Object> *fused_objects,
std::vector<std::vector<base::Object>> *fusion_result);
bool GetV2xFusionObjects(
const std::vector<std::vector<base::Object>> &fusion_result,
std::vector<base::Object> *fused_objects);
int DeleteRedundant(std::vector<base::Object> *objects);
private:
bool CombineNewResource(const std::vector<base::Object> &new_objects);
bool ComputeAssociateMatrix(const std::vector<base::Object> &in1_objects,
const std::vector<base::Object> &in2_objects,
Eigen::MatrixXf *association_mat);
double CheckOdistance(const base::Object &in1_ptr,
const base::Object &in2_ptr);
bool CheckDisScore(const base::Object &in1_ptr, const base::Object &in2_ptr,
double *score);
bool CheckTypeScore(const base::Object &in1_ptr, const base::Object &in2_ptr,
double *score);
bool host_vehicle_ = false;
bool zom_vehicle_ = false;
double last_timestamp_;
const double MAX_SCORE = 250000;
float m_matched_dis_limit_;
FTConfigManager *ft_config_manager_ptr_;
KMkernal km_matcher_;
fusion::ScoreParams score_params_;
std::vector<std::vector<base::Object>> fusion_result_;
std::vector<base::Object> updated_objects_;
};
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/fusion.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/libs/fusion/fusion.h"
#include <cmath>
#include <utility>
namespace apollo {
namespace v2x {
namespace ft {
Fusion::Fusion() {
ft_config_manager_ptr_ = FTConfigManager::Instance();
score_params_ = ft_config_manager_ptr_->fusion_params_.params.score_params();
switch (score_params_.confidence_level()) {
case fusion::ConfidenceLevel::C90P:
m_matched_dis_limit_ = std::sqrt(4.605);
break;
case fusion::ConfidenceLevel::C95P:
m_matched_dis_limit_ = std::sqrt(5.991);
break;
case fusion::ConfidenceLevel::C975P:
m_matched_dis_limit_ = std::sqrt(7.378);
break;
case fusion::ConfidenceLevel::C99P:
m_matched_dis_limit_ = std::sqrt(9.210);
break;
default:
break;
}
}
bool Fusion::Init() {
last_timestamp_ = -1.0;
return true;
}
bool Fusion::Proc(
const std::vector<std::vector<base::Object>> &input_objectlists,
double timestamp) {
fusion_result_.clear();
updated_objects_.clear();
for (unsigned int i = 0; i < input_objectlists.size(); ++i) {
CombineNewResource(input_objectlists[i]);
}
return true;
}
bool Fusion::CombineNewResource(const std::vector<base::Object> &new_objects) {
return CombineNewResource(new_objects, &updated_objects_, &fusion_result_);
}
bool Fusion::CombineNewResource(
const std::vector<base::Object> &new_objects,
std::vector<base::Object> *fused_objects,
std::vector<std::vector<base::Object>> *fusion_result) {
if (new_objects.empty()) {
return false;
}
if (fused_objects->size() < 1) {
fused_objects->assign(new_objects.begin(), new_objects.end());
for (unsigned int j = 0; j < new_objects.size(); ++j) {
std::vector<base::Object> matched_objects;
matched_objects.push_back(new_objects[j]);
fusion_result->push_back(matched_objects);
}
return true;
}
int u_num = fused_objects->size();
int v_num = new_objects.size();
Eigen::MatrixXf association_mat(u_num, v_num);
ComputeAssociateMatrix(*fused_objects, new_objects, &association_mat);
std::vector<std::pair<int, int>> match_cps;
if (u_num > v_num) {
km_matcher_.GetKMResult(association_mat.transpose(), &match_cps, true);
} else {
km_matcher_.GetKMResult(association_mat, &match_cps, false);
}
for (auto it = match_cps.begin(); it != match_cps.end(); it++) {
if (it->second != -1) {
if (it->first == -1) {
fused_objects->push_back(new_objects[it->second]);
std::vector<base::Object> matched_objects;
matched_objects.push_back(fused_objects->back());
fusion_result->push_back(matched_objects);
} else {
(*fusion_result)[it->first].push_back(new_objects[it->second]);
}
}
}
return true;
}
bool Fusion::GetV2xFusionObjects(
const std::vector<std::vector<base::Object>> &fusion_result,
std::vector<base::Object> *fused_objects) {
for (const auto &objects : fusion_result) {
if (objects.size() == 1) {
fused_objects->push_back(objects.at(0));
if (objects.at(0).frame_id == "V2X") {
fused_objects->back().v2x_type = base::V2xType::BLIND_ZONE;
} else {
fused_objects->back().v2x_type = base::V2xType::UNKNOWN;
}
} else {
fused_objects->push_back(objects.at(0));
host_vehicle_ = false;
zom_vehicle_ = false;
for (const auto &object : objects) {
if (object.v2x_type == base::V2xType::HOST_VEHICLE) {
host_vehicle_ = true;
} else if (object.v2x_type == base::V2xType::ZOMBIES_CAR) {
zom_vehicle_ = true;
}
}
if (zom_vehicle_ == true) {
fused_objects->back().v2x_type = base::V2xType::ZOMBIES_CAR;
}
if (host_vehicle_ == true) {
fused_objects->back().v2x_type = base::V2xType::HOST_VEHICLE;
}
}
}
return true;
}
double Fusion::CheckOdistance(const base::Object &in1_ptr,
const base::Object &in2_ptr) {
double xi = in1_ptr.position.x();
double yi = in1_ptr.position.y();
double xj = in2_ptr.position.x();
double yj = in2_ptr.position.y();
double distance = std::hypot(xi - xj, yi - yj);
return distance;
}
bool Fusion::CheckDisScore(const base::Object &in1_ptr,
const base::Object &in2_ptr, double *score) {
double dis = CheckOdistance(in1_ptr, in2_ptr);
*score = 2.5 * std::max(0.0, score_params_.max_match_distance() - dis);
return true;
}
bool Fusion::CheckTypeScore(const base::Object &in1_ptr,
const base::Object &in2_ptr, double *score) {
double same_prob = 0;
if (in1_ptr.sub_type == in2_ptr.sub_type) {
same_prob =
1 - (1 - in1_ptr.sub_type_probs[0]) * (1 - in2_ptr.sub_type_probs[0]);
} else if (in1_ptr.type == in2_ptr.type ||
in1_ptr.type == v2x::ft::base::ObjectType::UNKNOWN ||
in2_ptr.type == v2x::ft::base::ObjectType::UNKNOWN) {
same_prob =
(1 - in1_ptr.sub_type_probs.at(0)) * in2_ptr.sub_type_probs.at(0) +
(1 - in2_ptr.sub_type_probs.at(0)) * in1_ptr.sub_type_probs.at(0);
same_prob *= score_params_.prob_scale();
}
*score *= same_prob;
return true;
}
bool Fusion::ComputeAssociateMatrix(
const std::vector<base::Object> &in1_objects, // fused
const std::vector<base::Object> &in2_objects, // new
Eigen::MatrixXf *association_mat) {
for (unsigned int i = 0; i < in1_objects.size(); ++i) {
for (unsigned int j = 0; j < in2_objects.size(); ++j) {
const base::Object &obj1_ptr = in1_objects[i];
const base::Object &obj2_ptr = in2_objects[j];
double score = 0;
if (!CheckDisScore(obj1_ptr, obj2_ptr, &score)) {
AERROR << "V2X Fusion: check dis score failed";
}
if (score_params_.check_type() &&
!CheckTypeScore(obj1_ptr, obj2_ptr, &score)) {
AERROR << "V2X Fusion: check type failed";
}
(*association_mat)(i, j) =
(score >= score_params_.min_score()) ? score : 0;
}
}
return true;
}
int Fusion::DeleteRedundant(std::vector<base::Object> *objects) {
std::vector<unsigned int> to_be_deleted;
for (unsigned int i = 0; i < objects->size(); ++i) {
for (unsigned int j = i + 1; j < objects->size(); ++j) {
double distance = CheckOdistance(objects->at(i), objects->at(j));
if (distance < 1) {
to_be_deleted.push_back(j);
}
}
}
for (auto iter = to_be_deleted.rbegin(); iter != to_be_deleted.rend();
++iter) {
objects->erase(objects->begin() + *iter);
}
return to_be_deleted.size();
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/test_tools.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "modules/v2x/fusion/libs/common/v2x_object.h"
namespace apollo {
namespace v2x {
namespace ft {
bool LoadData(const std::string& file, std::vector<base::Object>* objects,
const std::string& frame_id) {
std::fstream fin;
fin.open(file.c_str(), std::ios::in);
if (!fin) {
return false;
}
std::string line;
while (getline(fin, line)) {
std::istringstream iss(line);
float sub_type_probs, x, y, z, xx, xy, xz, yx, yy, yz, zx, zy, zz;
Eigen::Vector3d pos;
Eigen::Matrix3d var;
int type, sub_type;
iss >> type >> sub_type >> sub_type_probs >> x >> y >> z >> xx >> xy >>
xz >> yx >> yy >> yz >> zx >> zy >> zz;
pos << x, y, z;
var << xx, xy, xz, yx, yy, yz, zx, zy, zz;
base::Object obj;
obj.type = base::ObjectType::VEHICLE;
Eigen::Vector3d car_size, bus_size, van_size;
Eigen::Matrix3d id_var;
car_size << 4.2, 2.0, 1.8;
bus_size << 12, 2.2, 3;
van_size << 4.5, 2.1, 2;
id_var << 1, 0, 0, 0, 1, 0, 0, 0, 1;
switch (sub_type) {
case 3:
obj.sub_type = base::ObjectSubType::CAR;
obj.size.Set(car_size, id_var);
break;
case 4:
obj.sub_type = base::ObjectSubType::VAN;
obj.size.Set(van_size, id_var);
break;
case 5:
obj.sub_type = base::ObjectSubType::BUS;
obj.size.Set(bus_size, id_var);
break;
default:
break;
}
obj.sensor_type = base::SensorType::MONOCULAR_CAMERA;
obj.frame_id = frame_id;
obj.position.Set(pos, var);
obj.theta.Set(0, 1);
obj.type_probs.push_back(0.9f);
obj.sub_type_probs.push_back(sub_type_probs);
objects->push_back(obj);
}
return true;
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "fusion",
srcs = ["fusion.cc"],
hdrs = ["fusion.h"],
copts = ['-DMODULE_NAME=\\"v2x_fusion\\"'],
deps = [
":km",
"//modules/v2x/fusion/configs:ft_config_manager",
"//modules/v2x/fusion/libs/common:v2x_object",
"@eigen",
],
)
cc_library(
name = "km",
hdrs = ["km.h"],
deps = [
"@eigen",
],
)
cc_library(
name = "test_tools",
hdrs = ["test_tools.h"],
deps = [
"//modules/v2x/fusion/libs/common:v2x_object",
],
)
cc_test(
name = "fusion_test",
size = "small",
srcs = ["fusion_test.cc"],
deps = [
":fusion",
":test_tools",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "km_test",
size = "small",
srcs = ["km_test.cc"],
deps = [
":km",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/km_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/libs/fusion/km.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
namespace ft {
TEST(KMkernal, get_km_result) {
KMkernal km_matcher;
Eigen::MatrixXf association_mat(5, 4);
association_mat << 50, 34, 0, 0, 10, 0, 17, 0, 0, 31, 18, 10, 0, 0, 8, 17, 0,
0, 0, 2;
std::vector<std::pair<int, int>> match_cps;
EXPECT_FALSE(km_matcher.GetKMResult(association_mat, &match_cps));
EXPECT_TRUE(
km_matcher.GetKMResult(association_mat.transpose(), &match_cps, true));
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/fusion_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/libs/fusion/fusion.h"
#include <fstream>
#include <iostream>
#include "gtest/gtest.h"
#include "modules/v2x/fusion/libs/fusion/test_tools.h"
namespace apollo {
namespace v2x {
namespace ft {
TEST(Fusion, get_km_result) {
Fusion fusion;
std::vector<base::Object> fused_objects;
std::vector<std::vector<base::Object>> fusion_result;
std::vector<base::Object> objects1;
std::vector<base::Object> objects2;
std::vector<base::Object> objects3;
std::vector<base::Object> objects4;
EXPECT_FALSE(
fusion.CombineNewResource(objects1, &fused_objects, &fusion_result));
LoadData("/apollo/modules/v2x/fusion/test_data/fusion_object1", &objects1,
"camera1");
LoadData("/apollo/modules/v2x/fusion/test_data/fusion_object2", &objects2,
"camera2");
LoadData("/apollo/modules/v2x/fusion/test_data/fusion_object3", &objects3,
"camera3");
LoadData("/apollo/modules/v2x/fusion/test_data/fusion_object4", &objects4,
"camera4");
EXPECT_TRUE(
fusion.CombineNewResource(objects1, &fused_objects, &fusion_result));
EXPECT_TRUE(
fusion.CombineNewResource(objects2, &fused_objects, &fusion_result));
EXPECT_TRUE(
fusion.CombineNewResource(objects3, &fused_objects, &fusion_result));
EXPECT_TRUE(
fusion.CombineNewResource(objects4, &fused_objects, &fusion_result));
EXPECT_GE(fused_objects.size(), 9);
EXPECT_LE(fused_objects.size(), 12);
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/fusion/km.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <unistd.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include <Eigen/Core>
#define USR_INF 999999999999
namespace apollo {
namespace v2x {
namespace ft {
class KMkernal {
public:
KMkernal() = default;
~KMkernal() = default;
template <typename T>
bool GetKMResult(const T& association_mat,
std::vector<std::pair<int, int>>* match_cps,
bool need_reverse = false);
private:
int u_size_;
int v_size_;
double* ex_u_;
double* ex_v_;
int* v_matched_;
double* v_slack_;
std::set<int> used_u_;
std::set<int> used_v_;
template <typename T>
bool FindCP(const T& mat, int i);
};
template <typename T>
bool KMkernal::GetKMResult(const T& association_mat,
std::vector<std::pair<int, int>>* match_cps,
bool need_reverse) {
match_cps->clear();
u_size_ = association_mat.rows();
v_size_ = association_mat.cols();
if (u_size_ > v_size_) return false;
ex_u_ = new double[u_size_];
ex_v_ = new double[v_size_];
v_matched_ = new int[v_size_];
std::fill(v_matched_, v_matched_ + v_size_, -1);
memset(ex_v_, 0, v_size_ * sizeof(double));
for (int i = 0; i < u_size_; ++i) {
ex_u_[i] = association_mat(i, 0);
for (int j = 1; j < v_size_; ++j) {
ex_u_[i] = std::max(static_cast<float>(ex_u_[i]), association_mat(i, j));
}
}
for (int i = 0; i < u_size_; ++i) {
if (ex_u_[i] <= 0) {
if (need_reverse)
match_cps->push_back(std::make_pair(-1, i));
else
match_cps->push_back(std::make_pair(i, -1));
continue;
}
v_slack_ = new double[v_size_];
std::fill(v_slack_, v_slack_ + v_size_, USR_INF);
while (1) {
used_u_.clear();
used_v_.clear();
if (FindCP(association_mat, i)) break;
double d = USR_INF;
for (int j = 0; j < v_size_; ++j)
if (used_v_.find(j) == used_v_.end()) d = std::min(d, v_slack_[j]);
for (auto it = used_u_.begin(); it != used_u_.end(); it++) {
ex_u_[*it] -= d;
}
for (int j = 0; j < v_size_; ++j) {
if (used_v_.find(j) != used_v_.end())
ex_v_[j] += d;
else
v_slack_[j] -= d;
}
}
delete[] v_slack_;
}
if (need_reverse) {
for (int j = 0; j < v_size_; ++j) {
if (v_matched_[j] == -1) {
match_cps->push_back(std::make_pair(j, -1));
} else if (association_mat(v_matched_[j], j) > 0) {
match_cps->push_back(std::make_pair(j, v_matched_[j]));
} else {
match_cps->push_back(std::make_pair(-1, v_matched_[j]));
match_cps->push_back(std::make_pair(j, -1));
}
}
} else {
for (int j = 0; j < v_size_; ++j) {
if (v_matched_[j] == -1) {
match_cps->push_back(std::make_pair(-1, j));
} else if (association_mat(v_matched_[j], j) > 0) {
match_cps->push_back(std::make_pair(v_matched_[j], j));
} else {
match_cps->push_back(std::make_pair(v_matched_[j], -1));
match_cps->push_back(std::make_pair(-1, j));
}
}
}
delete[] ex_u_;
delete[] ex_v_;
delete[] v_matched_;
return true;
}
template <typename T>
bool KMkernal::FindCP(const T& mat, int i) {
used_u_.insert(i);
for (int j = 0; j < v_size_; ++j) {
if (used_v_.find(j) != used_v_.end()) {
continue;
}
double gap = ex_u_[i] + ex_v_[j] - mat(i, j);
if (gap <= 0) {
// res = 0;
used_v_.insert(j);
bool match_success = v_matched_[j] == -1 || FindCP(mat, v_matched_[j]);
if (match_success) {
v_matched_[j] = i;
return true;
}
} else {
v_slack_[j] = std::min(v_slack_[j], gap);
}
}
return false;
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/common/v2x_object.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <memory>
#include <string>
#include <vector>
#include <Eigen/Core>
#include "absl/strings/str_cat.h"
#include "modules/perception/base/object_supplement.h"
#include "modules/perception/base/object_types.h"
#include "modules/perception/base/sensor_meta.h"
namespace apollo {
namespace v2x {
namespace ft {
namespace base {
using apollo::perception::base::CameraObjectSupplement;
using apollo::perception::base::FusionObjectSupplement;
using apollo::perception::base::ObjectSubType;
using apollo::perception::base::ObjectType;
using apollo::perception::base::SensorType;
enum class V2xType {
UNKNOWN = 0,
ZOMBIES_CAR = 1,
BLIND_ZONE = 2,
HOST_VEHICLE = 13,
};
enum class MessageType {
UNKNOWN_MESSAGE_TYPE = -1,
ROADSIDE = 0,
VEHICLE = 1,
};
// Value and Variance
template <typename Val, typename Var>
class Info {
public:
Info() = default;
Info(Val val, Var var) {
value_ = val;
variance_ = var;
}
~Info() = default;
// Info(const Info &) = delete;
Info(const Info &rhs) {
value_ = rhs.value_;
variance_ = rhs.variance_;
}
// Info &operator=(const Info &) = delete;
Info &operator=(const Info &rhs) {
value_ = rhs.value_;
variance_ = rhs.variance_;
return *this;
}
void Set(Val value, Var variance) {
value_ = value;
variance_ = variance;
}
Val Value() const { return value_; }
Var Variance() const { return variance_; }
protected:
Val value_ = {};
Var variance_ = {};
};
class Info3f : public Info<Eigen::Vector3f, Eigen::Matrix3f> {
public:
Info3f() {
value_.setZero();
variance_.setZero();
}
~Info3f() = default;
float x() const { return value_(0); }
float y() const { return value_(1); }
float z() const { return value_(2); }
float length() const { return value_(0); }
float width() const { return value_(1); }
float height() const { return value_(2); }
};
class Info3d : public Info<Eigen::Vector3d, Eigen::Matrix3d> {
public:
double x() const { return value_(0); }
double y() const { return value_(1); }
double z() const { return value_(2); }
double length() const { return value_(0); }
double width() const { return value_(1); }
double height() const { return value_(2); }
};
struct alignas(16) Object {
typedef Info<bool, float> Infob;
typedef Info<float, float> Infof;
typedef Info<double, double> Infod;
typedef Info<Eigen::Vector2f, Eigen::Matrix2f> Info2f;
typedef Info<Eigen::Vector2d, Eigen::Matrix2d> Info2d;
typedef Eigen::Vector2f Point2f;
typedef Eigen::Vector3f Point3f;
Object() : is_temporary_lost(false, 0.0) {}
~Object() = default;
Object(const Object &) = default;
Object &operator=(const Object &) = default;
bool operator<(const Object &rhs) const { return timestamp < rhs.timestamp; }
bool operator>(const Object &rhs) const { return timestamp > rhs.timestamp; }
bool operator==(const Object &rhs) const {
return timestamp == rhs.timestamp;
}
std::string ToString() const;
void Reset();
// camera, lidar, radar and others
SensorType sensor_type = SensorType::UNKNOWN_SENSOR_TYPE;
// ROADSIDE
MessageType message_type = MessageType::UNKNOWN_MESSAGE_TYPE;
// @brief sensor-specific object supplements, optional
CameraObjectSupplement camera_supplement;
FusionObjectSupplement fusion_supplement;
// message timestamp
double timestamp = 0.0;
// original sensor timestamp
double sensor_timestamp = 0.0;
// @brief age of the tracked object, required
double tracking_time = 0.0;
// @brief timestamp of latest measurement, required
double latest_tracked_time = 0.0;
std::string frame_id = "";
// @brief track id, required
int track_id = -1;
// @breif object id per frame, required
int global_id = -1;
// @brief center position of the boundingbox (x, y, z), required
Info3d position;
// @brief anchor point, required
Info3d anchor_point;
// 0-2Pi from east
Infod theta;
// @brief theta variance, required
Infod theta_variance;
// @brief main direction of the object, required
Info3d direction;
/* @brief size = [length, width, height] of boundingbox
length is the size of the main direction, required
*/
Info3d size;
// @brief convex hull of the object, required
// Point3f polygon;
// @brief object type, required
ObjectType type = ObjectType::UNKNOWN;
V2xType v2x_type = V2xType::UNKNOWN;
// @brief type variance, required
double type_variance = 1.0;
// @brief probability for each type, required
std::vector<float> type_probs;
// @brief object sub-type, optional
ObjectSubType sub_type = ObjectSubType::UNKNOWN;
// @brief probability for each sub-type, optional
std::vector<float> sub_type_probs;
std::vector<std::vector<Info3d>> tentacles;
std::vector<Info3d> polygon;
// tracking information
// @brief the variance of tracked
Infod track_variance;
// @brief velocity of the object, required
Info3d velocity;
// @brief acceleration of the object, required
Info3d acceleration;
// @brief motion state of the tracked object, required
Infob is_stationary;
Infob is_temporary_lost;
std::string DebugString() const {
return absl::StrCat("id: ", track_id, ", ", //
"time: ", timestamp, ", ", //
"sensor type: ", sensor_type, ", ", //
"x: ", position.x(), ", ", //
"y: ", position.y(), ", ", //
"vx: ", velocity.x(), ", ", //
"vy: ", velocity.y(), ", ", //
"yaw: ", theta.Value());
}
};
typedef std::shared_ptr<Object> ObjectPtr;
typedef std::shared_ptr<const Object> ObjectConstPtr;
struct alignas(16) ObjectList {
ObjectList() = default;
~ObjectList() = default;
ObjectList(const ObjectList &) = default;
ObjectList &operator=(const ObjectList &) = default;
bool operator<(const ObjectList &rhs) const {
return timestamp < rhs.timestamp;
}
bool operator>(const ObjectList &rhs) const {
return timestamp > rhs.timestamp;
}
bool operator==(const ObjectList &rhs) const {
return timestamp == rhs.timestamp;
}
SensorType sensor_type;
// @brief sensor-specific object supplements, optional
CameraObjectSupplement camera_supplement;
// LidarObjectSupplement lidar_supplement;
// RadarObjectSupplement radar_supplement;
FusionObjectSupplement fusion_supplement;
// message timestamp
double timestamp = 0.0;
// original sensor timestamp
double sensor_timestamp = 0.0;
// @brief age of the tracked object, require
std::string frame_id = "";
std::vector<ObjectPtr> objects;
};
typedef std::shared_ptr<ObjectList> ObjectListPtr;
typedef std::shared_ptr<const ObjectList> ObjectListConstPtr;
} // namespace base
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/common/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "v2x_object",
hdrs = [
"v2x_object.h",
],
deps = [
"//modules/perception/base:base_type",
"//modules/perception/base:box",
"//modules/perception/base:object",
"@com_google_absl//:absl",
],
)
cc_test(
name = "v2x_object_test",
size = "small",
srcs = ["v2x_object_test.cc"],
deps = [
":v2x_object",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/libs
|
apollo_public_repos/apollo/modules/v2x/fusion/libs/common/v2x_object_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/libs/common/v2x_object.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
namespace ft {
namespace base {
TEST(Object, operators) {
std::vector<Object> objects;
Object object;
object.timestamp = 4.1;
object.track_id = 0;
objects.push_back(object);
object.timestamp = 3.2;
object.track_id = 1;
objects.push_back(object);
object.timestamp = 2.3;
object.track_id = 2;
objects.push_back(object);
object.timestamp = 1.4;
object.track_id = 3;
objects.push_back(object);
sort(objects.begin(), objects.end(), std::less<Object>());
EXPECT_EQ(objects.at(0).track_id, 3);
}
} // namespace base
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/ft_config_manager_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/configs/ft_config_manager.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
namespace ft {
TEST(FTConfigManager, read_and_write) {
FTConfigManager* ft_config_manager_ptr = FTConfigManager::Instance();
auto& fusion_params = ft_config_manager_ptr->fusion_params_.params;
EXPECT_FALSE(fusion_params.score_params().check_type());
EXPECT_EQ(fusion_params.score_params().prob_scale(), 0.125);
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/fusion_tracker_gflags.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* File: fusion_gflags.cpp
* Brief: Global flags definition.
*/
#include "modules/v2x/fusion/configs/fusion_tracker_gflags.h"
namespace apollo {
namespace v2x {
namespace ft {
// config manager
DEFINE_string(config_path, "/apollo/modules/v2x/data",
"ADU shared data path, including maps, routings...");
DEFINE_string(v2x_module_name, "v2x_fusion", "name");
DEFINE_string(v2x_fusion_obstacles_topic, "/apollo/msf/obstacles",
"perception obstacle topic name");
DEFINE_bool(use_v2x, false, "use v2x");
// fusion
DEFINE_string(fusion_conf_file, "fusion_params.pt", "the roi conf path");
// app
DEFINE_string(app_conf_file, "app_config.pt", "the inputs conf path");
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/ft_config_manager.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/configs/ft_config_manager.h"
namespace apollo {
namespace v2x {
namespace ft {
FTConfigManager::FTConfigManager() {}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/ft_config_manager.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <map>
#include <string>
#include <boost/function.hpp>
#include "modules/v2x/proto/fusion_params.pb.h"
#include "cyber/cyber.h"
#include "modules/v2x/fusion/configs/fusion_tracker_gflags.h"
#define PLUGIN_PARAMS(classname, conf_file, prototype) \
class classname { \
public: \
classname() { \
file_path_ = FLAGS_config_path + "/" + conf_file; \
cyber::common::GetProtoFromFile(file_path_, ¶ms); \
} \
~classname() { cyber::common::SetProtoToASCIIFile(params, file_path_); } \
prototype params; \
\
private: \
std::string file_path_; \
};
namespace apollo {
namespace v2x {
namespace ft {
PLUGIN_PARAMS(FusionParams, FLAGS_fusion_conf_file, fusion::FusionParams)
class FTConfigManager {
public:
DECLARE_SINGLETON(FTConfigManager)
public:
FusionParams fusion_params_;
};
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/fusion_tracker_gflags.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* File: fusion_gflags.h
* Brief: Global flags definition.
*/
#pragma once
#include "gflags/gflags.h"
namespace apollo {
namespace v2x {
namespace ft {
// config manager
DECLARE_string(config_path);
DECLARE_string(v2x_module_name);
DECLARE_string(v2x_fusion_obstacles_topic);
DECLARE_bool(use_v2x);
// fusion
DECLARE_string(fusion_conf_file);
// app
DECLARE_string(app_conf_file);
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/configs/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "fusion_tracker_gflags",
srcs = ["fusion_tracker_gflags.cc"],
hdrs = ["fusion_tracker_gflags.h"],
deps = [
"@com_github_gflags_gflags//:gflags",
],
)
cc_library(
name = "ft_config_manager",
srcs = ["ft_config_manager.cc"],
hdrs = ["ft_config_manager.h"],
deps = [
":fusion_tracker_gflags",
"//cyber",
"//modules/v2x/proto:fusion_params_cc_proto",
"@boost",
],
)
cc_test(
name = "ft_config_manager_test",
size = "small",
srcs = ["ft_config_manager_test.cc"],
deps = [
":ft_config_manager",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/v2x_fusion_component_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/apps/v2x_fusion_component.h"
#include "gtest/gtest.h"
#include "cyber/init.h"
namespace apollo {
namespace v2x {
namespace ft {
TEST(V2XFusionComponentTest, Simple) {
cyber::Init("v2x_fusion_component_test");
V2XFusionComponent v2x_fusion_component;
EXPECT_EQ(v2x_fusion_component.Name(), "v2x_fusion");
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/v2x_fusion_component.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file
*/
#include <cmath>
#include <condition_variable>
#include <limits>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include "cyber/component/component.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/v2x/fusion/apps/common/trans_tools.h"
#include "modules/v2x/fusion/configs/ft_config_manager.h"
#include "modules/v2x/fusion/configs/fusion_tracker_gflags.h"
#include "modules/v2x/fusion/libs/fusion/fusion.h"
namespace apollo {
namespace v2x {
namespace ft {
class V2XFusionComponent
: public apollo::cyber::Component<PerceptionObstacles> {
public:
~V2XFusionComponent();
std::string Name() const;
bool Init() override;
bool Proc(const std::shared_ptr<PerceptionObstacles>& perception_obstacles)
override;
private:
bool V2XMessageFusionProcess(
const std::shared_ptr<PerceptionObstacles>& perception_obstacles);
void SerializeMsg(const std::vector<base::Object>& objects,
std::shared_ptr<PerceptionObstacles> obstacles);
Fusion fusion_;
std::shared_ptr<apollo::cyber::Reader<LocalizationEstimate>>
localization_reader_;
std::shared_ptr<apollo::cyber::Reader<V2XObstacles>> v2x_obstacles_reader_;
std::shared_ptr<apollo::cyber::Writer<PerceptionObstacles>>
perception_fusion_obstacles_writer_;
apollo::common::Header header_;
};
CYBER_REGISTER_COMPONENT(V2XFusionComponent)
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//tools/install:install.bzl", "install")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
install(
name = "install",
library_dest = "v2x/lib/fusion/apps",
targets = [
":libv2x_fusion_component.so",
]
)
cc_library(
name = "v2x_fusion_component_lib",
srcs = ["v2x_fusion_component.cc"],
hdrs = ["v2x_fusion_component.h"],
copts = [
"-DMODULE_NAME=\\\"v2x_fusion\\\"",
],
deps = [
"//cyber",
"//modules/common/adapters:adapter_gflags",
"//modules/v2x/fusion/apps/common:trans_tools",
"//modules/v2x/fusion/configs:ft_config_manager",
"//modules/v2x/fusion/configs:fusion_tracker_gflags",
"//modules/v2x/fusion/libs/fusion",
],
alwayslink = True,
)
cc_binary(
name = "libv2x_fusion_component.so",
linkshared = True,
linkstatic = True,
deps = [":v2x_fusion_component_lib"],
)
cc_test(
name = "v2x_fusion_component_test",
size = "small",
srcs = ["v2x_fusion_component_test.cc"],
linkopts = [
"-lgomp",
],
deps = [
":v2x_fusion_component_lib",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/v2x_fusion_component.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/apps/v2x_fusion_component.h"
namespace apollo {
namespace v2x {
namespace ft {
V2XFusionComponent::~V2XFusionComponent() {}
std::string V2XFusionComponent::Name() const { return FLAGS_v2x_module_name; }
bool V2XFusionComponent::Init() {
v2x_obstacles_reader_ =
node_->CreateReader<V2XObstacles>(FLAGS_v2x_obstacle_topic, nullptr);
localization_reader_ = node_->CreateReader<LocalizationEstimate>(
FLAGS_localization_topic, nullptr);
perception_fusion_obstacles_writer_ =
node_->CreateWriter<PerceptionObstacles>(FLAGS_perception_obstacle_topic);
return true;
}
bool V2XFusionComponent::Proc(
const std::shared_ptr<PerceptionObstacles>& perception_obstacles) {
if (FLAGS_use_v2x) {
return V2XMessageFusionProcess(perception_obstacles);
}
perception_fusion_obstacles_writer_->Write(*perception_obstacles);
return true;
}
bool V2XFusionComponent::V2XMessageFusionProcess(
const std::shared_ptr<PerceptionObstacles>& perception_obstacles) {
// Read localization info. and call OnLocalization to update
// the PoseContainer.
localization_reader_->Observe();
auto localization_msg = localization_reader_->GetLatestObserved();
if (localization_msg == nullptr) {
AERROR << "V2X: cannot receive any localization message.";
return false;
}
base::Object hv_obj;
CarstatusPb2Object(*localization_msg, &hv_obj, "VEHICLE");
v2x_obstacles_reader_->Observe();
auto v2x_obstacles_msg = v2x_obstacles_reader_->GetLatestObserved();
if (v2x_obstacles_msg == nullptr) {
AERROR << "V2X: cannot receive any v2x obstacles message.";
perception_fusion_obstacles_writer_->Write(*perception_obstacles);
} else {
header_.CopyFrom(perception_obstacles->header());
std::vector<Object> fused_objects;
std::vector<Object> v2x_fused_objects;
std::vector<std::vector<Object>> fusion_result;
std::vector<Object> v2x_objects;
V2xPbs2Objects(*v2x_obstacles_msg, &v2x_objects, "V2X");
std::vector<Object> perception_objects;
Pbs2Objects(*perception_obstacles, &perception_objects, "VEHICLE");
perception_objects.push_back(hv_obj);
fusion_.CombineNewResource(perception_objects, &fused_objects,
&fusion_result);
fusion_.CombineNewResource(v2x_objects, &fused_objects, &fusion_result);
fusion_.GetV2xFusionObjects(fusion_result, &v2x_fused_objects);
auto output_msg = std::make_shared<PerceptionObstacles>();
SerializeMsg(v2x_fused_objects, output_msg);
perception_fusion_obstacles_writer_->Write(*output_msg);
}
return true;
}
void V2XFusionComponent::SerializeMsg(
const std::vector<base::Object>& objects,
std::shared_ptr<PerceptionObstacles> output_msg) {
static int seq_num = 0;
Objects2Pbs(objects, output_msg);
apollo::common::Header* header = output_msg->mutable_header();
header->set_timestamp_sec(apollo::cyber::Time::Now().ToSecond());
header->set_module_name("v2x_fusion");
header->set_sequence_num(seq_num++);
header->set_lidar_timestamp(header_.lidar_timestamp());
header->set_camera_timestamp(header_.camera_timestamp());
header->set_radar_timestamp(header_.radar_timestamp());
output_msg->set_error_code(apollo::common::ErrorCode::PERCEPTION_ERROR_NONE);
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/apps
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/common/ft_definitions.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <memory>
#include "modules/common_msgs/localization_msgs/localization.pb.h"
#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
#include "modules/v2x/proto/v2x_obstacles.pb.h"
#include "modules/v2x/fusion/libs/common/v2x_object.h"
namespace apollo {
namespace v2x {
namespace ft {
using apollo::localization::LocalizationEstimate;
using apollo::perception::PerceptionObstacle;
using apollo::perception::PerceptionObstacles;
using apollo::v2x::V2XObstacle;
using apollo::v2x::V2XObstacles;
using apollo::v2x::ft::base::Object;
using PerceptionObstaclesPtr = std::shared_ptr<PerceptionObstacles>;
using V2XObstaclesPtr = std::shared_ptr<V2XObstacles>;
using StatusPtr = std::shared_ptr<LocalizationEstimate>;
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/apps
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/common/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "ft_definitions",
hdrs = ["ft_definitions.h"],
deps = [
"//modules/common_msgs/localization_msgs:localization_cc_proto",
"//modules/common_msgs/perception_msgs:perception_camera_cc_proto",
"//modules/v2x/fusion/libs/common:v2x_object",
"//modules/v2x/proto:v2x_obstacles_cc_proto",
],
)
cc_library(
name = "trans_tools",
srcs = ["trans_tools.cc"],
hdrs = ["trans_tools.h"],
copts = ['-DMODULE_NAME=\\"v2x_fusion\\"'],
deps = [
":ft_definitions",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/apps
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/common/trans_tools.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <cmath>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include "modules/v2x/fusion/apps/common/ft_definitions.h"
namespace apollo {
namespace v2x {
namespace ft {
base::Object Pb2Object(const PerceptionObstacle &obstacle,
const std::string &frame_id);
void Pb2Object(const PerceptionObstacle &obstacle, base::Object *object,
const std::string &frame_id, double timestamp_object = 0.0);
void V2xPb2Object(const V2XObstacle &obstacle, base::Object *object,
const std::string &frame_id, double timestamp_object);
void CarstatusPb2Object(const LocalizationEstimate &carstatus,
base::Object *object, const std::string &frame_id);
double Pbs2Objects(const PerceptionObstacles &obstacles,
std::vector<base::Object> *objects,
const std::string &frame_id);
double V2xPbs2Objects(const V2XObstacles &obstacles,
std::vector<base::Object> *objects,
const std::string &frame_id);
PerceptionObstacle Object2Pb(const base::Object &object);
void FillObjectPolygonFromBBox3D(PerceptionObstacle *object_ptr);
void Object2Pb(const base::Object &object, PerceptionObstacle *obstacle);
void Object2V2xPb(const base::Object &object, V2XObstacle *obstacle);
void Objects2Pbs(const std::vector<base::Object> &objects,
std::shared_ptr<PerceptionObstacles> obstacles);
void Objects2V2xPbs(const std::vector<base::Object> &objects,
std::shared_ptr<V2XObstacles> obstacles);
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/fusion/apps
|
apollo_public_repos/apollo/modules/v2x/fusion/apps/common/trans_tools.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/fusion/apps/common/trans_tools.h"
#include <limits>
namespace apollo {
namespace v2x {
namespace ft {
void Pb2Object(const PerceptionObstacle &obstacle, base::Object *object,
const std::string &frame_id, double timestamp_object) {
Eigen::Vector3d value;
Eigen::Matrix3d variance;
variance.setIdentity();
object->type_probs.push_back(0.85);
object->sub_type_probs.push_back(0.85);
object->type = static_cast<base::ObjectType>(obstacle.type());
variance = variance * 1;
switch (obstacle.sub_type()) {
case PerceptionObstacle::ST_UNKNOWN:
object->sub_type = base::ObjectSubType::UNKNOWN;
variance = variance * 3;
break;
case PerceptionObstacle::ST_UNKNOWN_MOVABLE:
object->sub_type = base::ObjectSubType::UNKNOWN_MOVABLE;
variance = variance * 2;
break;
case PerceptionObstacle::ST_CAR:
object->sub_type = base::ObjectSubType::CAR;
variance = variance * 0.8;
break;
case PerceptionObstacle::ST_VAN:
object->sub_type = base::ObjectSubType::VAN;
variance = variance * 1;
break;
case PerceptionObstacle::ST_TRUCK:
object->sub_type = base::ObjectSubType::TRUCK;
variance = variance * 3;
break;
case PerceptionObstacle::ST_BUS:
object->sub_type = base::ObjectSubType::BUS;
variance = variance * 3;
break;
case PerceptionObstacle::ST_CYCLIST:
object->sub_type = base::ObjectSubType::CYCLIST;
variance = variance * 0.8;
break;
case PerceptionObstacle::ST_MOTORCYCLIST:
object->sub_type = base::ObjectSubType::MOTORCYCLIST;
variance = variance * 0.8;
break;
case PerceptionObstacle::ST_TRICYCLIST:
object->sub_type = base::ObjectSubType::TRICYCLIST;
variance = variance * 0.8;
break;
case PerceptionObstacle::ST_PEDESTRIAN:
object->sub_type = base::ObjectSubType::PEDESTRIAN;
variance = variance * 0.8;
break;
case PerceptionObstacle::ST_TRAFFICCONE:
object->sub_type = base::ObjectSubType::TRAFFICCONE;
variance = variance * 0.8;
break;
default:
break;
}
if (obstacle.has_timestamp()) {
object->timestamp = obstacle.timestamp();
} else {
object->timestamp = timestamp_object;
}
value << obstacle.position().x(), obstacle.position().y(), 0.0;
object->position.Set(value, variance);
value << obstacle.velocity().x(), obstacle.velocity().y(),
obstacle.velocity().z();
object->velocity.Set(value, variance);
object->theta.Set(obstacle.theta(), 0.5);
object->sensor_type = base::SensorType::MONOCULAR_CAMERA;
object->track_id = obstacle.id();
object->frame_id = frame_id;
variance.setIdentity();
value << obstacle.length(), obstacle.width(), obstacle.height();
object->size.Set(value, variance);
std::vector<base::Info3d> polygon_info3d;
for (auto &polygon_point : obstacle.polygon_point()) {
base::Info3d point;
value << polygon_point.x(), polygon_point.y(), polygon_point.z();
point.Set(value, variance);
polygon_info3d.push_back(point);
}
object->polygon = polygon_info3d;
}
void V2xPb2Object(const apollo::v2x::V2XObstacle &obstacle,
base::Object *object, const std::string &frame_id,
double timestamp_object) {
Pb2Object(obstacle.perception_obstacle(), object, frame_id, timestamp_object);
if (obstacle.has_v2x_info() && obstacle.v2x_info().v2x_type_size() > 0 &&
obstacle.v2x_info().v2x_type(0) ==
::apollo::v2x::V2XInformation::ZOMBIES_CAR) {
object->v2x_type = base::V2xType::ZOMBIES_CAR;
}
}
base::Object Pb2Object(const PerceptionObstacle &obstacle,
const std::string &frame_id) {
base::Object object;
Eigen::Vector3d value;
Eigen::Matrix3d variance;
variance.setIdentity();
object.timestamp = obstacle.timestamp();
// object
value << obstacle.position().x(), obstacle.position().y(),
obstacle.position().z();
object.position.Set(value, variance);
value << obstacle.velocity().x(), obstacle.velocity().y(),
obstacle.velocity().z();
object.velocity.Set(value, variance);
object.theta.Set(obstacle.theta(), 0.5);
object.sensor_type = base::SensorType::MONOCULAR_CAMERA;
object.track_id = obstacle.id();
object.frame_id = frame_id;
value << obstacle.length(), obstacle.width(), obstacle.height();
object.size.Set(value, variance);
object.type_probs.push_back(0.85);
object.sub_type_probs.push_back(0.85);
object.type = static_cast<base::ObjectType>(obstacle.type());
switch (obstacle.sub_type()) {
case PerceptionObstacle::ST_UNKNOWN:
object.sub_type = base::ObjectSubType::UNKNOWN;
break;
case PerceptionObstacle::ST_UNKNOWN_MOVABLE:
object.sub_type = base::ObjectSubType::UNKNOWN_MOVABLE;
break;
case PerceptionObstacle::ST_CAR:
object.sub_type = base::ObjectSubType::CAR;
break;
case PerceptionObstacle::ST_VAN:
object.sub_type = base::ObjectSubType::VAN;
break;
case PerceptionObstacle::ST_TRUCK:
object.sub_type = base::ObjectSubType::TRUCK;
break;
case PerceptionObstacle::ST_BUS:
object.sub_type = base::ObjectSubType::BUS;
break;
case PerceptionObstacle::ST_CYCLIST:
object.sub_type = base::ObjectSubType::CYCLIST;
break;
case PerceptionObstacle::ST_MOTORCYCLIST:
object.sub_type = base::ObjectSubType::MOTORCYCLIST;
break;
case PerceptionObstacle::ST_TRICYCLIST:
object.sub_type = base::ObjectSubType::TRICYCLIST;
break;
case PerceptionObstacle::ST_PEDESTRIAN:
object.sub_type = base::ObjectSubType::PEDESTRIAN;
break;
case PerceptionObstacle::ST_TRAFFICCONE:
object.sub_type = base::ObjectSubType::TRAFFICCONE;
break;
default:
break;
}
return object;
}
PerceptionObstacle Object2Pb(const base::Object &object) {
PerceptionObstacle obstacle;
// times
obstacle.set_timestamp(object.timestamp);
// id
obstacle.set_id(object.track_id);
// position
obstacle.mutable_position()->set_x(object.position.x());
obstacle.mutable_position()->set_y(object.position.y());
obstacle.mutable_position()->set_z(object.position.z());
// velocity
obstacle.mutable_velocity()->set_x(object.velocity.x());
obstacle.mutable_velocity()->set_y(object.velocity.y());
obstacle.mutable_velocity()->set_z(object.velocity.z());
// yaw
obstacle.set_theta(object.theta.Value());
// lwh
obstacle.set_length(object.size.length());
obstacle.set_width(object.size.width());
obstacle.set_height(object.size.height());
obstacle.set_type(static_cast<PerceptionObstacle::Type>(object.type));
switch (object.sub_type) {
case base::ObjectSubType::UNKNOWN:
obstacle.set_sub_type(PerceptionObstacle::ST_UNKNOWN);
break;
case base::ObjectSubType::UNKNOWN_MOVABLE:
obstacle.set_sub_type(PerceptionObstacle::ST_UNKNOWN_MOVABLE);
break;
case base::ObjectSubType::CAR:
obstacle.set_sub_type(PerceptionObstacle::ST_CAR);
break;
case base::ObjectSubType::VAN:
obstacle.set_sub_type(PerceptionObstacle::ST_VAN);
break;
case base::ObjectSubType::TRUCK:
obstacle.set_sub_type(PerceptionObstacle::ST_TRUCK);
break;
case base::ObjectSubType::BUS:
obstacle.set_sub_type(PerceptionObstacle::ST_BUS);
break;
case base::ObjectSubType::CYCLIST:
obstacle.set_sub_type(PerceptionObstacle::ST_CYCLIST);
break;
case base::ObjectSubType::MOTORCYCLIST:
obstacle.set_sub_type(PerceptionObstacle::ST_MOTORCYCLIST);
break;
case base::ObjectSubType::TRICYCLIST:
obstacle.set_sub_type(PerceptionObstacle::ST_TRICYCLIST);
break;
case base::ObjectSubType::PEDESTRIAN:
obstacle.set_sub_type(PerceptionObstacle::ST_PEDESTRIAN);
break;
case base::ObjectSubType::TRAFFICCONE:
obstacle.set_sub_type(PerceptionObstacle::ST_TRAFFICCONE);
break;
default:
break;
}
return obstacle;
}
void FillObjectPolygonFromBBox3D(PerceptionObstacle *object_ptr) {
struct PolygoPoint {
double x = 0.0;
double y = 0.0;
double z = 0.0;
};
if (!object_ptr) {
return;
}
const double length = object_ptr->length();
const double width = object_ptr->width();
double hl = length / 2;
double hw = width / 2;
double cos_theta = std::cos(object_ptr->theta());
double sin_theta = std::sin(object_ptr->theta());
PolygoPoint polygon[4];
polygon[0].x = hl * cos_theta - hw * sin_theta + object_ptr->position().x();
polygon[0].y = hl * sin_theta + hw * cos_theta + object_ptr->position().y();
polygon[0].z = object_ptr->position().z();
polygon[1].x = hl * cos_theta + hw * sin_theta + object_ptr->position().x();
polygon[1].y = hl * sin_theta - hw * cos_theta + object_ptr->position().y();
polygon[1].z = object_ptr->position().z();
polygon[2].x = -hl * cos_theta + hw * sin_theta + object_ptr->position().x();
polygon[2].y = -hl * sin_theta - hw * cos_theta + object_ptr->position().y();
polygon[2].z = object_ptr->position().z();
polygon[3].x = -hl * cos_theta - hw * sin_theta + object_ptr->position().x();
polygon[3].y = -hl * sin_theta + hw * cos_theta + object_ptr->position().y();
polygon[3].z = object_ptr->position().z();
for (PolygoPoint point : polygon) {
auto polygon_point = object_ptr->add_polygon_point();
polygon_point->set_x(point.x);
polygon_point->set_y(point.y);
polygon_point->set_z(point.z);
}
}
void Object2Pb(const base::Object &object, PerceptionObstacle *obstacle) {
// times
obstacle->set_timestamp(object.timestamp);
// id
obstacle->set_id(object.track_id);
// position
obstacle->mutable_position()->set_x(object.position.x());
obstacle->mutable_position()->set_y(object.position.y());
obstacle->mutable_position()->set_z(object.position.z());
// velocity
obstacle->mutable_velocity()->set_x(object.velocity.x());
obstacle->mutable_velocity()->set_y(object.velocity.y());
obstacle->mutable_velocity()->set_z(object.velocity.z());
// yaw
obstacle->set_theta(object.theta.Value());
// lwh
obstacle->set_length(object.size.length());
obstacle->set_width(object.size.width());
obstacle->set_height(object.size.height());
FillObjectPolygonFromBBox3D(obstacle);
obstacle->set_type(static_cast<PerceptionObstacle::Type>(object.type));
switch (object.sub_type) {
case base::ObjectSubType::UNKNOWN:
obstacle->set_sub_type(PerceptionObstacle::ST_UNKNOWN);
break;
case base::ObjectSubType::UNKNOWN_MOVABLE:
obstacle->set_sub_type(PerceptionObstacle::ST_UNKNOWN_MOVABLE);
break;
case base::ObjectSubType::UNKNOWN_UNMOVABLE:
obstacle->set_sub_type(PerceptionObstacle::ST_UNKNOWN_UNMOVABLE);
break;
case base::ObjectSubType::CAR:
obstacle->set_sub_type(PerceptionObstacle::ST_CAR);
break;
case base::ObjectSubType::VAN:
obstacle->set_sub_type(PerceptionObstacle::ST_VAN);
break;
case base::ObjectSubType::TRUCK:
obstacle->set_sub_type(PerceptionObstacle::ST_TRUCK);
break;
case base::ObjectSubType::BUS:
obstacle->set_sub_type(PerceptionObstacle::ST_BUS);
break;
case base::ObjectSubType::CYCLIST:
obstacle->set_sub_type(PerceptionObstacle::ST_CYCLIST);
break;
case base::ObjectSubType::MOTORCYCLIST:
obstacle->set_sub_type(PerceptionObstacle::ST_MOTORCYCLIST);
break;
case base::ObjectSubType::TRICYCLIST:
obstacle->set_sub_type(PerceptionObstacle::ST_TRICYCLIST);
break;
case base::ObjectSubType::PEDESTRIAN:
obstacle->set_sub_type(PerceptionObstacle::ST_PEDESTRIAN);
break;
case base::ObjectSubType::TRAFFICCONE:
obstacle->set_sub_type(PerceptionObstacle::ST_TRAFFICCONE);
break;
default:
break;
}
obstacle->set_source(PerceptionObstacle::HOST_VEHICLE);
if (object.v2x_type == base::V2xType::ZOMBIES_CAR) {
obstacle->mutable_v2x_info()->add_v2x_type(
::apollo::perception::V2XInformation::ZOMBIES_CAR);
obstacle->set_source(PerceptionObstacle::V2X);
}
if (object.v2x_type == base::V2xType::BLIND_ZONE) {
obstacle->mutable_v2x_info()->add_v2x_type(
::apollo::perception::V2XInformation::BLIND_ZONE);
obstacle->set_source(PerceptionObstacle::V2X);
}
}
void Object2V2xPb(const base::Object &object, V2XObstacle *obstacle) {
PerceptionObstacle perception_obstacle;
Object2Pb(object, &perception_obstacle);
obstacle->mutable_perception_obstacle()->CopyFrom(perception_obstacle);
}
double Pbs2Objects(const PerceptionObstacles &obstacles,
std::vector<base::Object> *objects,
const std::string &frame_id) {
double timestamp = std::numeric_limits<double>::max();
objects->clear();
double timestamp_object = 0.0;
if (obstacles.perception_obstacle_size() > 0 &&
obstacles.perception_obstacle(0).has_timestamp() == false) {
if (obstacles.header().has_camera_timestamp() &&
obstacles.header().camera_timestamp() > 10.0) {
timestamp_object = obstacles.header().camera_timestamp() / 1.0e9;
} else {
timestamp_object = obstacles.header().lidar_timestamp() / 1.0e9;
}
}
for (int j = 0; j < obstacles.perception_obstacle_size(); ++j) {
base::Object object;
Pb2Object(obstacles.perception_obstacle(j), &object, frame_id,
timestamp_object);
objects->push_back(object);
if (timestamp > object.timestamp) {
timestamp = object.timestamp;
}
}
return timestamp;
}
void CarstatusPb2Object(const LocalizationEstimate &carstatus,
base::Object *object, const std::string &frame_id) {
Eigen::Vector3d value;
Eigen::Matrix3d variance;
variance.setIdentity();
object->type_probs.push_back(0.85);
object->sub_type_probs.push_back(0.85);
object->type = base::ObjectType::VEHICLE;
object->sub_type = base::ObjectSubType::CAR;
object->v2x_type = base::V2xType::HOST_VEHICLE;
variance = variance * 0.8;
value << carstatus.pose().position().x(), carstatus.pose().position().y(),
0.0;
object->position.Set(value, variance);
value << carstatus.pose().linear_velocity().x(),
carstatus.pose().linear_velocity().y(),
carstatus.pose().linear_velocity().z();
object->velocity.Set(value, variance);
object->theta.Set(carstatus.pose().heading(), 0.5);
object->sensor_type = base::SensorType::MONOCULAR_CAMERA;
object->track_id = 0;
object->frame_id = frame_id;
variance.setIdentity();
value << 5.02203, 2.13135, 2.17711;
object->size.Set(value, variance);
object->timestamp = carstatus.header().timestamp_sec();
}
double V2xPbs2Objects(const V2XObstacles &obstacles,
std::vector<base::Object> *objects,
const std::string &frame_id) {
double timestamp = std::numeric_limits<double>::max();
objects->clear();
double timestamp_object = 0.0;
if (obstacles.v2x_obstacle_size() > 0 &&
obstacles.v2x_obstacle(0).perception_obstacle().has_timestamp() ==
false) {
if (obstacles.header().has_camera_timestamp()) {
timestamp_object = obstacles.header().camera_timestamp() / 1000000000.0;
} else {
timestamp_object = obstacles.header().lidar_timestamp() / 1000000000.0;
}
}
for (int j = 0; j < obstacles.v2x_obstacle_size(); ++j) {
base::Object object;
V2xPb2Object(obstacles.v2x_obstacle(j), &object, frame_id,
timestamp_object);
objects->push_back(object);
if (timestamp > object.timestamp) {
timestamp = object.timestamp;
}
}
return timestamp;
}
void Objects2Pbs(const std::vector<base::Object> &objects,
std::shared_ptr<PerceptionObstacles> obstacles) {
obstacles->mutable_perception_obstacle()->Clear();
if (objects.size() < 1) {
return;
}
// obstacles->mutable_header()->set_frame_id(objects[0].frame_id);
for (const auto &object : objects) {
if (object.v2x_type == base::V2xType::HOST_VEHICLE) {
continue;
}
PerceptionObstacle obstacle;
Object2Pb(object, &obstacle);
obstacles->add_perception_obstacle()->CopyFrom(obstacle);
}
}
void Objects2V2xPbs(const std::vector<base::Object> &objects,
std::shared_ptr<V2XObstacles> obstacles) {
obstacles->mutable_v2x_obstacle()->Clear();
if (objects.size() < 1) {
return;
}
for (const auto &object : objects) {
if (object.v2x_type == base::V2xType::HOST_VEHICLE) {
continue;
}
V2XObstacle obstacle;
Object2V2xPb(object, &obstacle);
obstacles->add_v2x_obstacle()->CopyFrom(obstacle);
}
}
} // namespace ft
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/main.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file main.cc
* @brief v2x proxy main function
*/
#include "modules/v2x/v2x_proxy/app/v2x_proxy.h"
int main(int argc, char *argv[]) {
google::ParseCommandLineFlags(&argc, &argv, true);
::apollo::cyber::Init(argv[0]);
::apollo::v2x::V2xProxy v2x_proxy;
if (!v2x_proxy.InitFlag()) {
AERROR << "Failed to initialize v2x proxy";
::apollo::cyber::Clear();
return -1;
}
::apollo::cyber::WaitForShutdown();
return 0;
}
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/utils.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file utils.h
* @brief utils for v2x_proxy
*/
#pragma once
#include <algorithm>
#include <memory>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
#include "modules/common_msgs/planning_msgs/planning.pb.h"
#include "cyber/cyber.h"
#include "modules/map/hdmap/hdmap.h"
#include "modules/map/hdmap/hdmap_common.h"
#include "modules/v2x/v2x_proxy/proto_adapter/proto_adapter.h"
namespace apollo {
namespace v2x {
const char *const kUnknownJunctionId = "unknown";
class InternalData final {
private:
static constexpr size_t kBufferSize = 40;
std::shared_ptr<OSLight> oslight_ = nullptr;
std::shared_ptr<ObuLight> obu_light_ = nullptr;
int intersection_id_ = -1;
double change_color_timestamp_ = 0.0;
int32_t *remaining_time_ = nullptr;
double *msg_timestamp_ = nullptr;
public:
InternalData();
virtual ~InternalData();
void reset();
bool TrafficLightProc(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
double distance, ::apollo::v2x::RoadTrafficLight *msg);
bool ProcTrafficlight(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const ObuLight *x2v_traffic_light,
const std::string &junction_id, bool flag_u_turn,
double distance, double check_time,
std::shared_ptr<OSLight> *os_light);
bool ProcPlanningMessage(
const ::apollo::planning::ADCTrajectory *planning_msg,
const OSLight *last_os_light,
std::shared_ptr<::apollo::perception::TrafficLightDetection> *res_light);
};
namespace utils {
bool FindAllRoadId(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const ::apollo::hdmap::LaneInfoConstPtr &start_laneinfo,
const ::apollo::hdmap::LaneInfoConstPtr &end_laneinfo,
size_t max_road_count,
std::unordered_set<std::string> *result_id_set);
bool CheckCarInSet(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const std::unordered_set<std::string> &id_set,
const ::apollo::hdmap::LaneInfoConstPtr &car_laneinfo,
size_t max_lane_count);
bool GetRsuInfo(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const OSLocation &os_location,
const std::set<std::string> &rsu_whitelist, double distance,
double max_heading_difference,
std::shared_ptr<::apollo::v2x::CarStatus> *v2x_car_status,
std::string *out_junction_id, double *out_heading);
OSLightColor GetNextColor(OSLightColor color);
void UniqueOslight(OSLight *os_light);
} // namespace utils
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/utils.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file utils.cc
* @brief utils for v2x_proxy
*/
#include "modules/v2x/v2x_proxy/app/utils.h"
#include <sstream>
#include "modules/common/math/quaternion.h"
namespace apollo {
namespace v2x {
InternalData::InternalData() {
remaining_time_ = new int32_t[kBufferSize];
msg_timestamp_ = new double[kBufferSize];
CHECK_NOTNULL(remaining_time_);
CHECK_NOTNULL(msg_timestamp_);
obu_light_ = std::make_shared<ObuLight>();
this->reset();
}
InternalData::~InternalData() {
delete[] remaining_time_;
delete[] msg_timestamp_;
}
void InternalData::reset() {
oslight_ = nullptr;
intersection_id_ = -1;
change_color_timestamp_ = 0.0;
}
bool InternalData::TrafficLightProc(
const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap, double distance,
::apollo::v2x::RoadTrafficLight *msg) {
if (nullptr == msg) {
return false;
}
if (!msg->has_gps_x_m() || !msg->has_gps_y_m()) {
AERROR << "Error::v2x traffic_light ignore, gps point is null";
return false;
}
::apollo::common::PointENU point;
point.set_x(msg->gps_x_m());
point.set_y(msg->gps_y_m());
if (0 == msg->single_traffic_light_size()) {
AERROR << "Error::v2x traffic_light ignore, size of single light is 0.";
return false;
}
if (0 == msg->single_traffic_light(0).traffic_light_type_size()) {
return false;
}
::apollo::hdmap::LaneInfoConstPtr laneinfo;
double dummy_s = 0, dummy_l = 0;
if (0 != hdmap->GetNearestLane(point, &laneinfo, &dummy_s, &dummy_l)) {
return false;
}
std::vector<::apollo::hdmap::SignalInfoConstPtr> signals;
if (0 != hdmap->GetForwardNearestSignalsOnLane(point, distance, &signals)) {
AERROR << "Error::v2x traffic_light ignore, hdmap get no signals."
<< "traffic light size : " << signals.size() << " "
<< std::setiosflags(std::ios::fixed) << std::setprecision(11)
<< "Point:x=" << point.x() << ",y=" << point.y();
return false;
}
if (signals.empty()) {
AERROR << "Get traffic light size : " << signals.size() << " "
<< std::setiosflags(std::ios::fixed) << std::setprecision(11)
<< "Point:x=" << point.x() << ",y=" << point.y();
return false;
}
AINFO << "the size of traffic light from HDMap is: " << signals.size();
auto tl_type = msg->single_traffic_light(0).traffic_light_type(0);
auto color = msg->single_traffic_light(0).color();
auto remaining_time = msg->single_traffic_light(0).color_remaining_time_s();
auto next_color = msg->single_traffic_light(0).next_color();
auto next_remaining_time =
msg->single_traffic_light(0).next_remaining_time_s();
msg->clear_single_traffic_light();
for (size_t i = 0; i < signals.size(); i++) {
auto signal_info = signals[i];
auto single = msg->add_single_traffic_light();
single->set_id(signal_info->id().id());
single->add_traffic_light_type(tl_type);
single->set_color(color);
single->set_color_remaining_time_s(remaining_time);
single->set_next_color(next_color);
single->set_next_remaining_time_s(next_remaining_time);
}
return true;
}
bool IsRushHour() {
std::time_t local = std::time(nullptr);
std::tm now = {};
localtime_r(&local, &now);
return now.tm_hour > 16;
}
bool InternalData::ProcTrafficlight(
const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const ObuLight *x2v_traffic_light, const std::string &junction_id,
bool flag_u_turn, double distance, double check_time,
std::shared_ptr<OSLight> *os_light) {
if (nullptr == os_light) {
return false;
}
if (nullptr == *os_light) {
return false;
}
if (!x2v_traffic_light) {
if (junction_id == kUnknownJunctionId) {
return false;
}
return true;
}
if (junction_id != x2v_traffic_light->hdmap_junction_id()) {
AWARN << "current junction id " << junction_id
<< ", received the junction id "
<< x2v_traffic_light->hdmap_junction_id();
return false;
}
std::shared_ptr<OSLight> os_traffic_light = nullptr;
if (!ProtoAdapter::LightObu2Sys(*x2v_traffic_light, &os_traffic_light)) {
return false;
}
int num_os_traffic_light = os_traffic_light->road_traffic_light_size();
if (0 == num_os_traffic_light) {
AERROR << "Ignored no traffic light contained after conventor.";
return false;
}
std::shared_ptr<OSLight> sim_traffic_light_data = nullptr;
// enter the new intersection if the sim message is not null, clear
auto cur_junction_id = x2v_traffic_light->intersection_id();
auto tmp_os_traffic_light = std::make_shared<OSLight>();
tmp_os_traffic_light->CopyFrom(*os_traffic_light);
// clear road traffic light
tmp_os_traffic_light->clear_road_traffic_light();
for (int i = 0; i < num_os_traffic_light; i++) {
auto os_current_light = os_traffic_light->mutable_road_traffic_light(i);
if (!TrafficLightProc(hdmap, distance, os_current_light)) {
AERROR << "Traffic light proc failed";
continue;
}
if (os_current_light->single_traffic_light_size() > 0) {
auto tmp_os_current_light =
tmp_os_traffic_light->add_road_traffic_light();
tmp_os_current_light->CopyFrom(*(os_current_light));
}
}
tmp_os_traffic_light->set_confidence(IsRushHour() ? 0.5 : 1.0);
AINFO << "all traffic light send to os BEFORE is: "
<< os_traffic_light->DebugString();
if (0 == tmp_os_traffic_light->road_traffic_light_size()) {
return false;
}
cur_junction_id = x2v_traffic_light->intersection_id();
tmp_os_traffic_light->set_intersection_id(cur_junction_id);
// enter a new junction, need to clear the list
if (cur_junction_id != intersection_id_) {
AINFO << "Enter New Juncion: " << cur_junction_id;
oslight_ = nullptr;
intersection_id_ = cur_junction_id;
int num_traffic_light = tmp_os_traffic_light->road_traffic_light_size();
for (int i = 0; i < num_traffic_light; i++) {
auto remaining_time = tmp_os_traffic_light->road_traffic_light(i)
.single_traffic_light(0)
.color_remaining_time_s();
remaining_time_[i] = remaining_time;
msg_timestamp_[i] = x2v_traffic_light->header().timestamp_sec();
}
} else {
ADEBUG << "Same Juncion: " << cur_junction_id;
if (flag_u_turn) {
for (unsigned int i = 0; i < kBufferSize; i++) {
msg_timestamp_[i] = 0.0;
remaining_time_[i] = -1;
}
oslight_ = nullptr;
}
int num_traffic_light = tmp_os_traffic_light->road_traffic_light_size();
for (int i = 0; i < num_traffic_light; i++) {
auto remaining_time = tmp_os_traffic_light->road_traffic_light(i)
.single_traffic_light(0)
.color_remaining_time_s();
if ((remaining_time_[i] != remaining_time)) {
remaining_time_[i] = remaining_time;
msg_timestamp_[i] = x2v_traffic_light->header().timestamp_sec();
}
}
if (!!oslight_) {
int road_valid_size =
std::min(oslight_->road_traffic_light_size(),
tmp_os_traffic_light->road_traffic_light_size());
for (int i = 0; i < road_valid_size; i++) {
const auto &last_msg_road = oslight_->road_traffic_light(i);
auto current_msg_road =
tmp_os_traffic_light->mutable_road_traffic_light(i);
int single_valid_size =
std::min(last_msg_road.single_traffic_light_size(),
current_msg_road->single_traffic_light_size());
for (int j = 0; j < single_valid_size; j++) {
const auto &last_msg_single_traffic_light =
last_msg_road.single_traffic_light(j);
auto current_msg_single_traffic_light =
current_msg_road->mutable_single_traffic_light(j);
if (last_msg_single_traffic_light.color() ==
current_msg_single_traffic_light->color()) {
if (current_msg_single_traffic_light->color_remaining_time_s() >
last_msg_single_traffic_light.color_remaining_time_s()) {
AINFO << "correct the remaining time";
current_msg_single_traffic_light->set_color_remaining_time_s(
last_msg_single_traffic_light.color_remaining_time_s());
}
}
}
}
}
}
oslight_ = std::make_shared<::apollo::v2x::IntersectionTrafficLightData>();
oslight_->CopyFrom(*tmp_os_traffic_light);
(*os_light)->CopyFrom(*tmp_os_traffic_light);
return true;
}
bool InternalData::ProcPlanningMessage(
const ::apollo::planning::ADCTrajectory *planning_msg,
const OSLight *last_os_light,
std::shared_ptr<::apollo::perception::TrafficLightDetection> *res_light) {
if (!planning_msg || !res_light || !(*res_light)) {
return false;
}
// Keep this blank header for protect other module against coredump.
(*res_light)->mutable_header();
if (!planning_msg->has_debug() ||
!planning_msg->debug().has_planning_data()) {
return false;
}
const auto &planning_debug = planning_msg->debug().planning_data();
if (!planning_debug.has_signal_light() ||
0 == planning_debug.signal_light().signal_size()) {
return false;
}
const std::string light_id =
planning_debug.signal_light().signal(0).light_id();
if (!last_os_light || light_id.empty()) {
return true; // output traffic light without v2x;
}
::apollo::common::Direction attr = ::apollo::common::Direction::EAST;
bool found = false;
for (int idx = 0; idx < last_os_light->road_traffic_light_size(); idx++) {
const auto &road_tl = last_os_light->road_traffic_light(idx);
if (0 == road_tl.single_traffic_light_size()) {
continue;
}
if (road_tl.single_traffic_light(0).id() == light_id) {
attr = road_tl.road_attribute();
found = true;
break;
}
}
if (!found) {
AWARN << "Failed to find light_id from os_light: " << light_id
<< " , Ignored";
return true; // output traffic light without v2x;
}
(*res_light)->clear_traffic_light();
auto res_frame_id = std::to_string(last_os_light->has_intersection_id()
? last_os_light->intersection_id()
: -1);
(*res_light)->mutable_header()->set_frame_id(res_frame_id);
AINFO << "Selected road attr: " << ::apollo::common::Direction_Name(attr);
std::set<std::string> idset;
for (int idx = 0; idx < last_os_light->road_traffic_light_size(); idx++) {
const auto &road_tl = last_os_light->road_traffic_light(idx);
if (0 == road_tl.single_traffic_light_size()) {
continue;
}
if (road_tl.road_attribute() != attr) {
continue;
}
const auto &single_tl = road_tl.single_traffic_light(0);
if (single_tl.traffic_light_type_size() < 1) {
continue;
}
auto *light1 = (*res_light)->add_traffic_light();
// SET ID
// light1->set_id(single_tl.id());
light1->set_id(SingleTrafficLight_Type_Name( //
single_tl.traffic_light_type(0)));
idset.emplace(single_tl.id());
if (single_tl.has_color()) {
switch (single_tl.color()) {
case OSLightColor::SingleTrafficLight_Color_RED:
light1->set_color(
::apollo::perception::TrafficLight_Color::TrafficLight_Color_RED);
break;
case OSLightColor::SingleTrafficLight_Color_YELLOW:
light1->set_color(::apollo::perception::TrafficLight_Color::
TrafficLight_Color_YELLOW);
break;
case OSLightColor::SingleTrafficLight_Color_GREEN:
case OSLightColor::SingleTrafficLight_Color_FLASH_GREEN:
light1->set_color(::apollo::perception::TrafficLight_Color::
TrafficLight_Color_GREEN);
break;
case OSLightColor::SingleTrafficLight_Color_BLACK:
light1->set_color(::apollo::perception::TrafficLight_Color::
TrafficLight_Color_BLACK);
break;
default:
light1->set_color(::apollo::perception::TrafficLight_Color::
TrafficLight_Color_UNKNOWN);
break;
}
}
// REMAINING_TIME
if (single_tl.has_color_remaining_time_s()) {
light1->set_remaining_time(single_tl.color_remaining_time_s());
}
}
return true;
}
namespace utils {
bool FindAllRoadId(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const ::apollo::hdmap::LaneInfoConstPtr &start_laneinfo,
const ::apollo::hdmap::LaneInfoConstPtr &end_laneinfo,
size_t max_road_count,
std::unordered_set<std::string> *result_id_set) {
if (!result_id_set) {
return false;
}
size_t road_counter = 0;
::apollo::hdmap::Id id;
result_id_set->clear();
result_id_set->insert(start_laneinfo->road_id().id());
::apollo::hdmap::LaneInfoConstPtr start_laneinfo_tmp = start_laneinfo;
while (true) {
if (0 == start_laneinfo_tmp->lane().successor_id_size()) {
AINFO << "The lane has no successor";
return false;
}
id = start_laneinfo_tmp->lane().successor_id(0);
AINFO << "Lane id " << id.id();
start_laneinfo_tmp = hdmap->GetLaneById(id);
if (start_laneinfo_tmp == nullptr) {
AINFO << "Get lane by id is null.";
return false;
}
result_id_set->insert(start_laneinfo_tmp->road_id().id());
if (start_laneinfo_tmp->road_id().id() == end_laneinfo->road_id().id()) {
std::stringstream ss;
ss << "find all the road id: ";
for (const auto &item : *result_id_set) {
ss << item << " ";
}
AINFO << ss.str();
return true;
}
road_counter++;
if (road_counter > max_road_count) {
AINFO << "not find the end road id after try " << road_counter;
return false;
}
}
}
bool CheckCarInSet(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const std::unordered_set<std::string> &id_set,
const ::apollo::hdmap::LaneInfoConstPtr &car_laneinfo,
size_t max_lane_count) {
size_t lane_counter = 0;
::apollo::hdmap::Id id;
auto car_laneinfo_tmp = car_laneinfo;
while (true) {
if (id_set.count(car_laneinfo_tmp->road_id().id()) == 1) {
AINFO << "find the car is in the speed limit region";
return true;
}
if (car_laneinfo_tmp->lane().successor_id_size() == 0) {
AWARN << "The lane of the card no successor";
return false;
}
id = car_laneinfo_tmp->lane().successor_id(0);
AINFO << "Lane id " << id.id();
car_laneinfo_tmp = hdmap->GetLaneById(id);
if (car_laneinfo_tmp == nullptr) {
AWARN << "Get lane by id is null.";
return false;
} else {
if (++lane_counter > max_lane_count) {
AWARN << "not find the road in after try to " << lane_counter;
return false;
}
}
}
}
bool GetRsuInfo(const std::shared_ptr<::apollo::hdmap::HDMap> &hdmap,
const OSLocation &os_location,
const std::set<std::string> &rsu_whitelist, double distance,
double max_heading_difference,
std::shared_ptr<::apollo::v2x::CarStatus> *v2x_car_status,
std::string *out_junction_id, double *out_heading) {
if (!v2x_car_status) {
return false;
}
if (!out_junction_id) {
return false;
}
if (!out_heading) {
return false;
}
*out_junction_id = kUnknownJunctionId;
auto res = std::make_shared<::apollo::v2x::CarStatus>();
if (nullptr == res) {
return false;
}
if (!os_location.has_header()) {
return false;
}
if (!os_location.has_pose()) {
return false;
}
res->mutable_localization()->CopyFrom(os_location);
::apollo::common::PointENU point;
point.set_x(os_location.pose().position().x());
point.set_y(os_location.pose().position().y());
double heading = ::apollo::common::math::QuaternionToHeading(
os_location.pose().orientation().qw(),
os_location.pose().orientation().qx(),
os_location.pose().orientation().qy(),
os_location.pose().orientation().qz());
*out_heading = heading;
std::vector<::apollo::hdmap::RSUInfoConstPtr> rsus;
if (0 != hdmap->GetForwardNearestRSUs(point, distance, heading,
max_heading_difference, &rsus) ||
rsus.empty()) {
AINFO << "no rsu is found";
return false;
}
AINFO << "Get " << rsus.size() << " rsu(s)";
if (rsu_whitelist.find(rsus[0]->id().id() + "_tl") == rsu_whitelist.cend()) {
AINFO << "This rsu id '" << rsus[0]->id().id()
<< "' is not in the white list";
return false;
}
AINFO << "This RSU is in the white list";
AINFO << "Junction id " << rsus[0]->rsu().junction_id().id();
auto junction_info = hdmap->GetJunctionById(rsus[0]->rsu().junction_id());
if (nullptr == junction_info) {
return false;
}
std::shared_ptr<::apollo::v2x::ObuJunction> obu_junction = nullptr;
if (!ProtoAdapter::JunctionHd2obu(junction_info, &obu_junction)) {
return false;
}
res->mutable_junction()->CopyFrom(*obu_junction);
*v2x_car_status = res;
*out_junction_id = junction_info->id().id();
return true;
}
OSLightColor GetNextColor(OSLightColor color) {
switch (color) {
case OSLightColor::SingleTrafficLight_Color_GREEN:
return OSLightColor::SingleTrafficLight_Color_YELLOW;
case OSLightColor::SingleTrafficLight_Color_YELLOW:
return OSLightColor::SingleTrafficLight_Color_RED;
case OSLightColor::SingleTrafficLight_Color_RED:
return OSLightColor::SingleTrafficLight_Color_GREEN;
default:
return color;
}
}
void UniqueOslight(OSLight *os_light) {
if (nullptr == os_light) {
return;
}
auto tmp_os_light = std::make_shared<OSLight>();
tmp_os_light->CopyFrom(*os_light);
os_light->clear_road_traffic_light();
std::set<std::string> idset;
for (int idx_tl = 0; idx_tl < tmp_os_light->road_traffic_light_size();
idx_tl++) {
const auto &tmp_road_tl = tmp_os_light->road_traffic_light(idx_tl);
for (int idx_single = 0;
idx_single < tmp_road_tl.single_traffic_light_size(); idx_single++) {
const auto &single = tmp_road_tl.single_traffic_light(idx_single);
if (0 == single.traffic_light_type_size()) {
continue;
}
std::string tmpid =
single.id() +
std::to_string(static_cast<int>(single.traffic_light_type(0)));
// Has ID
if (idset.find(tmpid) != idset.cend()) {
continue;
}
idset.insert(tmpid);
// UNIQUE ID
auto res_tl = os_light->add_road_traffic_light();
res_tl->set_gps_x_m(tmp_road_tl.gps_x_m());
res_tl->set_gps_y_m(tmp_road_tl.gps_y_m());
res_tl->set_road_attribute(tmp_road_tl.road_attribute());
auto res_single = res_tl->add_single_traffic_light();
res_single->CopyFrom(single);
}
}
}
} // namespace utils
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/v2x_proxy.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file v2x_proxy.cc
* @brief define v2x proxy class
*/
#include "modules/v2x/v2x_proxy/app/v2x_proxy.h"
#include <cmath>
#include <cstdio>
#include <ostream>
#include <vector>
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
using ::apollo::canbus::ChassisDetail;
using ::apollo::v2x::CarStatus;
using ::apollo::v2x::StatusResponse;
using ::apollo::v2x::obu::ObuRsi;
using ::apollo::v2x::obu::ObuTrafficLight;
V2xProxy::~V2xProxy() {
if (recv_thread_ != nullptr && recv_thread_->joinable()) {
recv_thread_->join();
}
if (planning_thread_ != nullptr && planning_thread_->joinable()) {
planning_thread_->join();
}
if (obs_thread_ != nullptr && obs_thread_->joinable()) {
obs_thread_->join();
}
}
V2xProxy::V2xProxy(std::shared_ptr<::apollo::hdmap::HDMap> hdmap)
: node_(::apollo::cyber::CreateNode("v2x_proxy")), exit_(false) {
if (node_ == nullptr) {
AFATAL << "Create v2x proxy node failed.";
exit(1);
}
internal_ = std::make_shared<InternalData>();
hdmap_ = std::make_shared<::apollo::hdmap::HDMap>();
const auto hdmap_file = apollo::hdmap::BaseMapFile();
if (0 != hdmap_->LoadMapFromFile(hdmap_file)) {
AERROR << "Failed to load hadmap file: " << hdmap_file;
return;
}
::apollo::cyber::TimerOption v2x_car_status_timer_option;
v2x_car_status_timer_option.period =
static_cast<uint32_t>((1000 + FLAGS_v2x_car_status_timer_frequency - 1) /
FLAGS_v2x_car_status_timer_frequency);
v2x_car_status_timer_option.callback = [this]() {
this->OnV2xCarStatusTimer();
};
v2x_car_status_timer_option.oneshot = false;
v2x_car_status_timer_.reset(
new ::apollo::cyber::Timer(v2x_car_status_timer_option));
os_interface_.reset(new OsInterFace());
obu_interface_.reset(new ObuInterFaceGrpcImpl());
recv_thread_.reset(new std::thread([this]() {
while (!exit_.load()) {
this->RecvTrafficlight();
}
}));
CHECK(!!hdmap_ && !!v2x_car_status_timer_);
CHECK(!!os_interface_ && !!obu_interface_);
CHECK(os_interface_->InitFlag() && obu_interface_->InitFlag());
planning_thread_.reset(new std::thread([this]() {
while (!exit_.load()) {
this->RecvOsPlanning();
}
}));
obs_thread_.reset(new std::thread([this]() {
while (!exit_.load()) {
std::shared_ptr<::apollo::v2x::V2XObstacles> obs = nullptr;
this->obu_interface_->GetV2xObstaclesFromObu(&obs); // Blocked
this->os_interface_->SendV2xObstacles2Sys(obs);
}
}));
v2x_car_status_timer_->Start();
GetRsuListFromFile(FLAGS_rsu_whitelist_name, &rsu_list_);
init_flag_ = true;
}
bool V2xProxy::GetRsuListFromFile(const std::string &filename,
std::set<std::string> *whitelist) {
if (nullptr == whitelist) {
return false;
}
std::ifstream input_file(filename);
if (!input_file) {
return false;
}
std::string line;
while (getline(input_file, line)) {
whitelist->insert(line);
}
return !whitelist->empty();
}
bool V2xProxy::InitFlag() { return init_flag_; }
void V2xProxy::RecvOsPlanning() {
auto adc_trajectory = std::make_shared<::apollo::planning::ADCTrajectory>();
auto res_light =
std::make_shared<::apollo::perception::TrafficLightDetection>();
os_interface_->GetPlanningAdcFromOs(adc_trajectory);
// OK get planning message
std::shared_ptr<OSLight> last_os_light = nullptr;
{
std::lock_guard<std::mutex> lock(lock_last_os_light_);
auto now_us = ::apollo::cyber::Time::MonoTime().ToMicrosecond();
if (last_os_light_ == nullptr ||
2000LL * 1000 * 1000 < now_us - ts_last_os_light_) {
AWARN << "V2X Traffic Light is too old!";
last_os_light_ = nullptr;
} else {
ADEBUG << "V2X Traffic Light is on time.";
last_os_light = std::make_shared<OSLight>();
last_os_light->CopyFrom(*last_os_light_);
}
}
// proc planning message
bool res_proc_planning_msg = internal_->ProcPlanningMessage(
adc_trajectory.get(), last_os_light.get(), &res_light);
if (!res_proc_planning_msg) {
return;
}
os_interface_->SendV2xTrafficLight4Hmi2Sys(res_light);
}
void V2xProxy::RecvTrafficlight() {
// get traffic light from obu
std::shared_ptr<ObuLight> x2v_traffic_light = nullptr;
obu_interface_->GetV2xTrafficLightFromObu(&x2v_traffic_light);
os_interface_->SendV2xObuTrafficLightToOs(x2v_traffic_light);
auto os_light = std::make_shared<OSLight>();
std::string junction_id = "";
{
std::lock_guard<std::mutex> lg(lock_hdmap_junction_id_);
junction_id = hdmap_junction_id_;
}
bool res_success_ProcTrafficlight = internal_->ProcTrafficlight(
hdmap_, x2v_traffic_light.get(), junction_id, u_turn_,
FLAGS_traffic_light_distance, FLAGS_check_time, &os_light);
if (!res_success_ProcTrafficlight) {
return;
}
utils::UniqueOslight(os_light.get());
os_interface_->SendV2xTrafficLightToOs(os_light);
// save for hmi
std::lock_guard<std::mutex> lock(lock_last_os_light_);
ts_last_os_light_ = ::apollo::cyber::Time::MonoTime().ToMicrosecond();
last_os_light_ = os_light;
}
double cal_distance(const ::apollo::common::PointENU &p1,
const ::apollo::common::PointENU &p2) {
double x = p1.x() - p2.x();
double y = p1.y() - p2.y();
return std::sqrt(x * x + y * y);
}
void V2xProxy::OnV2xCarStatusTimer() {
// get loc
auto localization =
std::make_shared<::apollo::localization::LocalizationEstimate>();
os_interface_->GetLocalizationFromOs(localization);
if (nullptr == localization) {
return;
}
std::set<std::string> rsu_whitelist;
{
std::lock_guard<std::mutex> lg(rsu_list_mutex_);
rsu_whitelist.insert(rsu_list_.cbegin(), rsu_list_.cend());
}
::apollo::common::PointENU car_position;
car_position.set_x(localization->pose().position().x());
car_position.set_y(localization->pose().position().y());
std::shared_ptr<::apollo::v2x::CarStatus> v2x_car_status = nullptr;
double heading = 0.0;
std::string res_junction_id = "";
bool ret_get_rsu_info = utils::GetRsuInfo(
hdmap_, *localization, rsu_whitelist, FLAGS_traffic_light_distance,
FLAGS_heading_difference, &v2x_car_status, &res_junction_id, &heading);
{
std::lock_guard<std::mutex> lg(lock_hdmap_junction_id_);
hdmap_junction_id_ = res_junction_id;
}
if (!ret_get_rsu_info) {
return;
}
// calc heading
if (!init_heading_) {
heading_ = heading;
init_heading_ = true;
}
if (std::fabs(heading_ - heading) > 1.0) {
u_turn_ = true;
}
obu_interface_->SendCarStatusToObu(v2x_car_status);
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/v2x_proxy_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/v2x_proxy/app/v2x_proxy.h"
#include <iostream>
#include <memory>
#include <google/protobuf/text_format.h>
#include "gtest/gtest.h"
#include "modules/v2x/v2x_proxy/app/utils.h"
TEST(V2xProxy, V2xProxy) {
::apollo::cyber::Init("TestCase");
auto hdmap = std::make_shared<::apollo::hdmap::HDMap>();
hdmap->LoadMapFromFile(apollo::hdmap::BaseMapFile());
::apollo::v2x::V2xProxy v2x_proxy(hdmap);
EXPECT_TRUE(v2x_proxy.InitFlag());
sleep(1);
v2x_proxy.stop();
::apollo::cyber::Clear();
}
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
load("//tools/install:install.bzl", "install")
package(default_visibility = ["//visibility:public"])
install(
name = "install",
runtime_dest = "v2x/bin",
targets = [
":v2x",
]
)
cc_library(
name = "utils",
srcs = ["utils.cc"],
hdrs = ["utils.h"],
deps = [
"//cyber",
"//modules/common/math",
"//modules/map/hdmap:hdmap_util",
"//modules/v2x/v2x_proxy/obu_interface:obu_interface_grpc_impl",
"//modules/v2x/v2x_proxy/os_interface",
"//modules/v2x/v2x_proxy/proto_adapter",
],
)
cc_library(
name = "v2x_proxy",
srcs = ["v2x_proxy.cc"],
hdrs = ["v2x_proxy.h"],
deps = [
":utils",
"//cyber",
"//modules/map/hdmap:hdmap_util",
"//modules/v2x/v2x_proxy/obu_interface:obu_interface_grpc_impl",
"//modules/v2x/v2x_proxy/os_interface",
"//modules/v2x/v2x_proxy/proto_adapter",
],
)
#cc_test(
# name = "v2x_proxy_test",
# srcs = [
# "v2x_proxy_test.cc",
# ],
# deps = [
# ":v2x_proxy",
# "@com_google_googletest//:gtest_main",
# ],
#)
cc_binary(
name = "v2x",
srcs = ["main.cc"],
deps = [
":v2x_proxy",
],
)
cc_test(
name = "utils_test",
size = "small",
timeout = "short",
srcs = ["utils_test.cc"],
deps = [
":utils",
"//cyber",
"//modules/map/hdmap:hdmap_util",
"//modules/v2x/v2x_proxy/obu_interface:obu_interface_grpc_impl",
"//modules/v2x/v2x_proxy/os_interface",
"//modules/v2x/v2x_proxy/proto_adapter",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/v2x_proxy.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file v2x_proxy.h
* @brief define v2x proxy class
*/
#pragma once
#include <atomic>
#include <memory>
#include <set>
#include <string>
#include <thread>
#include "cyber/cyber.h"
#include "modules/map/hdmap/hdmap_util.h"
#include "modules/v2x/v2x_proxy/app/utils.h"
#include "modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl.h"
#include "modules/v2x/v2x_proxy/os_interface/os_interface.h"
#include "modules/v2x/v2x_proxy/proto_adapter/proto_adapter.h"
namespace apollo {
namespace v2x {
bool IsRushHour();
class V2xProxy {
private:
std::shared_ptr<InternalData> internal_ = nullptr;
std::string hdmap_junction_id_ = kUnknownJunctionId;
std::mutex lock_hdmap_junction_id_;
// for hmi traffic lights
std::shared_ptr<OSLight> last_os_light_ = nullptr;
uint64_t ts_last_os_light_ = 0;
std::mutex lock_last_os_light_;
public:
explicit V2xProxy(std::shared_ptr<::apollo::hdmap::HDMap> hdmap = nullptr);
~V2xProxy();
bool InitFlag();
void stop() {
exit_ = true;
v2x_car_status_timer_->Stop();
obu_status_timer_->Stop();
rsu_whitelist_timer_->Stop();
}
bool GetRsuListFromFile(const std::string &filename,
std::set<std::string> *whitelist);
private:
/* function RecvTrafficlight, get traffic light msg from grpc with timeout
*/
void RecvTrafficlight();
void RecvOsPlanning();
/* function obu to car traffic light timer callback
*/
// void on_x2v_traffic_light_timer();
std::unique_ptr<::apollo::cyber::Timer> v2x_car_status_timer_;
std::unique_ptr<::apollo::cyber::Timer> obu_status_timer_;
std::unique_ptr<::apollo::cyber::Timer> rsu_whitelist_timer_;
std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
std::unique_ptr<OsInterFace> os_interface_;
std::unique_ptr<ObuInterFaceGrpcImpl> obu_interface_;
std::unique_ptr<std::thread> recv_thread_ = nullptr;
std::unique_ptr<std::thread> planning_thread_ = nullptr;
std::unique_ptr<std::thread> rsi_thread_ = nullptr;
std::unique_ptr<std::thread> obs_thread_ = nullptr;
/* function car to obu car status timer callback
*/
void OnV2xCarStatusTimer();
std::shared_ptr<::apollo::hdmap::HDMap> hdmap_;
bool init_flag_ = false;
bool init_heading_ = false;
double heading_ = 0.0001;
bool u_turn_ = false;
std::atomic<bool> exit_;
std::mutex rsu_list_mutex_;
std::set<std::string> rsu_list_;
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/app/utils_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file utils_test.cc
*/
#include "modules/v2x/v2x_proxy/app/utils.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
TEST(v2x_proxy_app, v2x_proxy_UtilsGetNextColor) {
EXPECT_EQ(OSLightColor::SingleTrafficLight_Color_YELLOW,
utils::GetNextColor(OSLightColor::SingleTrafficLight_Color_GREEN));
EXPECT_EQ(OSLightColor::SingleTrafficLight_Color_RED,
utils::GetNextColor(OSLightColor::SingleTrafficLight_Color_YELLOW));
EXPECT_EQ(OSLightColor::SingleTrafficLight_Color_GREEN,
utils::GetNextColor(OSLightColor::SingleTrafficLight_Color_RED));
EXPECT_EQ(OSLightColor::SingleTrafficLight_Color_BLACK,
utils::GetNextColor(OSLightColor::SingleTrafficLight_Color_BLACK));
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/obu_interface_abstract_class.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file obu_interface_abstract_class.h
* @brief define v2x proxy module and onboard unit interface base class
*/
#pragma once
#include <chrono>
#include <memory>
#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
#include "modules/v2x/proto/v2x_car_status.pb.h"
#include "modules/v2x/proto/v2x_obstacles.pb.h"
#include "modules/v2x/proto/v2x_obu_rsi.pb.h"
#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
#include "cyber/cyber.h"
namespace apollo {
namespace v2x {
class ObuInterFaceBase {
public:
ObuInterFaceBase() {}
virtual ~ObuInterFaceBase() {}
public:
virtual bool InitialServer() = 0;
virtual bool InitialClient() = 0;
virtual void GetV2xTrafficLightFromObu(
std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> *msg) {}
virtual void SendCarStatusToObu(
const std::shared_ptr<::apollo::v2x::CarStatus> &msg) {}
virtual void GetV2xRsiFromObu(
std::shared_ptr<::apollo::v2x::obu::ObuRsi> *msg) {}
virtual void GetV2xObstaclesFromObu(
std::shared_ptr<::apollo::v2x::V2XObstacles> *msg) {}
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file obu_interface_grpc_impl.h
* @brief define v2x proxy module and onboard unit interface grpc impl class
*/
#pragma once
#include <condition_variable>
#include <memory>
#include <mutex>
#include <thread>
#include <grpc++/grpc++.h>
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client.h"
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server.h"
#include "modules/v2x/v2x_proxy/obu_interface/obu_interface_abstract_class.h"
namespace apollo {
namespace v2x {
class ObuInterFaceGrpcImpl : public ObuInterFaceBase {
public:
ObuInterFaceGrpcImpl();
~ObuInterFaceGrpcImpl();
/* function that init grpc server
*/
bool InitialServer() override;
/* function that init grpc client
*/
bool InitialClient() override;
/* function that get v2x traffic light through grpc
@param output return latest v2x traffic light
*/
void GetV2xTrafficLightFromObu(
std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> *msg) override;
void GetV2xObstaclesFromObu(
std::shared_ptr<::apollo::v2x::V2XObstacles> *msg) override;
void GetV2xRsiFromObu(
std::shared_ptr<::apollo::v2x::obu::ObuRsi> *msg) override;
/* function that send car status through grpc
@param input send car status msg to grpc
*/
void SendCarStatusToObu(
const std::shared_ptr<::apollo::v2x::CarStatus> &msg) override;
/* function that return init flag
*/
bool InitFlag() { return init_succ_; }
private:
/* thread function that run server
*/
void ThreadRunServer();
std::shared_ptr<GrpcClientImpl> grpc_client_;
std::unique_ptr<GrpcServerImpl> grpc_server_;
std::unique_ptr<grpc::Server> server_;
bool cli_init_ = false;
bool srv_init_ = false;
bool init_succ_ = false;
bool exit_flag_ = false;
std::unique_ptr<std::thread> thread_grpc_;
std::mutex mutex_;
std::condition_variable condition_;
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl_test.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file obu_interface_grpc_impl_test.cc
* @brief test v2x proxy module and onboard unit interface grpc impl class
*/
#include "modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
TEST(ObuInterFaceGrpcImplTest, Construct) {
apollo::cyber::Init("obu_interface_grpc_impl_test");
ObuInterFaceGrpcImpl obuinteface;
EXPECT_TRUE(obuinteface.InitFlag());
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file obu_interface_grpc_impl.cc
* @brief define v2x proxy module and onboard unit interface grpc impl class
*/
#include "modules/v2x/v2x_proxy/obu_interface/obu_interface_grpc_impl.h"
#include <memory>
#include <string>
#include <utility>
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
using ::apollo::v2x::CarStatus;
using ::apollo::v2x::obu::ObuRsi;
using ::apollo::v2x::obu::ObuTrafficLight;
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
ObuInterFaceGrpcImpl::ObuInterFaceGrpcImpl()
: grpc_client_(new GrpcClientImpl(grpc::CreateChannel(
FLAGS_grpc_client_host + ":" + FLAGS_grpc_client_port,
grpc::InsecureChannelCredentials()))) {
AINFO << "ObuInterFaceGrpcImpl Start Construct.";
cli_init_ = grpc_client_->InitFlag();
grpc_server_.reset(new GrpcServerImpl());
srv_init_ = grpc_server_->InitFlag();
CHECK(InitialClient());
CHECK(InitialServer());
init_succ_ = true;
}
ObuInterFaceGrpcImpl::~ObuInterFaceGrpcImpl() {
{
std::unique_lock<std::mutex> lck(mutex_);
exit_flag_ = true;
}
condition_.notify_all();
if (!!thread_grpc_ && thread_grpc_->joinable()) {
thread_grpc_->join();
}
AINFO << "close obu interface success";
}
bool ObuInterFaceGrpcImpl::InitialClient() { return cli_init_; }
bool ObuInterFaceGrpcImpl::InitialServer() {
if (!srv_init_) {
return false;
}
thread_grpc_.reset(new std::thread([this]() { this->ThreadRunServer(); }));
return thread_grpc_ != nullptr;
}
void ObuInterFaceGrpcImpl::ThreadRunServer() {
std::unique_lock<std::mutex> lck(mutex_);
auto start = std::chrono::steady_clock::now();
std::string server_address(FLAGS_grpc_server_host + ":" +
FLAGS_grpc_server_port);
ServerBuilder builder;
// Listen on the given address without any authentication mechanism.
builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
// Register "service" as the instance through which we'll communicate with
// clients. In this case it corresponds to an *synchronous* service.
builder.RegisterService(grpc_server_.get());
// Finally assemble the server.
auto tmp = builder.BuildAndStart();
server_ = std::move(tmp);
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> time_used = end - start;
AINFO << "ObuInterFaceGrpcImpl grpc server has listening on : "
<< server_address << " time used : " << time_used.count();
condition_.wait(lck, [&]() { return exit_flag_; });
}
void ObuInterFaceGrpcImpl::GetV2xTrafficLightFromObu(
std::shared_ptr<ObuTrafficLight> *msg) {
grpc_server_->GetMsgFromGrpc(msg);
}
void ObuInterFaceGrpcImpl::GetV2xObstaclesFromObu(
std::shared_ptr<::apollo::v2x::V2XObstacles> *msg) {
grpc_server_->GetMsgFromGrpc(msg);
}
void ObuInterFaceGrpcImpl::GetV2xRsiFromObu(std::shared_ptr<ObuRsi> *msg) {
grpc_server_->GetMsgFromGrpc(msg);
}
void ObuInterFaceGrpcImpl::SendCarStatusToObu(
const std::shared_ptr<CarStatus> &msg) {
grpc_client_->SendMsgToGrpc(msg);
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "obu_interface_grpc_impl",
srcs = ["obu_interface_grpc_impl.cc"],
hdrs = [
"obu_interface_abstract_class.h",
"obu_interface_grpc_impl.h",
],
deps = [
"//modules/v2x/v2x_proxy/obu_interface/grpc_interface:grpc_client",
"//modules/v2x/v2x_proxy/obu_interface/grpc_interface:grpc_server",
"@com_github_grpc_grpc//:grpc++",
],
)
cc_test(
name = "obu_interface_grpc_impl_test",
size = "small",
srcs = ["obu_interface_grpc_impl_test.cc"],
deps = [
":obu_interface_grpc_impl",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server_test.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_server_test.cc
* @brief test v2x proxy module and onboard unit interface grpc implement
*/
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
TEST(GrpcServerImplTest, Construct) {
apollo::cyber::Init("grpc_server_test");
bool init_succ = false;
GrpcServerImpl grpc_server;
init_succ = grpc_server.InitFlag();
EXPECT_TRUE(init_succ);
std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> ptr = nullptr;
grpc_server.GetMsgFromGrpc(&ptr);
EXPECT_EQ(nullptr, ptr);
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_client.h
* @brief define v2x proxy module and onboard unit interface grpc implement
*/
#pragma once
#include <memory>
#include <mutex>
#include <grpc++/grpc++.h>
#include "modules/v2x/proto/v2x_car_status.pb.h"
#include "modules/v2x/proto/v2x_obu_traffic_light.pb.h"
#include "modules/v2x/proto/v2x_service_car_to_obu.grpc.pb.h"
#include "cyber/cyber.h"
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
class GrpcClientImpl {
public:
/* construct function
@param input car_status type msg shared ptr
*/
explicit GrpcClientImpl(std::shared_ptr<grpc::Channel> channel);
~GrpcClientImpl() {}
bool InitFlag() { return init_flag_; }
/*function that send car status msg through grpc
@param input car_status type msg shared ptr
*/
void SendMsgToGrpc(const std::shared_ptr<::apollo::v2x::CarStatus> &msg);
private:
// grpc service stub
std::unique_ptr<::apollo::v2x::CarToObu::Stub> stub_;
int car_status_tv_nsec_ = 0;
bool init_flag_ = false;
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client_test.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_client_test.cc
* @brief test v2x proxy module and onboard unit interface grpc implement
*/
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client.h"
#include "gtest/gtest.h"
#include "cyber/cyber.h"
namespace apollo {
namespace v2x {
TEST(GrpcClientImplTest, Construct) {
apollo::cyber::Init("grpc_client_test");
GrpcClientImpl grpc_client(
grpc::CreateChannel(FLAGS_grpc_client_host + ":" + FLAGS_grpc_client_port,
grpc::InsecureChannelCredentials()));
bool init_succ = grpc_client.InitFlag();
EXPECT_TRUE(init_succ);
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_client.cc
* @brief define v2x proxy module and onboard unit interface grpc implement
*/
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_client.h"
#include <chrono>
#include "cyber/common/log.h"
#include "cyber/cyber.h"
namespace apollo {
namespace v2x {
using ::apollo::v2x::CarStatus;
using ::apollo::v2x::UpdateStatus;
using ::apollo::v2x::obu::ObuTrafficLight;
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
GrpcClientImpl::GrpcClientImpl(std::shared_ptr<Channel> channel)
: stub_(::apollo::v2x::CarToObu::NewStub(channel)) {
AINFO << "GrpcClientImpl initial success";
car_status_tv_nsec_ = (1000000000 / FLAGS_v2x_car_status_timer_frequency / 2);
init_flag_ = true;
}
void GrpcClientImpl::SendMsgToGrpc(const std::shared_ptr<CarStatus> &msg) {
if (!msg->has_localization()) {
return;
}
// set timeout
ClientContext context;
gpr_timespec timespec;
timespec.tv_sec = 0;
timespec.tv_nsec = car_status_tv_nsec_; // 80000000; // 80ms
timespec.clock_type = GPR_TIMESPAN;
context.set_deadline(timespec);
UpdateStatus response;
// time used statistics
auto start = std::chrono::steady_clock::now();
Status status = stub_->PushCarStatus(&context, *msg, &response);
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> time_used = end - start;
// response check: error_code 4: time out; 0: success;
AINFO << "stub PushCarStatus Time used: " << time_used.count() * 1000
<< " ms";
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_server.h
* @brief define v2x proxy module and onboard unit interface grpc implement
*/
#pragma once
#include <condition_variable>
#include <memory>
#include <mutex>
#include <thread>
#include <grpc++/grpc++.h>
#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
#include "modules/common_msgs/perception_msgs/traffic_light_detection.pb.h"
#include "modules/v2x/proto/v2x_obu_rsi.pb.h"
#include "modules/v2x/proto/v2x_service_obu_to_car.grpc.pb.h"
#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
#include "cyber/cyber.h"
namespace apollo {
namespace v2x {
class GrpcServerImpl final : public ::apollo::v2x::ObuToCar::Service {
public:
/* construct function
*/
GrpcServerImpl();
~GrpcServerImpl() {
traffic_light_condition_.notify_all();
rsi_condition_.notify_all();
}
bool InitFlag() { return init_flag_; }
/* function that send v2x traffic_light through grpc
@param input v2x traffic_light grpc request
@param output grpc response
*/
grpc::Status SendV2xTrafficLight(
grpc::ServerContext *context,
const ::apollo::v2x::obu::ObuTrafficLight *request,
::apollo::v2x::StatusResponse *response) override;
/* function that send v2x monitor messages through grpc
@param input v2x monitor grpc request
@param output grpc response
*/
grpc::Status SendObuAlarm(grpc::ServerContext *context,
const ::apollo::v2x::ObuAlarm *request,
::apollo::v2x::StatusResponse *response) override;
/* function that send perception obstacles through grpc
@param input perception obstacles grpc request
@param output grpc response
*/
grpc::Status SendPerceptionObstacles(grpc::ServerContext *context,
const apollo::v2x::V2XObstacles *request,
StatusResponse *response) override;
grpc::Status SendV2xRSI(grpc::ServerContext *context,
const ::apollo::v2x::obu::ObuRsi *request,
::apollo::v2x::StatusResponse *response);
void GetMsgFromGrpc(
std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> *ptr);
void GetMsgFromGrpc(std::shared_ptr<::apollo::v2x::obu::ObuRsi> *ptr);
void GetMsgFromGrpc(std::shared_ptr<::apollo::v2x::V2XObstacles> *ptr);
private:
std::mutex traffic_light_mutex_;
std::mutex rsi_mutex_;
std::mutex obstacles_mutex_;
std::condition_variable traffic_light_condition_;
std::condition_variable rsi_condition_;
std::condition_variable obs_condition_;
::apollo::v2x::obu::ObuTrafficLight latest_traffic_light_;
::apollo::v2x::obu::ObuRsi latest_rsi_;
::apollo::v2x::V2XObstacles latest_obstacles_;
bool init_flag_ = false;
bool refresh_ = false;
bool rsi_refresh_ = false;
bool obs_refresh_ = false;
std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file grpc_server.cc
* @brief define v2x proxy module and onboard unit interface grpc implement
*/
#include "modules/v2x/v2x_proxy/obu_interface/grpc_interface/grpc_server.h"
#include <chrono>
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
using ::apollo::v2x::StatusResponse;
using ::apollo::v2x::obu::ObuRsi;
using ::apollo::v2x::obu::ObuTrafficLight;
using grpc::Status;
GrpcServerImpl::GrpcServerImpl()
: node_(::apollo::cyber::CreateNode("v2x_grpc_server")) {
CHECK(!!node_);
// _monitor = cybertron::MetricController::Instance();
AINFO << "GrpcServerImpl initial success";
init_flag_ = true;
}
grpc::Status GrpcServerImpl::SendV2xRSI(grpc::ServerContext * /* context */,
const ObuRsi *request,
StatusResponse *response) {
ADEBUG << "Received SendV2xRSI request from client!";
ADEBUG << request->DebugString();
if (!request->has_header()) {
response->set_status(false);
response->set_info("error no header in RSI request");
AERROR << "SendV2xRSI request has no header";
return Status::CANCELLED;
}
{
std::lock_guard<std::mutex> guard(rsi_mutex_);
latest_rsi_.CopyFrom(*request);
auto obu_header = latest_rsi_.mutable_header();
if (obu_header->has_timestamp_sec()) {
AINFO << "Obu Timestamp: " << std::setiosflags(std::ios::fixed)
<< std::setprecision(11) << obu_header->timestamp_sec();
AINFO << "SVB Timestamp: " << std::setiosflags(std::ios::fixed)
<< std::setprecision(11) << ::apollo::cyber::Time::Now().ToSecond();
obu_header->set_timestamp_sec(::apollo::cyber::Time::Now().ToSecond());
}
rsi_refresh_ = true;
}
rsi_condition_.notify_one();
response->set_status(true);
AINFO << "SendV2xRSI response success.";
return Status::OK;
}
grpc::Status GrpcServerImpl::SendPerceptionObstacles(
grpc::ServerContext *, const apollo::v2x::V2XObstacles *request,
StatusResponse *response) {
ADEBUG << "Received SendPerceptionObstacles request from client!";
{
std::lock_guard<std::mutex> guard(obstacles_mutex_);
latest_obstacles_.CopyFrom(*request);
response->set_status(true);
obs_refresh_ = true;
ADEBUG << "SendPerceptionObstacles response success.";
}
obs_condition_.notify_one();
return Status::OK;
}
grpc::Status GrpcServerImpl::SendV2xTrafficLight(
grpc::ServerContext * /* context */, const ObuTrafficLight *request,
StatusResponse *response) {
ADEBUG << "Received SendV2xTrafficLight request from client!";
ADEBUG << request->DebugString();
int num_current_light = request->road_traffic_light_size();
if (0 == num_current_light) {
response->set_status(false);
response->set_info("error v2x current lane traffic light size == 0");
AERROR << "SendV2xTrafficLight request no current lane traffic light.";
return Status::CANCELLED;
}
if (!request->has_header()) {
response->set_status(false);
response->set_info(
"error no header in IntersectionTrafficLightData request");
AERROR << "SendV2xTrafficLight request has no header";
return Status::CANCELLED;
}
{
std::lock_guard<std::mutex> guard(traffic_light_mutex_);
latest_traffic_light_.CopyFrom(*request);
auto obu_header = latest_traffic_light_.mutable_header();
if (obu_header->has_timestamp_sec()) {
obu_header->set_timestamp_sec(::apollo::cyber::Time::Now().ToSecond());
}
refresh_ = true;
}
traffic_light_condition_.notify_one();
auto cur_junction_id = request->intersection_id();
ADEBUG << "recieved the junction id " << cur_junction_id;
response->set_status(true);
return Status::OK;
}
grpc::Status GrpcServerImpl::SendObuAlarm(
grpc::ServerContext *context, const ::apollo::v2x::ObuAlarm *request,
StatusResponse *response) {
ADEBUG << "Received SendOBUAlarm request from client!";
if (request->error_num() != ::apollo::v2x::ErrorCode::OBUID) {
} else {
AERROR << "OBU id:" << request->error_msg();
}
response->set_status(true);
return Status::OK;
}
void GrpcServerImpl::GetMsgFromGrpc(std::shared_ptr<ObuRsi> *ptr) {
if (nullptr == ptr) {
return;
}
std::unique_lock<std::mutex> guard(rsi_mutex_);
rsi_condition_.wait(guard, [this] { return rsi_refresh_; });
rsi_refresh_ = false;
*ptr = std::make_shared<ObuRsi>();
if (nullptr == *ptr) {
return;
}
(*ptr)->CopyFrom(latest_rsi_);
}
void GrpcServerImpl::GetMsgFromGrpc(
std::shared_ptr<::apollo::v2x::V2XObstacles> *ptr) {
if (nullptr == ptr) {
return;
}
std::unique_lock<std::mutex> guard(obstacles_mutex_);
obs_condition_.wait(guard, [this] { return obs_refresh_; });
obs_refresh_ = false;
*ptr = std::make_shared<::apollo::v2x::V2XObstacles>();
if (nullptr == *ptr) {
return;
}
(*ptr)->CopyFrom(latest_obstacles_);
}
void GrpcServerImpl::GetMsgFromGrpc(std::shared_ptr<ObuTrafficLight> *ptr) {
if (nullptr == ptr) {
return;
}
std::unique_lock<std::mutex> guard(traffic_light_mutex_);
if (!traffic_light_condition_.wait_for(
guard, std::chrono::milliseconds(FLAGS_msg_timeout),
[this] { return refresh_; })) {
AERROR << "GetMsgFromGrpc IntersectionTrafficLightData is timeout";
*ptr = nullptr;
return;
}
*ptr = std::make_shared<ObuTrafficLight>();
if (nullptr == *ptr) {
return;
}
(*ptr)->CopyFrom(latest_traffic_light_);
latest_traffic_light_.Clear();
refresh_ = false;
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/obu_interface/grpc_interface/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "grpc_client",
srcs = ["grpc_client.cc"],
hdrs = ["grpc_client.h"],
deps = [
"//cyber",
"//modules/v2x/common:v2x_proxy_gflags",
"//modules/v2x/proto:v2x_service_car_to_obu_cc_grpc",
"//modules/v2x/proto:v2x_service_obu_to_car_cc_grpc",
"@com_github_grpc_grpc//:grpc++",
],
)
cc_library(
name = "grpc_server",
srcs = ["grpc_server.cc"],
hdrs = ["grpc_server.h"],
deps = [
"//cyber",
"//modules/common_msgs/perception_msgs:perception_obstacle_cc_proto",
"//modules/common_msgs/perception_msgs:traffic_light_detection_cc_proto",
"//modules/v2x/common:v2x_proxy_gflags",
"//modules/v2x/proto:v2x_obu_rsi_cc_proto",
"//modules/v2x/proto:v2x_service_car_to_obu_cc_grpc",
"//modules/v2x/proto:v2x_service_obu_to_car_cc_grpc",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_cc_proto",
"@com_github_grpc_grpc//:grpc++",
],
)
cc_test(
name = "grpc_client_test",
size = "small",
srcs = ["grpc_client_test.cc"],
deps = [
":grpc_client",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "grpc_server_test",
size = "small",
srcs = ["grpc_server_test.cc"],
deps = [
":grpc_server",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/proto_adapter/proto_adapter.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#include "modules/v2x/v2x_proxy/proto_adapter/proto_adapter.h"
#include <Eigen/Core>
#include <Eigen/Geometry>
#include "cyber/cyber.h"
namespace apollo {
namespace v2x {
OSLightype ProtoAdapter::LightTypeObu2Sys(int32_t type) {
switch (type) {
case 2:
return OSLightype::SingleTrafficLight_Type_LEFT;
case 3:
return OSLightype::SingleTrafficLight_Type_RIGHT;
case 4:
return OSLightype::SingleTrafficLight_Type_U_TURN;
case 1:
default:
return OSLightype::SingleTrafficLight_Type_STRAIGHT;
}
}
bool ProtoAdapter::LightObu2Sys(const ObuLight &obu_light,
std::shared_ptr<OSLight> *os_light) {
if (nullptr == os_light) {
return false;
}
auto res = std::make_shared<OSLight>();
if (nullptr == res) {
return false;
}
if (!obu_light.has_header()) {
return false;
}
if (obu_light.header().has_timestamp_sec()) {
res->mutable_header()->set_timestamp_sec(
obu_light.header().timestamp_sec());
}
if (obu_light.header().has_module_name()) {
res->mutable_header()->set_module_name(obu_light.header().module_name());
}
if (0 == obu_light.road_traffic_light_size()) {
return false;
}
bool flag_has_data = false;
for (int idx_road = 0; idx_road < obu_light.road_traffic_light_size();
idx_road++) {
const auto &obu_road_light1 = obu_light.road_traffic_light(idx_road);
// Set the road index for lane
apollo::common::Direction tl_attr = apollo::common::Direction::EAST;
switch (obu_road_light1.road_direction()) {
case 1:
tl_attr = apollo::common::Direction::EAST;
break;
case 2:
tl_attr = apollo::common::Direction::WEST;
break;
case 3:
tl_attr = apollo::common::Direction::SOUTH;
break;
case 4:
tl_attr = apollo::common::Direction::NORTH;
break;
default:
AINFO << "Road direction=" << obu_road_light1.road_direction()
<< " is invalid.";
}
// FOR-EACH LANE
for (int idx_lane = 0; idx_lane < obu_road_light1.lane_traffic_light_size();
idx_lane++) {
const auto &obu_lane_light1 =
obu_road_light1.lane_traffic_light(idx_lane);
if (!obu_lane_light1.has_gps_x_m() || !obu_lane_light1.has_gps_y_m()) {
AWARN << "Invalid lane_traffic_light: [" << idx_road << "][" << idx_lane
<< "]: no gps info here.";
continue;
}
flag_has_data = true;
auto *res_light1 = res->add_road_traffic_light();
res_light1->set_gps_x_m(obu_lane_light1.gps_x_m());
res_light1->set_gps_y_m(obu_lane_light1.gps_y_m());
res_light1->set_road_attribute(tl_attr);
// single traffic light
for (int j = 0; j < obu_lane_light1.single_traffic_light_size(); j++) {
auto *res_single1 = res_light1->add_single_traffic_light();
const auto &obu_single1 = obu_lane_light1.single_traffic_light(j);
if (obu_single1.has_id()) {
res_single1->set_id(obu_single1.id());
}
if (obu_single1.has_color_remaining_time_s()) {
res_single1->set_color_remaining_time_s(
obu_single1.color_remaining_time_s());
}
if (obu_single1.has_next_remaining_time()) {
res_single1->set_next_remaining_time_s(
obu_single1.next_remaining_time());
}
if (obu_single1.has_right_turn_light()) {
res_single1->set_right_turn_light(obu_single1.right_turn_light());
}
if (obu_single1.has_color()) {
res_single1->set_color(obu_single1.color());
}
if (obu_single1.has_next_color()) {
res_single1->set_next_color(obu_single1.next_color());
}
if (obu_single1.has_traffic_light_type()) {
res_single1->add_traffic_light_type(
LightTypeObu2Sys(obu_single1.traffic_light_type()));
}
}
}
}
*os_light = res;
return flag_has_data;
}
bool ProtoAdapter::RsiObu2Sys(const ObuRsi *obu_rsi,
std::shared_ptr<OSRsi> *os_rsi) {
if (nullptr == obu_rsi) {
return false;
}
if (nullptr == os_rsi) {
return false;
}
auto res = std::make_shared<OSRsi>();
if (nullptr == res) {
return false;
}
if (!obu_rsi->has_alter_type()) {
return false;
}
res->set_radius(obu_rsi->radius());
res->set_rsi_type(obu_rsi->alter_type());
if (obu_rsi->has_header()) {
auto header = res->mutable_header();
header->set_sequence_num(obu_rsi->header().sequence_num());
header->set_timestamp_sec(obu_rsi->header().timestamp_sec());
header->set_module_name("v2x");
}
switch (obu_rsi->alter_type()) {
case RsiAlterType::SPEED_LIMIT:
case RsiAlterType::SPEED_LIMIT_BRIDGE:
case RsiAlterType::SPEED_LIMIT_TUNNEL:
for (int index = 0; index < obu_rsi->points_size(); index++) {
auto point = res->add_points();
point->set_x(obu_rsi->points(index).x());
point->set_y(obu_rsi->points(index).y());
res->set_speed(std::atof(obu_rsi->description().c_str()));
}
break;
case RsiAlterType::CONSTRUCTION_AHEAD: // Construction Ahead
case RsiAlterType::BUS_LANE: // Bus Lane
case RsiAlterType::TIDAL_LANE: // tidal Lane
case RsiAlterType::TRAFFIC_JAM: // traffic jam
case RsiAlterType::TRAFFIC_ACCIDENT: // traffic accident
for (int index = 0; index < obu_rsi->points_size(); index++) {
auto point = res->add_points();
point->set_x(obu_rsi->points(index).x());
point->set_y(obu_rsi->points(index).y());
}
break;
case RsiAlterType::NO_HONKING: // No Honking
case RsiAlterType::SLOW_DOWN_SECTION: // slow down section
case RsiAlterType::ACCIDENT_PRONE: // Accident Prone
case RsiAlterType::OVERSPEED_VEHICLE: // overspeed vehicle
case RsiAlterType::EMERGENCY_BRAKING: // emergency braking
case RsiAlterType::ANTIDROMIC_VEHICLE: // antidromic vehicle
case RsiAlterType::ZOMBIES_VEHICLE: { // zombies vehicle
auto point = res->add_points();
point->set_x(obu_rsi->points(0).x());
point->set_y(obu_rsi->points(0).y());
break;
}
case RsiAlterType::CONTROLLOSS_VEHICLE: // controlloss vehicle
case RsiAlterType::SPECIAL_VEHICLE: { // special vehicle
auto point = res->add_points();
point->set_x(obu_rsi->points(0).x());
point->set_y(obu_rsi->points(0).y());
res->set_speed(std::atof(obu_rsi->description().c_str()));
break;
}
default:
AINFO << "RSI type:" << obu_rsi->alter_type();
break;
}
*os_rsi = res;
return true;
}
bool ProtoAdapter::JunctionHd2obu(const HDJunction &hd_junction,
std::shared_ptr<ObuJunction> *obu_junction) {
if (nullptr == obu_junction) {
return false;
}
auto res = std::make_shared<ObuJunction>();
if (nullptr == res) {
return false;
}
res->mutable_id()->set_id(hd_junction->id().id());
for (const auto &point : hd_junction->polygon().points()) {
auto res_point = res->mutable_polygon()->add_point();
res_point->set_x(point.x());
res_point->set_y(point.y());
res_point->set_z(0);
}
*obu_junction = res;
return true;
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/proto_adapter/proto_adapter.h
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
#pragma once
#include <memory>
#include "modules/v2x/proto/v2x_car_status.pb.h"
#include "modules/v2x/proto/v2x_junction.pb.h"
#include "modules/v2x/proto/v2x_obu_rsi.pb.h"
#include "modules/v2x/proto/v2x_obu_traffic_light.pb.h"
#include "modules/v2x/proto/v2x_rsi.pb.h"
#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
#include "modules/map/hdmap/hdmap.h"
#include "modules/map/hdmap/hdmap_common.h"
namespace apollo {
namespace v2x {
enum RsiAlterType {
SPEED_LIMIT = 85,
SPEED_LIMIT_BRIDGE = 8,
SPEED_LIMIT_TUNNEL = 21,
CONSTRUCTION_AHEAD = 38,
BUS_LANE = 123,
TIDAL_LANE = 41,
TRAFFIC_JAM = 47,
TRAFFIC_ACCIDENT = 244,
NO_HONKING = 80,
SLOW_DOWN_SECTION = 35,
ACCIDENT_PRONE = 34,
OVERSPEED_VEHICLE = 801,
EMERGENCY_BRAKING = 802,
ANTIDROMIC_VEHICLE = 803,
ZOMBIES_VEHICLE = 804,
CONTROLLOSS_VEHICLE = 1000,
SPECIAL_VEHICLE = 2000,
};
using OSLightColor = ::apollo::v2x::SingleTrafficLight_Color;
using OSLightype = ::apollo::v2x::SingleTrafficLight_Type;
using ObuLightype = ::apollo::v2x::obu::SingleTrafficLight_Type;
using OSLight = ::apollo::v2x::IntersectionTrafficLightData;
using ObuLight = ::apollo::v2x::obu::ObuTrafficLight;
using OSLocation = ::apollo::localization::LocalizationEstimate;
using OSRsi = ::apollo::v2x::RsiMsg;
using ObuRsi = ::apollo::v2x::obu::ObuRsi;
using HDJunction = ::apollo::hdmap::JunctionInfoConstPtr;
using ObuJunction = ::apollo::v2x::Junction;
class ProtoAdapter final {
public:
static OSLightype LightTypeObu2Sys(int32_t type);
static bool LightObu2Sys(const ObuLight &obu_light,
std::shared_ptr<OSLight> *os_light);
static bool RsiObu2Sys(const ObuRsi *obu_rsi, std::shared_ptr<OSRsi> *os_rsi);
static bool JunctionHd2obu(const HDJunction &hd_junction,
std::shared_ptr<ObuJunction> *obu_junction);
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/proto_adapter/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "proto_adapter",
srcs = ["proto_adapter.cc"],
hdrs = ["proto_adapter.h"],
deps = [
"//cyber",
"//modules/map/hdmap",
"//modules/v2x/common:v2x_proxy_gflags",
"//modules/v2x/proto:v2x_car_status_cc_proto",
"//modules/v2x/proto:v2x_junction_cc_proto",
"//modules/v2x/proto:v2x_obu_rsi_cc_proto",
"//modules/v2x/proto:v2x_obu_traffic_light_cc_proto",
"//modules/v2x/proto:v2x_rsi_cc_proto",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_cc_proto",
"@eigen",
],
)
cc_test(
name = "proto_adapter_test",
size = "small",
timeout = "short",
srcs = ["proto_adapter_test.cc"],
deps = [
":proto_adapter",
"@com_google_googletest//:gtest_main",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/proto_adapter/proto_adapter_test.cc
|
/******************************************************************************
* Copyright 2020 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file proto_adapter_test.cc
*/
#include "modules/v2x/v2x_proxy/proto_adapter/proto_adapter.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
TEST(v2x_proxy_app, v2x_proxy_adapter_convert_enum) {
EXPECT_EQ(OSLightype::SingleTrafficLight_Type_LEFT,
ProtoAdapter::LightTypeObu2Sys(2));
EXPECT_EQ(OSLightype::SingleTrafficLight_Type_RIGHT,
ProtoAdapter::LightTypeObu2Sys(3));
EXPECT_EQ(OSLightype::SingleTrafficLight_Type_U_TURN,
ProtoAdapter::LightTypeObu2Sys(4));
EXPECT_EQ(OSLightype::SingleTrafficLight_Type_STRAIGHT,
ProtoAdapter::LightTypeObu2Sys(1));
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/os_interface/os_interface.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file os_interface.h
* @brief define v2x proxy module and apollo os interface
*/
#pragma once
#include <chrono>
#include <cstring>
#include <iostream>
#include <memory>
#include <mutex>
#include <string>
#include "modules/common_msgs/localization_msgs/localization.pb.h"
#include "modules/common_msgs/perception_msgs/perception_obstacle.pb.h"
#include "modules/common_msgs/planning_msgs/planning.pb.h"
#include "modules/v2x/proto/v2x_obstacles.pb.h"
#include "modules/v2x/proto/v2x_obu_rsi.pb.h"
#include "modules/v2x/proto/v2x_obu_traffic_light.pb.h"
#include "modules/common_msgs/v2x_msgs/v2x_traffic_light.pb.h"
#include "cyber/cyber.h"
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
class OsInterFace {
public:
OsInterFace();
~OsInterFace();
bool InitFlag() { return init_flag_; }
void GetLocalizationFromOs(
const std::shared_ptr<::apollo::localization::LocalizationEstimate> &msg);
void GetPlanningAdcFromOs(
const std::shared_ptr<::apollo::planning::ADCTrajectory> &msg);
void SendV2xObuTrafficLightToOs(
const std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> &msg);
void SendV2xTrafficLightToOs(
const std::shared_ptr<::apollo::v2x::IntersectionTrafficLightData> &msg);
void SendV2xObstacles2Sys(
const std::shared_ptr<apollo::v2x::V2XObstacles> &msg);
void SendV2xTrafficLight4Hmi2Sys(
const std::shared_ptr<::apollo::perception::TrafficLightDetection> &msg);
private:
template <typename MessageT>
void SendMsgToOs(::apollo::cyber::Writer<MessageT> *writer,
const std::shared_ptr<MessageT> &msg) {
if (nullptr == writer) {
return;
}
writer->Write(msg);
}
bool InitReaders();
bool InitWriters();
std::unique_ptr<::apollo::cyber::Node> node_ = nullptr;
std::shared_ptr<
::apollo::cyber::Reader<::apollo::localization::LocalizationEstimate>>
localization_reader_ = nullptr;
std::shared_ptr<::apollo::cyber::Reader<::apollo::planning::ADCTrajectory>>
planning_reader_ = nullptr;
std::shared_ptr<::apollo::cyber::Writer<::apollo::v2x::obu::ObuTrafficLight>>
v2x_obu_traffic_light_writer_ = nullptr;
std::shared_ptr<
::apollo::cyber::Writer<::apollo::v2x::IntersectionTrafficLightData>>
v2x_traffic_light_writer_ = nullptr;
std::shared_ptr<
::apollo::cyber::Writer<::apollo::perception::TrafficLightDetection>>
v2x_traffic_light_hmi_writer_ = nullptr;
std::shared_ptr<::apollo::cyber::Writer<::apollo::v2x::V2XObstacles>>
v2x_obstacles_internal_writer_ = nullptr;
::apollo::localization::LocalizationEstimate current_localization_;
::apollo::planning::ADCTrajectory adc_trajectory_msg_;
bool flag_planning_new_ = false;
mutable std::mutex mutex_localization_;
mutable std::mutex mutex_planning_;
mutable std::condition_variable cond_planning_;
bool init_flag_ = false;
};
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/os_interface/os_interface.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file os_interface.cc
* @brief define v2x proxy module and apollo os interface
*/
#include "modules/v2x/v2x_proxy/os_interface/os_interface.h"
#include "modules/common/adapters/adapter_gflags.h"
namespace apollo {
namespace v2x {
using ::apollo::localization::LocalizationEstimate;
using ::apollo::perception::PerceptionObstacles;
using ::apollo::planning::ADCTrajectory;
using ::apollo::v2x::IntersectionTrafficLightData;
OsInterFace::OsInterFace()
: node_(::apollo::cyber::CreateNode("v2x_os_interface")),
init_flag_(false) {
init_flag_ = !!node_ && InitReaders() && InitWriters();
}
OsInterFace::~OsInterFace() {}
bool OsInterFace::InitReaders() {
localization_reader_ = node_->CreateReader<LocalizationEstimate>(
FLAGS_localization_topic,
[this](const std::shared_ptr<const LocalizationEstimate> &msg) {
std::lock_guard<std::mutex> lg(mutex_localization_);
current_localization_.Clear();
current_localization_.CopyFrom(*msg);
});
planning_reader_ = node_->CreateReader<ADCTrajectory>(
FLAGS_planning_trajectory_topic,
[this](const std::shared_ptr<const ADCTrajectory> &msg) {
{
std::lock_guard<std::mutex> lg(mutex_planning_);
adc_trajectory_msg_.Clear();
adc_trajectory_msg_.CopyFrom(*msg);
flag_planning_new_ = true;
}
cond_planning_.notify_one();
});
return nullptr != localization_reader_ && nullptr != planning_reader_;
}
bool OsInterFace::InitWriters() {
v2x_obu_traffic_light_writer_ =
node_->CreateWriter<::apollo::v2x::obu::ObuTrafficLight>(
FLAGS_v2x_obu_traffic_light_topic);
v2x_traffic_light_writer_ =
node_->CreateWriter<::apollo::v2x::IntersectionTrafficLightData>(
FLAGS_v2x_traffic_light_topic);
v2x_traffic_light_hmi_writer_ =
node_->CreateWriter<::apollo::perception::TrafficLightDetection>(
FLAGS_v2x_traffic_light_for_hmi_topic);
v2x_obstacles_internal_writer_ =
node_->CreateWriter<apollo::v2x::V2XObstacles>(
FLAGS_v2x_internal_obstacle_topic);
return nullptr != v2x_obu_traffic_light_writer_ &&
nullptr != v2x_traffic_light_hmi_writer_ &&
nullptr != v2x_obstacles_internal_writer_ &&
nullptr != v2x_traffic_light_writer_;
}
void OsInterFace::GetLocalizationFromOs(
const std::shared_ptr<LocalizationEstimate> &msg) {
AINFO << "get localization result from os";
std::lock_guard<std::mutex> lg(mutex_localization_);
msg->CopyFrom(current_localization_);
}
void OsInterFace::GetPlanningAdcFromOs(
const std::shared_ptr<::apollo::planning::ADCTrajectory> &msg) {
AINFO << "get planning adc from os";
std::unique_lock<std::mutex> lg(mutex_planning_);
cond_planning_.wait(lg, [this]() { return flag_planning_new_; });
flag_planning_new_ = false;
msg->CopyFrom(adc_trajectory_msg_);
}
void OsInterFace::SendV2xObuTrafficLightToOs(
const std::shared_ptr<::apollo::v2x::obu::ObuTrafficLight> &msg) {
if (nullptr == msg) {
return;
}
AINFO << "send v2x obu traffic_light to os";
SendMsgToOs(v2x_obu_traffic_light_writer_.get(), msg);
AINFO << "v2x obu traffic_light result: " << msg->DebugString();
}
void OsInterFace::SendV2xObstacles2Sys(
const std::shared_ptr<apollo::v2x::V2XObstacles> &msg) {
if (nullptr == msg) {
return;
}
AINFO << "send v2x obu traffic_light to os";
SendMsgToOs(v2x_obstacles_internal_writer_.get(), msg);
AINFO << "v2x obu traffic_light result: " << msg->DebugString();
}
void OsInterFace::SendV2xTrafficLightToOs(
const std::shared_ptr<IntersectionTrafficLightData> &msg) {
if (nullptr == msg) {
return;
}
AINFO << "send v2x traffic_light to os";
SendMsgToOs(v2x_traffic_light_writer_.get(), msg);
AINFO << "v2x traffic_light result: " << msg->DebugString();
}
void OsInterFace::SendV2xTrafficLight4Hmi2Sys(
const std::shared_ptr<::apollo::perception::TrafficLightDetection> &msg) {
if (nullptr == msg) {
return;
}
AINFO << "send v2x tl4hmi to os";
SendMsgToOs(v2x_traffic_light_hmi_writer_.get(), msg);
AINFO << "v2x tl4hmi result: " << msg->DebugString();
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/os_interface/os_interface_test.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file os_interface_test.cc
* @brief test v2x proxy module and apollo os interface
*/
#include "modules/v2x/v2x_proxy/os_interface/os_interface.h"
#include "gtest/gtest.h"
namespace apollo {
namespace v2x {
TEST(OsInterFaceTest, Construct) {
apollo::cyber::Init("os_inteface_test");
OsInterFace os_interface;
EXPECT_TRUE(os_interface.InitFlag());
}
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy
|
apollo_public_repos/apollo/modules/v2x/v2x_proxy/os_interface/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "os_interface",
srcs = ["os_interface.cc"],
hdrs = ["os_interface.h"],
deps = [
"//cyber",
"//modules/common/adapters:adapter_gflags",
"//modules/common_msgs/localization_msgs:localization_cc_proto",
"//modules/common_msgs/perception_msgs:perception_obstacle_cc_proto",
"//modules/common_msgs/planning_msgs:planning_cc_proto",
"//modules/v2x/common:v2x_proxy_gflags",
"//modules/v2x/proto:v2x_obstacles_cc_proto",
"//modules/v2x/proto:v2x_obu_rsi_cc_proto",
"//modules/v2x/proto:v2x_obu_traffic_light_cc_proto",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_cc_proto",
],
)
cc_test(
name = "os_interface_test",
size = "small",
timeout = "short",
srcs = ["os_interface_test.cc"],
deps = [
":os_interface",
"@com_google_googletest//:gtest_main",
],
linkstatic = True,
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_obstacles.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/common_msgs/basic_msgs/header.proto";
import "modules/common_msgs/basic_msgs/error_code.proto";
import "modules/common_msgs/perception_msgs/perception_obstacle.proto";
message Point {
optional double x = 1; // in meters.
optional double y = 2; // in meters.
optional double z = 3; // height in meters.
}
message MiniAreaMap {
optional bytes rscu_id = 1; // RSCU id.
optional Point feature_position = 2; // the centre of intersection or sstraight area
optional Point start_position = 3; // the centre of intersection or sstraight area
optional Point end_position = 4; // the centre of intersection or sstraight area
}
message AbnormalInformation {
optional double average_speed = 1;
optional double vehicle_density = 2;
}
message V2XInformation {
enum V2XType {
NONE = 0;
ZOMBIES_CAR = 1;
BLIND_ZONE = 2;
};
repeated V2XType v2x_type = 1; // use case type
optional Point traffic_event_start = 3; // congestion or others initial position.
optional Point traffic_event_start_error = 4; // congestion or others initial position error.
optional Point traffic_event_end = 5; // congestion or others end position.
optional Point traffic_event_end_error = 6; // congestion or others end position error.
optional AbnormalInformation abnormal_info = 7; // abnormal info
}
message V2XObstacle {
optional apollo.perception.PerceptionObstacle perception_obstacle = 1; // obstacle.
optional V2XInformation v2x_info = 2; // v2x use case info
}
message V2XObstacles {
repeated V2XObstacle v2x_obstacle = 1; // An array of obstacles
optional MiniAreaMap area_map = 2; // Mini area map
optional double traffic_flow = 3; // Traffic flow
optional apollo.common.Header header = 4; // Header
optional apollo.common.ErrorCode error_code = 5 [default = OK]; // perception error code
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_car_status.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/common_msgs/localization_msgs/localization.proto";
import "modules/common_msgs/chassis_msgs/chassis_detail.proto";
import "modules/v2x/proto/v2x_junction.proto";
message CarStatus {
optional apollo.localization.LocalizationEstimate localization = 1;
optional apollo.canbus.ChassisDetail chassis_detail = 2;
optional apollo.v2x.Junction junction = 3;
optional Id rsu_id = 4;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_rsi.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/common_msgs/basic_msgs/header.proto";
message RsiPoint {
optional double x = 1; // in meters.
optional double y = 2; // in meters.
}
message RsiMsg {
optional apollo.common.Header header = 1;
repeated RsiPoint points = 2;
optional double speed = 3;
optional double low_speed = 4;
optional double high_speed = 5;
optional string description = 6;
optional int32 rsi_type = 7;
optional double radius = 8;
optional int32 priority = 9;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_service_obu_to_car.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/v2x/proto/v2x_obu_traffic_light.proto";
import "modules/v2x/proto/v2x_monitor.proto";
import "modules/v2x/proto/v2x_obu_rsi.proto";
import "modules/v2x/proto/v2x_obstacles.proto";
service ObuToCar {
// for onboard unit send perception obstacles (from rsu) results to car end
rpc SendPerceptionObstacles(apollo.v2x.V2XObstacles)
returns (StatusResponse) {}
// for onboard unit send v2x traffic_lights (from rsu) results to car end
rpc SendV2xTrafficLight(apollo.v2x.obu.ObuTrafficLight)
returns (StatusResponse) {}
// rsi message
rpc SendV2xRSI(apollo.v2x.obu.ObuRsi) returns (StatusResponse) {}
// v2x obu monitor
rpc SendObuAlarm(apollo.v2x.ObuAlarm) returns (StatusResponse) {}
}
// The response message containing the status.
message StatusResponse {
required bool status = 1 [default = false];
optional string info = 2;
optional int64 error_code = 3;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/fusion_params.proto
|
syntax = "proto2";
package apollo.v2x.ft.fusion;
message KMParams {
optional double min_score = 1;
}
message Param {
optional double k = 1;
optional double b = 2;
}
message SingleCameraParam {
optional int32 camera_id = 1;
repeated Param param = 2;
}
enum ConfidenceLevel {
C90P = 0;
C95P = 1;
C975P = 2;
C99P = 3;
}
message ScoreParams {
optional double prob_scale = 1;
optional double max_match_distance = 2;
optional double min_score = 3;
optional bool use_mahalanobis_distance = 4 [default = false];
optional bool check_type = 5 [default = false];
optional ConfidenceLevel confidence_level = 6 [default = C975P];
}
message FusionParams {
repeated SingleCameraParam fusion_params= 1;
optional KMParams km_params = 2;
required ScoreParams score_params = 3;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_obu_traffic_light.proto
|
syntax = "proto2";
package apollo.v2x.obu;
import "modules/common_msgs/basic_msgs/header.proto";
import "modules/common_msgs/v2x_msgs/v2x_traffic_light.proto";
message SingleTrafficLight {
enum Type {
STRAIGHT = 1;
LEFT = 2;
RIGHT = 3;
U_TURN = 4;
};
optional apollo.v2x.SingleTrafficLight.Color color = 1;
optional int32 traffic_light_type = 2;
// Traffic light string-ID in the map data.
optional string id = 3;
optional int32 color_remaining_time_s = 4;
optional bool right_turn_light = 5;
// v2x next traffic light color
optional apollo.v2x.SingleTrafficLight.Color next_color = 6;
// v2x next traffic light remaining time
optional double next_remaining_time = 7;
// next 2nd traffic ligth color
optional apollo.v2x.SingleTrafficLight.Color next_2nd_color = 8;
optional double next_2nd_remaining_time = 9;
}
message LaneTrafficLight {
// Feature points of lane in the map reference frame.
optional double gps_x_m = 1;
optional double gps_y_m = 2;
repeated SingleTrafficLight single_traffic_light = 3;
}
message RoadTrafficLight {
repeated LaneTrafficLight lane_traffic_light = 1;
optional int32 road_direction = 2;
}
message ObuTrafficLight {
optional apollo.common.Header header = 1;
repeated RoadTrafficLight road_traffic_light = 2;
optional int32 intersection_id = 3;
optional bytes hdmap_junction_id = 4;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_obu_rsi.proto
|
syntax = "proto2";
package apollo.v2x.obu;
import "modules/common_msgs/basic_msgs/header.proto";
import "modules/common_msgs/basic_msgs/geometry.proto";
message ObuRsi {
optional apollo.common.Header header = 1;
optional bytes rsu_id = 2;
optional int32 rsi_id = 3;
optional int32 alter_type = 4;
optional string description = 5;
optional apollo.common.Point2D ref_point = 6;
repeated apollo.common.Point2D points = 7;
optional int32 radius = 8;
optional int32 msg_cnt = 9;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_service_car_to_obu.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/v2x/proto/v2x_car_status.proto";
service CarToObu {
rpc PushCarStatus(apollo.v2x.CarStatus) returns (UpdateStatus) {}
}
message UpdateStatus {
required bool updated = 1 [default = false];
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/BUILD
|
## Auto generated by `proto_build_generator.py`
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//tools:python_rules.bzl", "py_grpc_library", "py_proto_library")
load("@com_github_grpc_grpc//bazel:cc_grpc_library.bzl", "cc_grpc_library")
load("//tools/install:install.bzl", "install", "install_files")
package(default_visibility = ["//visibility:public"])
install_files(
name = "py_pb_v2x",
dest = "v2x/python/modules/v2x/proto",
files = [
":v2x_obstacles_py_pb2",
":v2x_car_status_py_pb2",
":v2x_rsi_py_pb2",
":v2x_service_obu_to_car_py_pb2",
":fusion_params_py_pb2",
":v2x_obu_traffic_light_py_pb2",
":v2x_obu_rsi_py_pb2",
":v2x_service_car_to_obu_py_pb2",
":v2x_monitor_py_pb2",
":v2x_junction_py_pb2",
":v2x_traffic_light_policy_py_pb2"
]
)
cc_proto_library(
name = "v2x_obstacles_cc_proto",
deps = [
":v2x_obstacles_proto",
],
)
proto_library(
name = "v2x_obstacles_proto",
srcs = ["v2x_obstacles.proto"],
deps = [
"//modules/common_msgs/basic_msgs:header_proto",
"//modules/common_msgs/basic_msgs:error_code_proto",
"//modules/common_msgs/perception_msgs:perception_obstacle_proto",
],
)
py_proto_library(
name = "v2x_obstacles_py_pb2",
deps = [
":v2x_obstacles_proto",
"//modules/common_msgs/basic_msgs:header_py_pb2",
"//modules/common_msgs/basic_msgs:error_code_py_pb2",
"//modules/common_msgs/perception_msgs:perception_obstacle_py_pb2",
],
)
cc_proto_library(
name = "v2x_car_status_cc_proto",
deps = [
":v2x_car_status_proto",
],
)
proto_library(
name = "v2x_car_status_proto",
srcs = ["v2x_car_status.proto"],
deps = [
"//modules/common_msgs/localization_msgs:localization_proto",
"//modules/common_msgs/chassis_msgs:chassis_detail_proto",
":v2x_junction_proto",
],
)
py_proto_library(
name = "v2x_car_status_py_pb2",
deps = [
":v2x_car_status_proto",
"//modules/common_msgs/localization_msgs:localization_py_pb2",
"//modules/common_msgs/chassis_msgs:chassis_detail_py_pb2",
":v2x_junction_py_pb2",
],
)
cc_proto_library(
name = "v2x_rsi_cc_proto",
deps = [
":v2x_rsi_proto",
],
)
proto_library(
name = "v2x_rsi_proto",
srcs = ["v2x_rsi.proto"],
deps = [
"//modules/common_msgs/basic_msgs:header_proto",
],
)
py_proto_library(
name = "v2x_rsi_py_pb2",
deps = [
":v2x_rsi_proto",
"//modules/common_msgs/basic_msgs:header_py_pb2",
],
)
cc_grpc_library(
name = "v2x_service_obu_to_car_cc_grpc",
srcs = [":v2x_service_obu_to_car_proto"],
grpc_only = True,
deps = [":v2x_service_obu_to_car_cc_proto"],
)
cc_proto_library(
name = "v2x_service_obu_to_car_cc_proto",
deps = [
":v2x_service_obu_to_car_proto",
],
)
proto_library(
name = "v2x_service_obu_to_car_proto",
srcs = ["v2x_service_obu_to_car.proto"],
deps = [
":v2x_obu_traffic_light_proto",
":v2x_monitor_proto",
":v2x_obu_rsi_proto",
":v2x_obstacles_proto",
],
)
py_grpc_library(
name = "v2x_service_obu_to_car_py_pb2_grpc",
srcs = [":v2x_service_obu_to_car_proto"],
deps = [":v2x_service_obu_to_car_py_pb2"],
)
py_proto_library(
name = "v2x_service_obu_to_car_py_pb2",
deps = [
":v2x_service_obu_to_car_proto",
":v2x_obu_traffic_light_py_pb2",
":v2x_monitor_py_pb2",
":v2x_obu_rsi_py_pb2",
":v2x_obstacles_py_pb2",
],
)
cc_proto_library(
name = "fusion_params_cc_proto",
deps = [
":fusion_params_proto",
],
)
proto_library(
name = "fusion_params_proto",
srcs = ["fusion_params.proto"],
)
py_proto_library(
name = "fusion_params_py_pb2",
deps = [
":fusion_params_proto",
],
)
cc_proto_library(
name = "v2x_obu_traffic_light_cc_proto",
deps = [
":v2x_obu_traffic_light_proto",
],
)
proto_library(
name = "v2x_obu_traffic_light_proto",
srcs = ["v2x_obu_traffic_light.proto"],
deps = [
"//modules/common_msgs/basic_msgs:header_proto",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_proto",
],
)
py_proto_library(
name = "v2x_obu_traffic_light_py_pb2",
deps = [
":v2x_obu_traffic_light_proto",
"//modules/common_msgs/basic_msgs:header_py_pb2",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_py_pb2",
],
)
cc_proto_library(
name = "v2x_obu_rsi_cc_proto",
deps = [
":v2x_obu_rsi_proto",
],
)
proto_library(
name = "v2x_obu_rsi_proto",
srcs = ["v2x_obu_rsi.proto"],
deps = [
"//modules/common_msgs/basic_msgs:header_proto",
"//modules/common_msgs/basic_msgs:geometry_proto",
],
)
py_proto_library(
name = "v2x_obu_rsi_py_pb2",
deps = [
":v2x_obu_rsi_proto",
"//modules/common_msgs/basic_msgs:header_py_pb2",
"//modules/common_msgs/basic_msgs:geometry_py_pb2",
],
)
cc_grpc_library(
name = "v2x_service_car_to_obu_cc_grpc",
srcs = [":v2x_service_car_to_obu_proto"],
grpc_only = True,
deps = [":v2x_service_car_to_obu_cc_proto"],
)
cc_proto_library(
name = "v2x_service_car_to_obu_cc_proto",
deps = [
":v2x_service_car_to_obu_proto",
],
)
proto_library(
name = "v2x_service_car_to_obu_proto",
srcs = ["v2x_service_car_to_obu.proto"],
deps = [
":v2x_car_status_proto",
],
)
py_grpc_library(
name = "v2x_service_car_to_obu_py_pb2_grpc",
srcs = [":v2x_service_car_to_obu_proto"],
deps = [":v2x_service_car_to_obu_py_pb2"],
)
py_proto_library(
name = "v2x_service_car_to_obu_py_pb2",
deps = [
":v2x_service_car_to_obu_proto",
":v2x_car_status_py_pb2",
],
)
cc_proto_library(
name = "v2x_monitor_cc_proto",
deps = [
":v2x_monitor_proto",
],
)
proto_library(
name = "v2x_monitor_proto",
srcs = ["v2x_monitor.proto"],
)
py_proto_library(
name = "v2x_monitor_py_pb2",
deps = [
":v2x_monitor_proto",
],
)
cc_proto_library(
name = "v2x_junction_cc_proto",
deps = [
":v2x_junction_proto",
],
)
proto_library(
name = "v2x_junction_proto",
srcs = ["v2x_junction.proto"],
deps = [
"//modules/common_msgs/basic_msgs:geometry_proto",
],
)
py_proto_library(
name = "v2x_junction_py_pb2",
deps = [
":v2x_junction_proto",
"//modules/common_msgs/basic_msgs:geometry_py_pb2",
],
)
cc_proto_library(
name = "v2x_traffic_light_policy_cc_proto",
deps = [
":v2x_traffic_light_policy_proto",
],
)
proto_library(
name = "v2x_traffic_light_policy_proto",
srcs = ["v2x_traffic_light_policy.proto"],
)
py_proto_library(
name = "v2x_traffic_light_policy_py_pb2",
deps = [
":v2x_traffic_light_policy_proto",
],
)
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_monitor.proto
|
syntax = "proto2";
package apollo.v2x;
enum ErrorCode {
LTEV = 500;
NET = 501;
CPU = 502;
MEM = 503;
GPS = 504;
MAP = 510;
SPAT = 511;
OBUID = 999;
}
message ObuAlarm {
required double mode_num = 1;
required ErrorCode error_num = 2;
required string error_msg = 3;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_junction.proto
|
syntax = "proto2";
package apollo.v2x;
import "modules/common_msgs/basic_msgs/geometry.proto";
message Id {
optional bytes id = 1;
}
message Junction {
optional Id id = 1;
optional apollo.common.Polygon polygon = 2;
// crosswalk in junction
repeated Id crosswalk_id = 3;
repeated Id overlap_id = 4;
// The number of road segments (arms) that are involved.
// e.g 3-way junction indicates a T junction (two arms form one road) or a Y
// junction.
optional int32 num_road_segments = 5 [default = 4];
// lanes in the junction
repeated Id lane_id = 6;
enum Type {
UNKNOWN = 0;
IN_ROAD = 1;
CROSS_ROAD = 2;
};
optional Type type = 7;
enum EdgeType {
PHYSICAL = 0;
VIRTUAL = 1;
};
repeated EdgeType edge_type = 8;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/proto/v2x_traffic_light_policy.proto
|
syntax = "proto2";
package apollo.v2x;
message Position2D {
optional double x = 1;
optional double y = 2;
}
message Connection {
enum Type {
STRAIGHT = 0;
LEFT = 1;
RIGHT = 2;
U_TURN = 3;
};
optional Type allow_driving_behavior = 1;
optional int32 phase_id = 2;
}
message Lane {
optional int32 lane_id = 1;
repeated Position2D position_offset = 2;
repeated Connection connections = 3;
}
message Road {
optional int32 upstream_node_id = 1;
optional Position2D points = 2;
repeated Lane lanes = 3;
}
message Intersection {
optional int32 id = 1;
optional Position2D position = 2;
repeated Road roads = 3;
}
message Map {
optional double time_stamp = 1;
optional int32 msg_cnt = 2;
repeated Intersection intersections = 3;
}
message Phase {
enum Color {
UNKNOWN = 0;
RED = 1;
YELLOW = 2;
GREEN = 3;
BLACK = 4;
FLASH_GREEN = 5;
};
optional int32 id = 1;
optional Color color = 2;
optional int32 color_remaining_time_s = 3;
}
message IntersectionState {
optional int32 intersection_id = 1;
repeated Phase Phases = 2;
optional int32 moy = 3;
optional int32 time_stamp_dsecond = 4;
}
message Spat {
optional double time_stamp = 1;
optional int32 msg_cnt = 2;
repeated IntersectionState intersections = 3;
}
message PolicyData {
optional Map map = 1;
optional Spat spat = 2;
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/launch/v2x.launch
|
<cyber>
<module>
<name>v2x</name>
<dag_conf></dag_conf>
<type>binary</type>
<process_name>
/apollo/bazel-bin/modules/v2x/v2x_proxy/app/v2x --flagfile=/apollo/modules/v2x/conf/v2x.conf
</process_name>
<version>1.0.0</version>
</module>
</cyber>
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/dag/v2x_perception_fusion.dag
|
# Define all coms in DAG streaming.
module_config {
module_library : "/apollo/bazel-bin/modules/v2x/fusion/apps/libv2x_fusion_component.so"
components {
class_name : "V2XFusionComponent"
config {
name : "v2x_fusion"
flag_file_path : "/apollo/modules/v2x/conf/v2x_fusion_tracker.conf"
readers: [
{
channel: "/perception/vehicle/obstacles"
}
]
}
}
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/common/v2x_proxy_gflags.cc
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file v2x_proxy_gflags.cc
* @brief The gflags used by v2x proxy module
*/
#include "modules/v2x/common/v2x_proxy_gflags.h"
namespace apollo {
namespace v2x {
// IP & PORT
DEFINE_string(grpc_client_host, "127.0.0.1", "grpc client host ip");
DEFINE_string(grpc_server_host, "127.0.0.1", "grpc server host ip");
DEFINE_string(grpc_client_port, "50100", "grpc client port");
DEFINE_string(grpc_server_port, "50101", "grpc server port");
DEFINE_string(grpc_debug_server_port, "50102", "grpc server debug port");
// Other Flags
DEFINE_int64(x2v_traffic_light_timer_frequency, 10,
"x2v traffic_light timer frequency");
DEFINE_int64(v2x_car_status_timer_frequency, 10,
"v2x car_status timer frequency");
DEFINE_double(traffic_light_distance, 250.0, "traffic light distance in m");
DEFINE_double(heading_difference, 30.0 / 180.0,
"max heading difference in rad");
DEFINE_int64(list_size, 6, "size of list which stores the traffic light data");
DEFINE_int64(msg_timeout, 250, "timeout value which getting the msg from OBU");
DEFINE_int64(sim_sending_num, 10, "the max sending times");
DEFINE_bool(use_nearest_flag, true,
"use the hdmap interface get_forward_nearest_signals_on_lane flag");
DEFINE_int64(spat_period, 150, "SPAT message period in ms");
DEFINE_double(check_time, 0.5, "SPAT message period in s");
DEFINE_int64(rsu_whitelist_period, 3 * 1000,
"get whitelist period in ms"); // 3s
DEFINE_string(rsu_whitelist_name, "/apollo/modules/v2x/conf/rsu_whitelist.txt",
"file name for RSU whitelist");
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/common/v2x_proxy_gflags.h
|
/******************************************************************************
* Copyright 2018 The Apollo Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/
/**
* @file v2x_proxy_gflags.h
* @brief The gflags used by v2x proxy module
*/
#pragma once
#include "gflags/gflags.h"
namespace apollo {
namespace v2x {
// IP & PORT
DECLARE_string(grpc_client_host);
DECLARE_string(grpc_server_host);
DECLARE_string(grpc_client_port);
DECLARE_string(grpc_server_port);
DECLARE_string(grpc_debug_server_port);
// Other Flags
DECLARE_int64(x2v_traffic_light_timer_frequency);
DECLARE_int64(v2x_car_status_timer_frequency);
DECLARE_double(traffic_light_distance);
DECLARE_double(heading_difference);
DECLARE_int64(list_size);
DECLARE_int64(msg_timeout);
DECLARE_int64(sim_sending_num);
DECLARE_bool(use_nearest_flag);
DECLARE_int64(spat_period);
DECLARE_double(check_time);
DECLARE_int64(rsu_whitelist_period);
DECLARE_string(rsu_whitelist_name);
} // namespace v2x
} // namespace apollo
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/common/BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library")
load("//tools:cpplint.bzl", "cpplint")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "v2x_proxy_gflags",
srcs = ["v2x_proxy_gflags.cc"],
hdrs = ["v2x_proxy_gflags.h"],
deps = [
"@com_github_gflags_gflags//:gflags",
],
)
cpplint()
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/data/fusion_params.pt
|
score_params {
prob_scale: 0.125
max_match_distance: 10
min_score: 0
use_mahalanobis_distance: true
check_type: false
confidence_level: C99P
}
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/conf/v2x.conf
|
--x2v_traffic_light_timer_frequency=10
--v2x_car_status_timer_frequency=10
--grpc_client_host=192.168.10.21
--grpc_server_host=192.168.10.6
--hdmap_file_name=/apollo/modules/map/data/sunnyvale_big_loop/base_map.bin
--rsu_whitelist_name=/apollo/modules/v2x/conf/rsu_whitelist.txt
| 0
|
apollo_public_repos/apollo/modules/v2x
|
apollo_public_repos/apollo/modules/v2x/conf/v2x_fusion_tracker.conf
|
--config_path=/apollo/modules/v2x/data
--fusion_conf_file=fusion_params.pt
--input_conf_file=app_config.pt
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/common_msgs/cyberfile.xml
|
<package format="2">
<name>common-msgs</name>
<version>local</version>
<description>
This module contains code that is not specific to any module but is useful for the functioning of Apollo.
</description>
<maintainer email="apollo-support@baidu.com">Apollo</maintainer>
<license>Apache License 2.0</license>
<url type="website">https://www.apollo.auto/</url>
<url type="repository">https://github.com/ApolloAuto/apollo</url>
<url type="bugtracker">https://github.com/ApolloAuto/apollo/issues</url>
<type>module-wrapper</type>
<src_path url="https://github.com/ApolloAuto/apollo">//modules/common_msgs</src_path>
<depend expose="False">3rd-rules-python-dev</depend>
<depend expose="False">3rd-grpc-dev</depend>
<depend expose="False">3rd-gpus-dev</depend>
<depend expose="False">3rd-rules-proto-dev</depend>
<depend expose="False">3rd-bazel-skylib-dev</depend>
<depend lib_names="protobuf" repo_name="com_google_protobuf">3rd-protobuf-dev</depend>
</package>
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/common_msgs/common-msgs.BUILD
|
load("@rules_cc//cc:defs.bzl", "cc_library")
cc_library(
name = "common-msgs",
includes = ["include"],
hdrs = glob(
[
"include/**/*.h",
],
),
include_prefix = "modules/common_msgs",
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)
| 0
|
apollo_public_repos/apollo/modules
|
apollo_public_repos/apollo/modules/common_msgs/BUILD
|
load("//tools/install:install.bzl", "install", "install_files", "install_src_files")
package(
default_visibility = ["//visibility:public"],
)
install(
name = "install",
data_dest = "common-msgs",
data = [
":cyberfile.xml",
":common-msgs.BUILD",
],
deps = [
":pb_hdrs",
],
)
install(
name = "pb_hdrs",
data_dest = "common-msgs/include",
data = [
"//modules/common_msgs/audio_msgs:audio_common_cc_proto",
"//modules/common_msgs/audio_msgs:audio_event_cc_proto",
"//modules/common_msgs/audio_msgs:audio_cc_proto",
"//modules/common_msgs/basic_msgs:direction_cc_proto",
"//modules/common_msgs/basic_msgs:drive_event_cc_proto",
"//modules/common_msgs/basic_msgs:drive_state_cc_proto",
"//modules/common_msgs/basic_msgs:error_code_cc_proto",
"//modules/common_msgs/basic_msgs:geometry_cc_proto",
"//modules/common_msgs/basic_msgs:header_cc_proto",
"//modules/common_msgs/basic_msgs:pnc_point_cc_proto",
"//modules/common_msgs/basic_msgs:vehicle_id_cc_proto",
"//modules/common_msgs/basic_msgs:vehicle_signal_cc_proto",
"//modules/common_msgs/chassis_msgs:chassis_cc_proto",
"//modules/common_msgs/chassis_msgs:chassis_detail_cc_proto",
"//modules/common_msgs/control_msgs:control_cmd_cc_proto",
"//modules/common_msgs/control_msgs:input_debug_cc_proto",
"//modules/common_msgs/control_msgs:pad_msg_cc_proto",
"//modules/common_msgs/dreamview_msgs:chart_cc_proto",
"//modules/common_msgs/dreamview_msgs:hmi_status_cc_proto",
"//modules/common_msgs/guardian_msgs:guardian_cc_proto",
"//modules/common_msgs/localization_msgs:gps_cc_proto",
"//modules/common_msgs/localization_msgs:imu_cc_proto",
"//modules/common_msgs/localization_msgs:localization_status_cc_proto",
"//modules/common_msgs/localization_msgs:localization_cc_proto",
"//modules/common_msgs/localization_msgs:pose_cc_proto",
"//modules/common_msgs/map_msgs:map_clear_area_cc_proto",
"//modules/common_msgs/map_msgs:map_crosswalk_cc_proto",
"//modules/common_msgs/map_msgs:map_geometry_cc_proto",
"//modules/common_msgs/map_msgs:map_id_cc_proto",
"//modules/common_msgs/map_msgs:map_junction_cc_proto",
"//modules/common_msgs/map_msgs:map_lane_cc_proto",
"//modules/common_msgs/map_msgs:map_overlap_cc_proto",
"//modules/common_msgs/map_msgs:map_parking_space_cc_proto",
"//modules/common_msgs/map_msgs:map_pnc_junction_cc_proto",
"//modules/common_msgs/map_msgs:map_road_cc_proto",
"//modules/common_msgs/map_msgs:map_rsu_cc_proto",
"//modules/common_msgs/map_msgs:map_signal_cc_proto",
"//modules/common_msgs/map_msgs:map_speed_bump_cc_proto",
"//modules/common_msgs/map_msgs:map_speed_control_cc_proto",
"//modules/common_msgs/drivers_msgs:can_card_parameter_cc_proto",
"//modules/common_msgs/map_msgs:map_stop_sign_cc_proto",
"//modules/common_msgs/map_msgs:map_yield_sign_cc_proto",
"//modules/common_msgs/map_msgs:map_cc_proto",
"//modules/common_msgs/monitor_msgs:smart_recorder_status_cc_proto",
"//modules/common_msgs/monitor_msgs:system_status_cc_proto",
"//modules/common_msgs/perception_msgs:perception_camera_cc_proto",
"//modules/common_msgs/perception_msgs:perception_lane_cc_proto",
"//modules/common_msgs/perception_msgs:perception_obstacle_cc_proto",
"//modules/common_msgs/perception_msgs:traffic_light_detection_cc_proto",
"//modules/common_msgs/planning_msgs:decision_cc_proto",
"//modules/common_msgs/planning_msgs:navigation_cc_proto",
"//modules/common_msgs/planning_msgs:pad_msg_cc_proto",
"//modules/common_msgs/planning_msgs:planning_internal_cc_proto",
"//modules/common_msgs/planning_msgs:planning_cc_proto",
"//modules/common_msgs/planning_msgs:scenario_type_cc_proto",
"//modules/common_msgs/planning_msgs:sl_boundary_cc_proto",
"//modules/common_msgs/prediction_msgs:feature_cc_proto",
"//modules/common_msgs/prediction_msgs:lane_graph_cc_proto",
"//modules/common_msgs/prediction_msgs:prediction_obstacle_cc_proto",
"//modules/common_msgs/prediction_msgs:prediction_point_cc_proto",
"//modules/common_msgs/prediction_msgs:scenario_cc_proto",
"//modules/common_msgs/routing_msgs:poi_cc_proto",
"//modules/common_msgs/routing_msgs:routing_cc_proto",
"//modules/common_msgs/sensor_msgs:conti_radar_cc_proto",
"//modules/common_msgs/sensor_msgs:delphi_esr_cc_proto",
"//modules/common_msgs/sensor_msgs:gnss_best_pose_cc_proto",
"//modules/common_msgs/sensor_msgs:gnss_raw_observation_cc_proto",
"//modules/common_msgs/sensor_msgs:gnss_cc_proto",
"//modules/common_msgs/sensor_msgs:heading_cc_proto",
"//modules/common_msgs/sensor_msgs:imu_cc_proto",
"//modules/common_msgs/sensor_msgs:ins_cc_proto",
"//modules/common_msgs/sensor_msgs:mobileye_cc_proto",
"//modules/common_msgs/sensor_msgs:pointcloud_cc_proto",
"//modules/common_msgs/sensor_msgs:racobit_radar_cc_proto",
"//modules/common_msgs/sensor_msgs:radar_cc_proto",
"//modules/common_msgs/sensor_msgs:sensor_image_cc_proto",
"//modules/common_msgs/sensor_msgs:smartereye_cc_proto",
"//modules/common_msgs/sensor_msgs:ultrasonic_radar_cc_proto",
"//modules/common_msgs/storytelling_msgs:story_cc_proto",
"//modules/common_msgs/task_manager_msgs:task_manager_cc_proto",
"//modules/common_msgs/transform_msgs:transform_cc_proto",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_cc_proto",
"//modules/common_msgs/monitor_msgs:monitor_log_cc_proto",
"//modules/common_msgs/config_msgs:vehicle_config_cc_proto",
],
deps = [":pb_py"]
)
install_src_files(
name = "install_src",
src_dir = ["."],
dest = "common-msgs/src",
filter = "*",
)
install_files(
name = "pb_py",
dest = "common-msgs/python/modules/common_msgs",
files = [
"//modules/common_msgs/audio_msgs:audio_common_py_pb2",
"//modules/common_msgs/audio_msgs:audio_event_py_pb2",
"//modules/common_msgs/audio_msgs:audio_py_pb2",
"//modules/common_msgs/chassis_msgs:chassis_detail_py_pb2",
"//modules/common_msgs/chassis_msgs:chassis_py_pb2",
"//modules/common_msgs/config_msgs:vehicle_config_py_pb2",
"//modules/common_msgs/control_msgs:control_cmd_py_pb2",
"//modules/common_msgs/control_msgs:input_debug_py_pb2",
"//modules/common_msgs/control_msgs:pad_msg_py_pb2",
"//modules/common_msgs/dreamview_msgs:chart_py_pb2",
"//modules/common_msgs/dreamview_msgs:hmi_status_py_pb2",
"//modules/common_msgs/drivers_msgs:can_card_parameter_py_pb2",
"//modules/common_msgs/guardian_msgs:guardian_py_pb2",
"//modules/common_msgs/localization_msgs:gps_py_pb2",
"//modules/common_msgs/localization_msgs:imu_py_pb2",
"//modules/common_msgs/localization_msgs:localization_status_py_pb2",
"//modules/common_msgs/localization_msgs:localization_py_pb2",
"//modules/common_msgs/localization_msgs:pose_py_pb2",
"//modules/common_msgs/map_msgs:map_clear_area_py_pb2",
"//modules/common_msgs/map_msgs:map_crosswalk_py_pb2",
"//modules/common_msgs/map_msgs:map_geometry_py_pb2",
"//modules/common_msgs/map_msgs:map_id_py_pb2",
"//modules/common_msgs/map_msgs:map_junction_py_pb2",
"//modules/common_msgs/map_msgs:map_lane_py_pb2",
"//modules/common_msgs/map_msgs:map_overlap_py_pb2",
"//modules/common_msgs/map_msgs:map_parking_space_py_pb2",
"//modules/common_msgs/map_msgs:map_pnc_junction_py_pb2",
"//modules/common_msgs/map_msgs:map_road_py_pb2",
"//modules/common_msgs/map_msgs:map_rsu_py_pb2",
"//modules/common_msgs/map_msgs:map_signal_py_pb2",
"//modules/common_msgs/map_msgs:map_speed_bump_py_pb2",
"//modules/common_msgs/map_msgs:map_speed_control_py_pb2",
"//modules/common_msgs/map_msgs:map_stop_sign_py_pb2",
"//modules/common_msgs/map_msgs:map_yield_sign_py_pb2",
"//modules/common_msgs/map_msgs:map_py_pb2",
"//modules/common_msgs/monitor_msgs:monitor_log_py_pb2",
"//modules/common_msgs/monitor_msgs:smart_recorder_status_py_pb2",
"//modules/common_msgs/monitor_msgs:system_status_py_pb2",
"//modules/common_msgs/perception_msgs:perception_camera_py_pb2",
"//modules/common_msgs/perception_msgs:perception_lane_py_pb2",
"//modules/common_msgs/perception_msgs:perception_obstacle_py_pb2",
"//modules/common_msgs/perception_msgs:traffic_light_detection_py_pb2",
"//modules/common_msgs/planning_msgs:decision_py_pb2",
"//modules/common_msgs/planning_msgs:navigation_py_pb2",
"//modules/common_msgs/planning_msgs:pad_msg_py_pb2",
"//modules/common_msgs/planning_msgs:planning_internal_py_pb2",
"//modules/common_msgs/planning_msgs:planning_py_pb2",
"//modules/common_msgs/planning_msgs:scenario_type_py_pb2",
"//modules/common_msgs/planning_msgs:sl_boundary_py_pb2",
"//modules/common_msgs/prediction_msgs:feature_py_pb2",
"//modules/common_msgs/prediction_msgs:lane_graph_py_pb2",
"//modules/common_msgs/prediction_msgs:prediction_obstacle_py_pb2",
"//modules/common_msgs/prediction_msgs:prediction_point_py_pb2",
"//modules/common_msgs/prediction_msgs:scenario_py_pb2",
"//modules/common_msgs/routing_msgs:poi_py_pb2",
"//modules/common_msgs/routing_msgs:routing_py_pb2",
"//modules/common_msgs/sensor_msgs:conti_radar_py_pb2",
"//modules/common_msgs/sensor_msgs:delphi_esr_py_pb2",
"//modules/common_msgs/sensor_msgs:gnss_best_pose_py_pb2",
"//modules/common_msgs/sensor_msgs:gnss_raw_observation_py_pb2",
"//modules/common_msgs/sensor_msgs:gnss_py_pb2",
"//modules/common_msgs/sensor_msgs:heading_py_pb2",
"//modules/common_msgs/sensor_msgs:imu_py_pb2",
"//modules/common_msgs/sensor_msgs:ins_py_pb2",
"//modules/common_msgs/sensor_msgs:mobileye_py_pb2",
"//modules/common_msgs/sensor_msgs:pointcloud_py_pb2",
"//modules/common_msgs/sensor_msgs:racobit_radar_py_pb2",
"//modules/common_msgs/sensor_msgs:radar_py_pb2",
"//modules/common_msgs/sensor_msgs:sensor_image_py_pb2",
"//modules/common_msgs/sensor_msgs:smartereye_py_pb2",
"//modules/common_msgs/sensor_msgs:ultrasonic_radar_py_pb2",
"//modules/common_msgs/simulation_msgs:agent_py_pb2",
"//modules/common_msgs/simulation_msgs:grading_condition_py_pb2",
"//modules/common_msgs/simulation_msgs:grading_metric_py_pb2",
"//modules/common_msgs/simulation_msgs:scenario_py_pb2",
"//modules/common_msgs/storytelling_msgs:story_py_pb2",
"//modules/common_msgs/task_manager_msgs:task_manager_py_pb2",
"//modules/common_msgs/transform_msgs:transform_py_pb2",
"//modules/common_msgs/v2x_msgs:v2x_traffic_light_py_pb2",
"//modules/common_msgs/basic_msgs:direction_py_pb2",
"//modules/common_msgs/basic_msgs:drive_state_py_pb2",
"//modules/common_msgs/basic_msgs:error_code_py_pb2",
"//modules/common_msgs/basic_msgs:geometry_py_pb2",
"//modules/common_msgs/basic_msgs:header_py_pb2",
"//modules/common_msgs/basic_msgs:pnc_point_py_pb2",
"//modules/common_msgs/basic_msgs:vehicle_signal_py_pb2",
"//modules/common_msgs/basic_msgs:drive_event_py_pb2",
"//modules/common_msgs/basic_msgs:vehicle_id_py_pb2",
],
)
| 0
|
apollo_public_repos/apollo/modules/common_msgs
|
apollo_public_repos/apollo/modules/common_msgs/config_msgs/vehicle_config.proto
|
syntax = "proto2";
package apollo.common;
import "modules/common_msgs/basic_msgs/header.proto";
import "modules/common_msgs/basic_msgs/geometry.proto";
import "modules/common_msgs/basic_msgs/vehicle_id.proto";
message Transform {
optional bytes source_frame = 1; // Also known as "frame_id."
optional bytes target_frame = 2; // Also known as "child_frame_id."
// Position of target in the source frame.
optional Point3D translation = 3;
// Activate rotation from the source frame to the target frame.
optional Quaternion rotation = 4;
}
message Extrinsics {
repeated Transform tansforms = 1;
}
// Vehicle parameters shared among several modules.
// By default, all are measured with the SI units (meters, meters per second,
// etc.).
enum VehicleBrand {
LINCOLN_MKZ = 0;
GEM = 1;
LEXUS = 2;
TRANSIT = 3;
GE3 = 4;
WEY = 5;
ZHONGYUN = 6;
CH = 7;
DKIT = 8;
NEOLIX = 9;
}
message LatencyParam {
// latency parameters, in second (s)
optional double dead_time = 1;
optional double rise_time = 2;
optional double peak_time = 3;
optional double settling_time = 4;
}
message VehicleParam {
optional VehicleBrand brand = 1;
// Car center point is car reference point, i.e., center of rear axle.
optional VehicleID vehicle_id = 2;
optional double front_edge_to_center = 3 [default = nan];
optional double back_edge_to_center = 4 [default = nan];
optional double left_edge_to_center = 5 [default = nan];
optional double right_edge_to_center = 6 [default = nan];
optional double length = 7 [default = nan];
optional double width = 8 [default = nan];
optional double height = 9 [default = nan];
optional double min_turn_radius = 10 [default = nan];
optional double max_acceleration = 11 [default = nan];
optional double max_deceleration = 12 [default = nan];
// The following items are used to compute trajectory constraints in
// planning/control/canbus,
// vehicle max steer angle
optional double max_steer_angle = 13 [default = nan];
// vehicle max steer rate; how fast can the steering wheel turn.
optional double max_steer_angle_rate = 14 [default = nan];
// vehicle min steer rate;
optional double min_steer_angle_rate = 15 [default = nan];
// ratio between the turn of steering wheel and the turn of wheels
optional double steer_ratio = 16 [default = nan];
// the distance between the front and back wheels
optional double wheel_base = 17 [default = nan];
// Tire effective rolling radius (vertical distance between the wheel center
// and the ground).
optional double wheel_rolling_radius = 18 [default = nan];
// minimum differentiable vehicle speed, in m/s
optional float max_abs_speed_when_stopped = 19 [default = nan];
// minimum value get from chassis.brake, in percentage
optional double brake_deadzone = 20 [default = nan];
// minimum value get from chassis.throttle, in percentage
optional double throttle_deadzone = 21 [default = nan];
// vehicle latency parameters
optional LatencyParam steering_latency_param = 22;
optional LatencyParam throttle_latency_param = 23;
optional LatencyParam brake_latency_param = 24;
}
message VehicleConfig {
optional apollo.common.Header header = 1;
optional VehicleParam vehicle_param = 2;
optional Extrinsics extrinsics = 3;
}
| 0
|
apollo_public_repos/apollo/modules/common_msgs
|
apollo_public_repos/apollo/modules/common_msgs/config_msgs/BUILD
|
## Auto generated by `proto_build_generator.py`
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("//tools:python_rules.bzl", "py_proto_library")
package(default_visibility = ["//visibility:public"])
cc_proto_library(
name = "vehicle_config_cc_proto",
deps = [
":vehicle_config_proto",
],
)
proto_library(
name = "vehicle_config_proto",
srcs = ["vehicle_config.proto"],
deps = [
"//modules/common_msgs/basic_msgs:header_proto",
"//modules/common_msgs/basic_msgs:geometry_proto",
"//modules/common_msgs/basic_msgs:vehicle_id_proto",
],
)
py_proto_library(
name = "vehicle_config_py_pb2",
deps = [
":vehicle_config_proto",
"//modules/common_msgs/basic_msgs:header_py_pb2",
"//modules/common_msgs/basic_msgs:geometry_py_pb2",
"//modules/common_msgs/basic_msgs:vehicle_id_py_pb2",
],
)
| 0
|
apollo_public_repos/apollo/modules/common_msgs
|
apollo_public_repos/apollo/modules/common_msgs/storytelling_msgs/story.proto
|
syntax = "proto2";
package apollo.storytelling;
import "modules/common_msgs/basic_msgs/header.proto";
message CloseToCrosswalk {
optional string id = 1;
optional double distance = 2 [default = nan];
}
message CloseToClearArea {
optional string id = 1;
optional double distance = 2 [default = nan];
}
message CloseToJunction {
enum JunctionType {
PNC_JUNCTION = 1;
JUNCTION = 2;
};
optional string id = 1;
optional JunctionType type = 2;
optional double distance = 3 [default = nan];
}
message CloseToSignal {
optional string id = 1;
optional double distance = 2 [default = nan];
}
message CloseToStopSign {
optional string id = 1;
optional double distance = 2 [default = nan];
}
message CloseToYieldSign {
optional string id = 1;
optional double distance = 2 [default = nan];
}
// Usage guide for action modules:
// 1. Call `stories.has_XXX()` to check if a story you are interested is in
// charge.
// 2. Access the story details if necessary, and take action accordingly.
message Stories {
optional apollo.common.Header header = 1;
optional CloseToClearArea close_to_clear_area = 2;
optional CloseToCrosswalk close_to_crosswalk = 3;
optional CloseToJunction close_to_junction = 4;
optional CloseToSignal close_to_signal = 5;
optional CloseToStopSign close_to_stop_sign = 6;
optional CloseToYieldSign close_to_yield_sign = 7;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.