Skip to content

Instantly share code, notes, and snippets.

@horverno
Last active February 5, 2026 07:35
Show Gist options
  • Select an option

  • Save horverno/b51fb4f42172461f74ad406ce079c5e6 to your computer and use it in GitHub Desktop.

Select an option

Save horverno/b51fb4f42172461f74ad406ce079c5e6 to your computer and use it in GitHub Desktop.

Megbeszélés jegyzet:

Battery model: input data (topics):

  • throttle reference (nyomaték referencia) - CARLA
  • brake reference (féknyomaték referencia) - CARLA
  • speed - CARLA
  • mechanical power required (teljesítményigény) // current demand
  • <start_power_draining_topic>: Topic(s) that can be used to start power draining.
  • <stop_power_draining_topic>: Topic(s) that can be used to stop power draining.

output data (topics):

  • battery voltage (akkumulátor feszültség)
  • State of Charge (SoC) (akkumulátor töltöttségi szint)
  • battery energy consumed (akkumulátor energiafogyasztás)

state variables (debug topics):

params:

  • regenerative braking treshold (rekuperációs fékezési küszöbérték)
  • volage inintial value (feszültség kezdeti érték)
  • SoC initial value (akkumulátor töltöttségi szint kezdeti érték)
  • : Total charge that the battery can hold (Ah).
  • <power_load>: Power load on battery (W).

Vehicle model

Zoliék cikke (Control-Oriented Model for Energy-Efficient Electric Vehicle) alapján készült jármű modell.

graph LR;

VM_IN1["/torqueref"]:::dark
VM_IN2["/track_slope"]:::dark
VM_OUT1["/efficiency"]:::dark
VM_OUT2["/force_drive"]:::dark
VM_OUT3["/speed"]:::dark
VM_IN1 --> VM
VM_IN2 --> VM
VM --> VM_OUT1
VM --> VM_OUT2
VM --> VM_OUT3

VM["Nemlineáris járműmodell<br/><br/>Alblokkok:<br/>- Powertrain: F_drive, eta_drive<br/>- Resistance: F_res (aero, gördülés, emelkedő)<br/>- Track: R, Fz<br/>- ΣF -> a=ΣF/m -> ∫a dt = x -> ∫x dt = s<br/><br/>Kimenet (consumption):<br/>- η_drive hatékonyság<br/>- F_drive (force)<br/>- v (sebesség)"]:::light




classDef light fill:#34aec5,stroke:#152742,stroke-width:2px,color:#152742  
classDef dark fill:#152742,stroke:#34aec5,stroke-width:2px,color:#34aec5
classDef white fill:#ffffff,stroke:#152742,stroke-width:2px,color:#152742
classDef red fill:#ef4638,stroke:#152742,stroke-width:2px,color:#fff


Loading

Carla sim

  • throttle reference (nyomaték referencia) - CARLA
  • brake reference (féknyomaték referencia) - CARLA
  • speed - CARLA
graph LR;

C_IN1["/throttle_cmd (accel_cmd)"]:::dark
C_IN2["/brake_cmd"]:::dark
C_IN3["/steer_cmd"]:::dark
C_IN4[" map based global slope"]:::dark
C_OUT1["/sensing/gnss/pose"]:::dark
C_OUT2["/sensing/imu"]:::dark
C_OUT3["/vehicle_status (speed)"]:::dark
C_OUT4["actual slope"]:::dark

CM["CARLA járműmodell<br/><br/>Input:<br/> - /control/command/actuation_cmd <br/> Output:<br/> - /vehicle_status/velocity"]:::light

C_IN1 --> CM
C_IN2 --> CM
C_IN3 --> CM
C_IN4 --> CM
CM --> C_OUT1
CM --> C_OUT2
CM --> C_OUT3
CM --> C_OUT4



classDef light fill:#34aec5,stroke:#152742,stroke-width:2px,color:#152742  
classDef dark fill:#152742,stroke:#34aec5,stroke-width:2px,color:#34aec5
classDef white fill:#ffffff,stroke:#152742,stroke-width:2px,color:#152742
classDef red fill:#ef4638,stroke:#152742,stroke-width:2px,color:#fff


Loading

Battery model

output data (topics):

  • battery voltage (akkumulátor feszültség)
  • State of Charge (SoC) (akkumulátor töltöttségi szint)
  • battery energy consumed (akkumulátor energiafogyasztás)
graph LR;

B_IN1["/force_drive"]:::dark
B_IN2[" map based global slope"]:::dark
B_PARAM1[" param initial_soc"]:::white
B_PARAM2[" param regen_brake_threshold"]:::white
B_OUT1["/battery/voltage"]:::dark
B_OUT2["/battery/soc"]:::dark
B_OUT3["/battery/energy_consumed"]:::dark


BM["Battery model<br/><br/>Input:<br/> - <br/> - State of Charge (SoC)<br/> -"]:::light

B_IN1 --> BM
B_IN2 --> BM
B_PARAM1 --> BM
B_PARAM2 --> BM
BM --> B_OUT1
BM --> B_OUT2
BM --> B_OUT3


classDef light fill:#34aec5,stroke:#152742,stroke-width:2px,color:#152742  
classDef dark fill:#152742,stroke:#34aec5,stroke-width:2px,color:#34aec5
classDef white fill:#ffffff,stroke:#152742,stroke-width:2px,color:#152742
classDef red fill:#ef4638,stroke:#152742,stroke-width:2px,color:#fff


Loading

Combined

graph LR;

%% ---------- Vehicle model ----------
subgraph S_VM["Vehicle model"]
direction LR

VM_IN1["/torqueref"]:::dark --> VM
VM_IN2["/track_slope"]:::dark --> VM

VM --> VM_OUT1["/efficiency"]:::dark
VM --> VM_OUT2["/force_drive"]:::dark
VM --> VM_OUT3["/speed"]:::dark

VM["Nemlineáris járműmodell<br/><br/>Alblokkok:<br/>- Powertrain: F_drive, eta_drive<br/>- Resistance: F_res (aero, gördülés, emelkedő)<br/>- Track: R, Fz<br/>- ΣF -> a=ΣF/m -> ∫a dt = x -> ∫x dt = s<br/><br/>Kimenet (consumption):<br/>- η_drive hatékonyság<br/>- F_drive (force)<br/>- v (sebesség)"]:::light

end

%% ---------- CARLA sim ----------
subgraph S_CARLA["CARLA sim"]
direction LR

C_IN1["/throttle_cmd (accel_cmd)"]:::dark --> CM
C_IN2["/brake_cmd"]:::dark --> CM
C_IN3["/steer_cmd"]:::dark --> CM
C_IN4["map based global slope"]:::dark --> CM

CM --> C_OUT1["/sensing/gnss/pose"]:::dark
CM --> C_OUT2["/sensing/imu"]:::dark
CM --> C_OUT3["/vehicle_status (speed)"]:::dark
CM --> C_OUT4["actual slope"]:::dark

CM["CARLA járműmodell<br/><br/>Input:<br/> - /control/command/actuation_cmd<br/>Output:<br/> - /vehicle_status/velocity"]:::light

end

%% ---------- Battery model ----------
subgraph S_BATT["Battery model"]
direction LR

B_IN1["/p_mech (Power request)"]:::dark --> BM
B_IN2["/ambient_temperature"]:::dark --> BM
B_PARAM1["param initial_soc"]:::white --> BM
B_PARAM2["param regen_brake_threshold"]:::white --> BM

BM --> B_OUT1["/battery/soc"]:::dark
BM --> B_OUT2["/battery/max_load_power"]:::dark
BM --> B_OUT3["/battery/max_charge_power"]:::dark
BM --> B_OUT4["/battery/temperature"]:::dark
BM --> B_OUT5["/battery/voltage"]:::dark
BM --> B_OUT6["/battery/energy_consumed"]:::dark
BM --> B_OUT7["/battery/soh"]:::dark

BM["Battery model<br/><br/>Input:<br/>- Power request (p_mech)<br/>- Ambient Temperature<br/>- Initial SoC<br/>- Regen threshold<br/><br/>Output:<br/>- SoC<br/>- Max Load Power<br/>- Max Charge Power<br/>- Temperature<br/>- Voltage<br/>- Energy Consumed<br/>- SoH"]:::light

end

%% ---------- Cross-links (optional but typical) ----------
%% If CARLA slope is your /track_slope source:
C_OUT4 --> VM_IN2

%% Vehicle model drives Battery model:
VM_OUT2 --> B_IN1

%% ---------- Styles (define once) ----------
classDef light fill:#34aec5,stroke:#152742,stroke-width:2px,color:#152742
classDef dark  fill:#152742,stroke:#34aec5,stroke-width:2px,color:#34aec5
classDef white fill:#ffffff,stroke:#152742,stroke-width:2px,color:#152742
classDef red   fill:#ef4638,stroke:#152742,stroke-width:2px,color:#fff
	
Loading

--- IGNORE ---

ros2 topic echo /vehicle/status/velocity_status --once
header:
  stamp:
    sec: 205
    nanosec: 100003056
  frame_id: base_link
longitudinal_velocity: 3.24501633644104
lateral_velocity: -0.30875223875045776
heading_rate: -10.058479309082031
ros2 topic echo /control/command/actuation_cmd --once
header:
  stamp:
    sec: 256
    nanosec: 950003828
  frame_id: base_link
actuation:
  accel_cmd: 0.0
  brake_cmd: 0.6
  steer_cmd: -0.3264337480068207

Slope 1

ros2 topic echo --once /control/trajectory_follower/longitudinal/slope_angle
stamp:
  sec: 326
  nanosec: 100004859
layout:
  dim: []
  data_offset: 0
data:
- -4.3699801608454436e-05
---

Slope 2 (rviz scenario planning scenario trajectory view text slope)

ros2 interface show autoware_planning_msgs/msg/Trajectory
std_msgs/Header header
	builtin_interfaces/Time stamp
		int32 sec
		uint32 nanosec
	string frame_id
autoware_planning_msgs/TrajectoryPoint[] points
	builtin_interfaces/Duration time_from_start
		int32 sec
		uint32 nanosec
	geometry_msgs/Pose pose
		Point position
			float64 x
			float64 y
			float64 z
		Quaternion orientation
			float64 x 0
			float64 y 0
			float64 z 0
			float64 w 1
	float32 longitudinal_velocity_mps
	float32 lateral_velocity_mps
	float32 acceleration_mps2
	float32 heading_rate_rps
	float32 front_wheel_angle_rad
	float32 rear_wheel_angle_rad
ros2 interface show sensor_msgs/msg/BatteryState

# Constants are chosen to match the enums in the linux kernel
# defined in include/linux/power_supply.h as of version 3.7
# The one difference is for style reasons the constants are
# all uppercase not mixed case.

# Power supply status constants
uint8 POWER_SUPPLY_STATUS_UNKNOWN = 0
uint8 POWER_SUPPLY_STATUS_CHARGING = 1
uint8 POWER_SUPPLY_STATUS_DISCHARGING = 2
uint8 POWER_SUPPLY_STATUS_NOT_CHARGING = 3
uint8 POWER_SUPPLY_STATUS_FULL = 4

# Power supply health constants
uint8 POWER_SUPPLY_HEALTH_UNKNOWN = 0
uint8 POWER_SUPPLY_HEALTH_GOOD = 1
uint8 POWER_SUPPLY_HEALTH_OVERHEAT = 2
uint8 POWER_SUPPLY_HEALTH_DEAD = 3
uint8 POWER_SUPPLY_HEALTH_OVERVOLTAGE = 4
uint8 POWER_SUPPLY_HEALTH_UNSPEC_FAILURE = 5
uint8 POWER_SUPPLY_HEALTH_COLD = 6
uint8 POWER_SUPPLY_HEALTH_WATCHDOG_TIMER_EXPIRE = 7
uint8 POWER_SUPPLY_HEALTH_SAFETY_TIMER_EXPIRE = 8

# Power supply technology (chemistry) constants
uint8 POWER_SUPPLY_TECHNOLOGY_UNKNOWN = 0
uint8 POWER_SUPPLY_TECHNOLOGY_NIMH = 1
uint8 POWER_SUPPLY_TECHNOLOGY_LION = 2
uint8 POWER_SUPPLY_TECHNOLOGY_LIPO = 3
uint8 POWER_SUPPLY_TECHNOLOGY_LIFE = 4
uint8 POWER_SUPPLY_TECHNOLOGY_NICD = 5
uint8 POWER_SUPPLY_TECHNOLOGY_LIMN = 6

std_msgs/Header  header
        builtin_interfaces/Time stamp
                int32 sec
                uint32 nanosec
        string frame_id
float32 voltage          # Voltage in Volts (Mandatory)
float32 temperature      # Temperature in Degrees Celsius (If unmeasured NaN)
float32 current          # Negative when discharging (A)  (If unmeasured NaN)
float32 charge           # Current charge in Ah  (If unmeasured NaN)
float32 capacity         # Capacity in Ah (last full capacity)  (If unmeasured NaN)
float32 design_capacity  # Capacity in Ah (design capacity)  (If unmeasured NaN)
float32 percentage       # Charge percentage on 0 to 1 range  (If unmeasured NaN)
uint8   power_supply_status     # The charging status as reported. Values defined above
uint8   power_supply_health     # The battery health metric. Values defined above
uint8   power_supply_technology # The battery chemistry. Values defined above
bool    present          # True if the battery is present

float32[] cell_voltage   # An array of individual cell voltages for each cell in the pack
                         # If individual voltages unknown but number of cells known set each to NaN
float32[] cell_temperature # An array of individual cell temperatures for each cell in the pack
                           # If individual temperatures unknown but number of cells known set each to NaN
string location          # The location into which the battery is inserted. (slot number or plug)
string serial_number     # The best approximation of the battery serial number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment